Hi there!
I am working on a BMP (using weblogic 6.1)
My problem is - How do I contact remote interface from client. In my jndi tree I have mentioned only Home interface. Right now I am calling my remote interface like this:
//contact home interface
Object obj = ctx.lookup("APIHome");
APIHome home = (APIHome) javax.rmi.PortableRemoteObject.narrow(obj, APIHome.class);
//creating remote somehow - I got this clue from a website
rem = home.findByPrimaryKey(new EntityPK("test1","test2"));
//calling getter & setter methods
rem.setWidth()
rem.getId();
This works...but doesn't make any sense to me. Why should we initialize remote interface as above. Or is there any other option. Can somebody please explain me more clearly about this concept.
Thanks very much
regards
-Manasvi
-
Calling Remote interface from client (3 messages)
- Posted by: Manasvi M
- Posted on: May 28 2002 13:30 EDT
Threaded Messages (3)
- Calling Remote interface from client by Ashish Mangla on May 29 2002 05:12 EDT
- Calling Remote interface from client by Ashish Mangla on May 30 2002 06:08 EDT
- Calling Remote interface from client by Mark Hills on May 31 2002 01:43 EDT
-
Calling Remote interface from client[ Go to top ]
- Posted by: Ashish Mangla
- Posted on: May 29 2002 05:12 EDT
- in response to Manasvi M
Hi
You can also call create method of Home interface to get a reference of Remote Interface.
APIRemote = home.create();
& then u can call methods defined in RemoteInterface
APIRemote.getWidth();
I hope this will help to clear your doubt.
create method in home interface always gives the reference of RemoteInterface using Factory pattern. -
Calling Remote interface from client[ Go to top ]
- Posted by: Ashish Mangla
- Posted on: May 30 2002 06:08 EDT
- in response to Ashish Mangla
Hi
In continuation to my previous reply, I would like to add one more point.
Suppose u don't want to allow your client to insert a record in DB, in that case, u will not call
home.create() method.
In this particular case, the method u r using is the only way to get a reference of Remote Interface.
Object obj = ctx.lookup("APIHome");
APIHome home = (APIHome) javax.rmi.PortableRemoteObject.narrow(obj, APIHome.class);
//creating remote somehow - I got this clue from a website
rem = home.findByPrimaryKey(new EntityPK("test1","test2"));
//calling getter & setter methods
rem.setWidth()
rem.getId();
I hope this explanation will help. -
Calling Remote interface from client[ Go to top ]
- Posted by: Mark Hills
- Posted on: May 31 2002 01:43 EDT
- in response to Manasvi M
The quick answer to the question "How do I contact remote interface from client" is "You don't, directly". You have to do it in some method similar to what you have in the sample code.
EJBs have home and remote interfaces. The remote interface has all the business methods in it, like the getter and setter methods you mention. But it doesn't have the lifecycle methods to do things like create a new bean, or delete one you don't need anymore. The home interface has these. So, in order to create/delete/retrieve beans, you get the home interface first, which then hands you a remote interface.
I definitely would advise a good book on the topic. Check out Amazon and look up EJB books by either Roman (Mastering Enterprise JavaBeans, 2nd Edition) or Monson-Haefel (Enterprise JavaBeans, 3rd Edition). I think the first has a free PDF format download on this site, as well.
Mark