Board index » off-topic » Persistent IOR

Persistent IOR


2005-05-30 10:38:04 PM
off-topic5
I'm having a problem figuring out how to create a persistent IOR for the
service we're deploying with BES Visibroker Edition 6.5.
Using a persistent IOR is a requisite of the application we are developing.
Every time we start up the server application, it generates a different IOR.
We're using smart agent and I'd like to know what else should we do to make
it work (like setting environment variables, etc)..
Below is the implementation of the persistent IOR in the server:
// Init ORB
Properties props = System.getProperties();
/* WE DON'T NEED THIS AS WE ARE USING VBJ AS JAVA VM*/
props.setProperty("org.omg.CORBA.ORBClass",
"com.inprise.vbroker.orb.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass",
"com.inprise.vbroker.orb.ORBSingleton");
/**/
orb = org.omg.CORBA.ORB.init(new String[]{}, props);
org.omg.CORBA.Object object =
orb.resolve_initial_references("RootPOA");
// Create root POA
rootPoa = POAHelper.narrow(object);
// Define policies for AuthFactory child POA
Policy[] poaPolicies = new org.omg.CORBA.Policy[]{
rootPoa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)};
// Create the AuthFactory child POA
authPoa = rootPoa.create_POA("AuthFactoryPOA",
rootPoa.the_POAManager(), poaPolicies);
logger.info("Initializing singleton instance of
AuthenticationFactory...");
// Create a AuthFactory servant
AuthFactoryImpl auth = AuthFactoryImpl.getInstance(orb);
// Create the AuthFactory servant ID (because we have USER_ID
policy)
byte[] servantId = (new String ("AUTH_FACTORY")).getBytes();
// Activate the AuthFactory servant with ID created.
authPoa.activate_object_with_id(servantId, auth);
// Activate POAManager
rootPoa.the_POAManager().activate();
// Get the servant reference (that we want to stringify and
store)
org.omg.CORBA.Object obj = authPoa.id_to_reference (servantId);
// Get stringified AuthFactoryImpl reference
String singletonIOR = orb.object_to_string(obj);
logger.info("Singleton instance has IOR: "+singletonIOR);
Any help would be really useful..
Thanks in advance,
Fred
 
 

Re:Persistent IOR

One reason why IOR is different could be because you have not fixed the
port value for the server. Use following property to do so:
vbroker.se.iiop_tp.scm.iiop_tp.listener.port=<port where server
listens>
The IOR will also change if you change the host where server is run.
HTH
LL
Frederico Melo wrote:
Quote
I'm having a problem figuring out how to create a persistent IOR for the
service we're deploying with BES Visibroker Edition 6.5.
Using a persistent IOR is a requisite of the application we are developing.
Every time we start up the server application, it generates a different IOR.
We're using smart agent and I'd like to know what else should we do to make
it work (like setting environment variables, etc)..

Below is the implementation of the persistent IOR in the server:



// Init ORB
Properties props = System.getProperties();

/* WE DON'T NEED THIS AS WE ARE USING VBJ AS JAVA VM*/
props.setProperty("org.omg.CORBA.ORBClass",
"com.inprise.vbroker.orb.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass",
"com.inprise.vbroker.orb.ORBSingleton");
/**/

orb = org.omg.CORBA.ORB.init(new String[]{}, props);
org.omg.CORBA.Object object =
orb.resolve_initial_references("RootPOA");

// Create root POA
rootPoa = POAHelper.narrow(object);

// Define policies for AuthFactory child POA
Policy[] poaPolicies = new org.omg.CORBA.Policy[]{
rootPoa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)};



// Create the AuthFactory child POA
authPoa = rootPoa.create_POA("AuthFactoryPOA",
rootPoa.the_POAManager(), poaPolicies);

logger.info("Initializing singleton instance of
AuthenticationFactory...");
// Create a AuthFactory servant
AuthFactoryImpl auth = AuthFactoryImpl.getInstance(orb);



// Create the AuthFactory servant ID (because we have USER_ID
policy)
byte[] servantId = (new String ("AUTH_FACTORY")).getBytes();

