File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB & RMI CallBack

 
Prem Kumar
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Babji Reddy
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic