Sagewire Logo

Returning remote reference to an object by another remote object

4 Message(s) by 3 Author(s) originally posted in java corba


From: Marek Date:   Wednesday, January 25, 2006
Hi,

This is my problem:

I've many object s 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 have 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.


From: vivekm Date:   Friday, January 27, 2006
Hello,

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

Best Regards,
Vivekanandan M


From: Marek Date:   Friday, January 27, 2006
Uzytkownik <vivekm@xxxxxxxxxxx> napisal w wiadomosci

Hello,
Try using a Naming service instead of passing the object reference,
its a good design.
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


From: Piet van Oostrum Date:   Sunday, January 29, 2006
wrote in message:

M> Hi,
M> This is my problem:



M> I've 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:
M> class A {
M> ...
M> B getB(){...}
M> ...
M> }



M> I have 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));
--
Piet van Oostrum <piet@xxxxxxxxxxx>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet@xxxxxxxxxxx



Next Message: I can not install orbacus on a machine with only C++.Net


Blogs related to Returning remote reference to an object by another remote object

38. Servlets 20 mins drill and Quiz.
A open source library for java. Please refer sourceforge site for sample servlet examples. ... If a session is existing, it will return that session object, ... If session exists, then it returns the reference of that session object, ...

Core Java & J2EE
What value does readLine() return when it has reached the end of a file'The ... What is the default value of an object reference declared as an instance variable'null ... They have to deal with communication between remote systems, ...

Creating interactive prototypes: let’s move beyond “paper prototypes”
This dialog box lets you link an object to another PowerPoint file or even ... and running external programs such as small programs written in Java or more ... be published on a Web site for easy review by reviewers at remote locations. ...

Swing and Roundabouts 1M: Emission DTs
Another option is eventbus.dev.java.net by Michael Bushe, which uses the ... Those might be serialised into XML, and sent over HTTP to remote QRestResource responders. ... where we wait for a response, and return a response object. ...

Core Java & J2EE
What value does readLine() return when it has reached the end of a file? ... Java only supports pass by value. With objects, the object reference itself is passed by value ... They have to deal with communication between remote systems, ...

JAVA BASIC QUESTIONS
21) Which cast must be used to cast an object to another class? ... 45) You can explicitly drop a object reference by setting the value of a variable whose data type ... Java Supports three jump statements: break, continue, and return. ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional