Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / CORBA / January 2006

Tip: Looking for answers? Try searching our database.

Returning remote reference to an object by another remote object

Thread view: 
Marek - 25 Jan 2006 18:19 GMT
Hi,

This is my problem:

I have many objects that need to be accessed remotly, for example A and B.
First object has method that returns reference to the second object:
class A {
   ...
   B getB(){...}
   ...
}

I've implemented servants for A and B (APOA and BPOA).
Method getB() returns reference made by rootPOA.servant_to_reference()
and narrowed by BHelper.narrow().
When I try to call some B's methods in a client application I get some null
pointer exception.

My question is how I should make and return reference to B by A's getB()
method?

Thanks in advance.
vivekm@sankhya.com - 27 Jan 2006 05:36 GMT
Hello,

  Try using a Naming service instead of passing the object reference,
its a good design.

Best Regards,
Vivekanandan M
Marek - 27 Jan 2006 21:13 GMT
> Hello,
>
[quoted text clipped - 3 lines]
> Best Regards,
> Vivekanandan M

The problem is that it ought to be done that way, because there's a software
which does
something like this:
...
SomeClassA someA =
SomeClassAHelper.narrow(remoteReferenceToATakenFromTheNameServer);
SomeClassB someB = SomeClassBHelper.narrow(someA.getB());
...
I need to write mocks for SomeClassA and SomeClassB.
Does anybody have idea how to do that?

Thanks and best regards
Piet van Oostrum - 29 Jan 2006 20:12 GMT
>>>>> "Marek" <hddoferty@wp.pl> (M) wrote:

>M> Hi,
>M> This is my problem:

>M> I have many objects that need to be accessed remotly, for example A and B.
>M> First object has method that returns reference to the second object:
[quoted text clipped - 3 lines]
>M>     ...
>M> }

>M> I've implemented servants for A and B (APOA and BPOA).
>M> Method getB() returns reference made by rootPOA.servant_to_reference()
>M> and narrowed by BHelper.narrow().
>M> When I try to call some B's methods in a client application I get some null
>M> pointer exception.

>M> My question is how I should make and return reference to B by A's getB()
>M> method?

The following should work:

BPOA b = new BPOA();
b.setORB(orb);

rootPOA.activate_object(b);
return BHelper.narrow(rootPOA.servant_to_reference(b));
Signature

Piet van Oostrum <piet@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet@vanoostrum.org



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.