public static void main(String[] args)
{
java.util.Properties props = System.getProperties();
ORB orb = null;
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POA poa;
Policy[] policies;
POAManager manager = root.the_POAManager();
//
// Create POAs
//
policies = new Policy[ 4 ];
policies [ 0 ] =
root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies [ 1 ] =
root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies [ 2 ] =
root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies [ 3 ] =
root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
try
{
poa = root.create_POA("poa", manager, policies);
}
catch (AdapterAlreadyExists ex)
{
throw new RuntimeException(ex);
}
catch (InvalidPolicy ex)
{
throw new RuntimeException(ex);
}
TestLocationForwardActivator_impl activatorImpl =
new TestLocationForwardActivator_impl();
org.omg.PortableServer.ServantActivator activator =
activatorImpl._this(orb);
try
{
poa.set_servant_manager(activator);
}
catch (WrongPolicy ex)
{
throw new RuntimeException(ex);
}
byte[] oid = "test".getBytes();
org.omg.CORBA.Object obj =
poa.create_reference_with_id(oid, "IDL:Test:1.0");
TestLocationForward_impl testImpl = new TestLocationForward_impl(orb);
activatorImpl.setActivatedServant(testImpl);
Server_impl serverImpl = new Server_impl(orb, activatorImpl, obj);
TestLocationForwardServer server = serverImpl._this(orb);
//
// Save reference
//
String refFile = "Test.ref";
try
{
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(ior = orb.object_to_string(server));
out.flush();
file.close();
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
//
// Run implementation
//
try
{
manager.activate();
}
catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
{
throw new RuntimeException(ex);
}
orb.run();
File file = new File(refFile);
file.delete();
orb.destroy();
}