[omniORB] Object Reference Rules

Armen Yampolsky ayampolsky@erols.com
Wed, 24 Mar 1999 17:57:53 +0000


Hi,

Apologies if this question is not entirely omniORB-specific. I am trying
to figure out the correct way of passing an object reference from server
to client and back again. A simple example IDL would look as follows:

-------------------------------
interface SimpleObject {
    attribute long count;
    void kill();    // counterpart to ObjFactory::createObj(), clears
server resources.
};

interface ObjectHolder {
    void put(in SimpleObject obj);
    SimpleObject get();
};

interface ObjFactory {
    SimpleObject createObj();
};
-------------------------------


Now what I want to do is the following:
(1) receive ref to a newly instantiated SimpleObject via
ObjFactory::createObj().
(2) put it into the ObjectHolder on the server.
(3) get it from the ObjectHolder.
(4) alter its attribute.
(5) put it back in the ObjectHolder.
(6) repeat 3-5 as much as I want.

Instantiation via ObjFactory::createObj() works fine, we call
_obj_is_ready and _this as required by the spec. Modifying the object
reference's attribute on the client works fine. SimpleObject::kill()
calls _dispose(), and this works correctly as usual. Putting the
SimpleObject into the ObjectHolder seems to work fine as well. But
here's where the questions arise. In ObjectHolder::get() we can not call
_this() on the object prior to returning it, as it is now recognized by
the ObjectHolder as a SimpleObject_ptr, which does not have a _this()
method. We tried calling _duplicate in the ObjectHolder::put(), but this
leaks memory. We then tried adding a CORBA::release() on the new
duplicate, but then got OBJECT_NOT_EXIST exception on the client. What
is the correct way to implement these methods (ObjecHolder::put and
ObjectHolder::get)?

Note: Client is in Java, server is omniORB2.7.1 on Solaris 2.6.

TIA,
-Armen



--
Armen Yampolsky
Axiom Software Labs
New York