Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes EJB & RMI CallBack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB & RMI CallBack" Watch "EJB & RMI CallBack" New topic
Author

EJB & RMI CallBack

Prem Kumar
Greenhorn

Joined: Jan 29, 2006
Posts: 14
Hi Friends,

I am wondering how call back happens in EJB.
I created an interface called CallBack.This extends Remote.
This contains a method update(String msg).

CallBack extends Remote {
void update(String msg) throws RemoteException;
}

Then to my ejb i pass this interface as shown below.
public void register(CallBack callback) {
try {
if(callback!=null) {
callback.update("Msg from Server");
}
}catch(RemoteException e){
e.printStackTrace();
}
}
I created a client which implements the CallBack interface and i called
the ejb's register method.Surprisingly i got a message from the server.
How does this work. Normally in RMI for the call back to work the client
should also expose itself as a RMI Server.This is usually done by
UnicastRemoteObject.exportObject(client);After this you use rmic to generate the stub and skeleton classes. For the EJB case i didnt export the client with exportObject nor i generated any stub and skeleton. How was the ejb able to call back the client in this scenario.Sorry for the long mail

Thanks


Have a Great Day!
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
I presume that its the 'RMIC' task's output. When an object is passed as a Parameter to EJB method, it must be either of serializable(externalizable) or Remote type.
If serializable, the picture is clear, the RMIC generates the stub for EJB methods for client's access.
If its Remote, then RMIC is taking the next step of generating the stub for this callback Remote object and give the stubs to EJB method.
When you do the RMIC, probably you can make the callback as serializable once and Remote once, then do RMIC and compare the generated stubs.
Prem Kumar
Greenhorn

Joined: Jan 29, 2006
Posts: 14
I found the issue.It was done by some classes in weblogic.jar.If you give
this jar to the classpath ,it automatically generates a stub for the remote object.So thats how the callback worked.it was using the stub generated by some classes in weblogic.jar.
Thiyagarajan Dakshinamurthy
Greenhorn

Joined: Mar 01, 2006
Posts: 1
Hi Prem,

Did you find out that this ejb->client callback is a documented feature in Weblogic? I cant find this documentation in edocs..??

thanks
tyago
 
GeeCON Prague 2014
 
subject: EJB & RMI CallBack