[omniORB] Persistent Obj Refs.
Alex Hayward
xelah@xelah.com
Tue, 19 Jun 2001 14:53:14 +0100 (BST)
On Tue, 19 Jun 2001, Andrew Weaver wrote:
> Moi, here is some modification of eg2_impl from the
> $TOP/src/examples/poa/persistent_objeref
>
> // Activate the echo object...
> Echo_i* myecho = new Echo_i();
> //
> // AWE - 1
> //
> obj = myecho->_this();
> CORBA::String_var sior(orb->object_to_string(obj));
> cerr << "AWE 1 '" << (char*)sior << "'" << endl;
>
> poa->activate_object_with_id(oid, myecho);
> //
> // AWE -2
> //
> obj = myecho->_this();
> CORBA::String_var sior2(orb->object_to_string(obj));
> cerr << "AWE 2 '" << (char*)sior2 << "'" << endl;
>
> With the code like this, I get the same string for the IOR from the AWE -1
> block as from AWE-2. However, this string is not the same from run to run.
>
> If I comment out the AWE-2 code, I get not the same string run to run.
>
> Only when the code is as the original (with only AWE-2 code active) all is
> OK. I am curious about this behaviour.
omniORB won't generate the same IOR for the same object ID on each run
unless you use a special POA. You can get a reference to this POA using
orb->resolve_initial_references("omniINSPOA"); Even setting the PERSISTENT
life span policy won't get you IORs that don't change...
This turned out to be a particular problem for me a little while ago
because I had wanted to use a POA with PERSISTENT set and a servant
manager to load objects from a database as required. Instead I work around
it by having the clients call a special 'find' method if they get any
unexpected exceptions (eg an OBJECT_NOT_EXIST exception caused by the
server restarting).