// Activate the AuthFactory servant with ID created.
authPoa.activate_object_with_id(servantId, auth);

// Activate POAManager
rootPoa.the_POAManager().activate();

// Get the servant reference (that we want to stringify and
store)
org.omg.CORBA.Object obj = authPoa.id_to_reference (servantId);

// Get stringified AuthFactoryImpl reference
String singletonIOR = orb.object_to_string(obj);
logger.info("Singleton instance has IOR: "+singletonIOR);

Any help would be really useful..

Thanks in advance,





Fred
 

Re:Persistent IOR

Frederico:
First: You should desactive Smart Agent location.
vbroker.agent.enableLocator = false
Below examples the implementation (persistent ior).
Server.
Set necesary properties. License, etcs.
..
ORB orb = ORB.init(args, null);
POA root_poa = POAHelper.narrow(orb_resolver_references("RootPOA"));
XXXImpl xxx_servant = new XXXImpl();
XXXCorbaObject corba_object = xxx_servant._this(orb); // Crear el
Objeto Corba
PrintWriter output = new PrintWriter(new BufferedWriter(new
FileWriter("xxxx.ior"))); // saving the ior.
output.println(orb.object_to_string(corba_object));
output.close();
root_poa.the_POAManager().activate();
orb.run();
Client:
..
ORB orb = ORB.init(args, null);
....
String ior = null;
BufferedReader input = new BufferedReader(new FileReader("xxxx.ior"));
ior = input.readLine();
org.omg.CORBA.Object object = orb.string_to_object(ior);
XXXXCorbaObject corba_object = XXXXCorbaObjectHelper.narrow(object);
// .. in this point you can to invoke the methods the interface.
PD:
The point important is: vbroker.agent.enableLocator = false, because
Visibroker uses the Smart Agent by default as Service Locator...
Luis Felipe González
Venezuela
"Frederico Melo" < XXXX@XXXXX.COM >wrote in message
Quote
I'm having a problem figuring out how to create a persistent IOR for the
service we're deploying with BES Visibroker Edition 6.5.
Using a persistent IOR is a requisite of the application we are
developing. Every time we start up the server application, it generates a
different IOR. We're using smart agent and I'd like to know what else
should we do to make it work (like setting environment variables, etc)..

Below is the implementation of the persistent IOR in the server:



// Init ORB
Properties props = System.getProperties();

/* WE DON'T NEED THIS AS WE ARE USING VBJ AS JAVA VM*/
props.setProperty("org.omg.CORBA.ORBClass",
"com.inprise.vbroker.orb.ORB");
props.setProperty("org.omg.CORBA.ORBSingletonClass",
"com.inprise.vbroker.orb.ORBSingleton");
/**/

orb = org.omg.CORBA.ORB.init(new String[]{}, props);
org.omg.CORBA.Object object =
orb.resolve_initial_references("RootPOA");

// Create root POA
rootPoa = POAHelper.narrow(object);

// Define policies for AuthFactory child POA
Policy[] poaPolicies = new org.omg.CORBA.Policy[]{

rootPoa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),

rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)};



// Create the AuthFactory child POA
authPoa = rootPoa.create_POA("AuthFactoryPOA",
rootPoa.the_POAManager(), poaPolicies);

logger.info("Initializing singleton instance of
AuthenticationFactory...");
// Create a AuthFactory servant
AuthFactoryImpl auth = AuthFactoryImpl.getInstance(orb);



// Create the AuthFactory servant ID (because we have USER_ID
policy)
byte[] servantId = (new String ("AUTH_FACTORY")).getBytes();

// Activate the AuthFactory servant with ID created.
authPoa.activate_object_with_id(servantId, auth);

// Activate POAManager
rootPoa.the_POAManager().activate();

// Get the servant reference (that we want to stringify and
store)
org.omg.CORBA.Object obj = authPoa.id_to_reference (servantId);

// Get stringified AuthFactoryImpl reference
String singletonIOR = orb.object_to_string(obj);
logger.info("Singleton instance has IOR: "+singletonIOR);

Any help would be really useful..

Thanks in advance,





Fred





 

{smallsort}