Corba POA
Jeg har problemer med Corba (java 1.4 ORB)Jeg har fået den til at kalde et remote objekt og få svar, men jeg kan ikke greje det med POA\'er. Jeg hvis jeg forsøger at lava en childPOA med vil objekterne ikke længere lade sig binde.
Kode:
---------------------------------------
// create and initialize the ORB
ORB orb = ORB.init(args, null);
// get reference to rootpoa & activate the POAManager
POA rootpoa = (POA)orb.resolve_initial_references(\"RootPOA\");
POAManager manager = rootpoa.the_POAManager();
Policy[] policies = new org.omg.CORBA.Policy[0];
//policies[0] = rootpoa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
//policies[1] = rootpoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
POA poa = rootpoa.create_POA(\"persistent\", manager, policies);
rootpoa.the_POAManager().activate();
poa.the_POAManager().activate();
// create servant and register it with the ORB
AccountFactoryImpl factory = new AccountFactoryImpl();
factory.setORB(orb);
factory.setPOA(rootpoa); //Her prøver jeg i stedet at binde til poa, men det går galt
// get object reference from the servant
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(factory); //Her skal det også være poa i stedet for rootpoa
AccountFactory href = AccountFactoryHelper.narrow(ref);
// get the root naming context
// NameService invokes the transient name service
org.omg.CORBA.Object objRef = orb.resolve_initial_references(\"NameService\");
// Use NamingContextExt which is part of the Interoperable
// Naming Service (INS) specification.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
// bind the Object Reference in Naming
String name = \"AccountFactory\";
NameComponent path[] = ncRef.to_name( name );
ncRef.rebind(path, href);
System.out.println(\"HelloServer ready and waiting ...\");
// wait for invocations from clients
orb.run();
