POA root = TestUtil.GetRootPOA(orb);
POA poa;
Policy[] policies;
POAManager manager = root.the_POAManager();
//
// Create POA
//
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 (InvalidPolicy ex)
{
throw new RuntimeException(ex);
}
catch (AdapterAlreadyExists ex)
{
throw new RuntimeException(ex);
}
TestLocationForwardActivator_impl activatorImpl =
new TestLocationForwardActivator_impl();
ServantActivator activator = activatorImpl._this(orb);
try
{
poa.set_servant_manager(activator);
}
catch (WrongPolicy ex)
{
throw new RuntimeException(ex);
}
byte[] oid = ("test").getBytes();
final org.omg.CORBA.Object reference =
poa.create_reference_with_id(oid, TestLocationForwardHelper.id());
//"IDL:Test:1.0");
String impl = null;
//
// Read all object references from file
//
try
{
String refFile = "Test.ref";
FileInputStream file = new FileInputStream(refFile);
BufferedReader in = new BufferedReader(new InputStreamReader(file));
impl = in.readLine();
file.close();
}
catch (IOException ex)
{
System.err.println("Can't read from `" + ex.getMessage() + "'");
System.exit(1);
}
org.omg.CORBA.Object obj = orb.string_to_object(impl);
TestLocationForwardServer server =
TestLocationForwardServerHelper.narrow(obj);
if (server == null)
throw new RuntimeException("Server is null");
org.omg.CORBA.Object servant = server.get_servant();
activatorImpl.setForwardRequest(servant);
TestLocationForward_impl testImpl = new TestLocationForward_impl(orb);
activatorImpl.setActivatedServant(testImpl);
try
{
manager.activate();
}
catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
{
throw new RuntimeException(ex);
}