Meaningless Drivel is fun!*
The moose likes EJB and other Java EE Technologies and the fly likes Call Back from EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Call Back from EJB" Watch "Call Back from EJB" New topic
Author

Call Back from EJB

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!
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You have described a regular EJB method. But callbacks are different because they are tied to the EJB's life cycle. Callbacks are invoked on the bean's instance by the container, eg setSessionContext of a session bean during the transition from its "does not exist" state to "method ready" state. Apart from a few exceptions such as ejbLoad and ejbStore of BMP entity beans, callbacks are never invoked by a bean or client.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call Back from EJB
 
Similar Threads
how to get Clients CPU information on Server using Java RMI
Query regarding Ejbs
How to Call ClientCallBacks from the Server
EJB & RMI CallBack
Handle query