use of org.codice.alliance.nsili.mockserver.impl.LibraryImpl in project alliance by codice.
the class MockNsili method getOrbForServer.
private ORB getOrbForServer(int port) throws InvalidName, AdapterInactive, WrongPolicy, ServantNotActive, IOException {
System.setProperty("org.omg.CORBA.ORBInitialPort", String.valueOf(port));
final ORB orb = ORB.init(new String[0], null);
System.clearProperty("org.omg.CORBA.ORBInitialPort");
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootPOA.the_POAManager().activate();
org.omg.CORBA.Object objref = rootPOA.servant_to_reference(new LibraryImpl(rootPOA));
// set ior.txt for http web server
iorString = orb.object_to_string(objref);
// set ior.txt for ftp web server
File ftpIorFile = new File(ftpHomeDirectoryPath + "/data/ior.txt");
File ftpDataDirectory = new File(ftpHomeDirectoryPath + "/data");
ftpDataDirectory.mkdirs();
if (!ftpIorFile.createNewFile()) {
LOGGER.error("Unable to create new file");
}
PrintWriter printWriter = new PrintWriter(new FileWriter(ftpIorFile.getPath()));
printWriter.print(orb.object_to_string(objref));
if (printWriter.checkError()) {
LOGGER.error("Unable to write ior string to ftp server temporary file");
}
printWriter.close();
return orb;
}
Aggregations