jlengrand
jlengrand

Reputation: 12827

Get access to the ORB into an implementation?

I have a tricky problem. And being new to CORBA, I'm unable to get out of it.

How can I instantiate an implementation object from another implementation?

Usually, if I have an interface A. I would create an A_Impl class (in a A_Impl.java file), extending from the A_POA class generated from the idl.

Then, on the server side I would do something like this :

AImpl  my_a_impl = new A_Impl ();
org.omg.CORBA.Object ref = orb.activate_object(my_a_impl);
A my_a_object = A.narrow(ref);

But what when one of the methods of another object B needs to return A?

In my B_impl class, I don't have access to the orb and thus cannot get a reference to my object by using the activate_object method.

How can I then return such an object?

Any help would be greatly appreciated. Thanks in advance !

Upvotes: 1

Views: 251

Answers (3)

Brian Kelly
Brian Kelly

Reputation: 19305

CORBA already offers a function that can be used to get an existing ORB reference - ORB_init(). For most ORBs, that function behaves like a singleton and will return an existing ORB object, assuming you use the same ORB ID each time you call it.

Upvotes: 1

jlengrand
jlengrand

Reputation: 12827

It seems like (for a non comprehensible reason for me), constructors are not generated by the idl. Creating constructors allows me to simply pass objects as references and make them visible to my classes. Yes... as simple as that :)

Upvotes: 0

dash1e
dash1e

Reputation: 7807

Put a reference to the current active orb in a singleton class, that you can reach from very object *_Impl.

Upvotes: 0

Related Questions