File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Callback Methods in 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 » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Callback Methods in EJB" Watch "Callback Methods in EJB" New topic
Author

Callback Methods in EJB

Anganna Venkatesh
Greenhorn

Joined: Dec 07, 2005
Posts: 1
I have a question.
What are callback methods and why are they named so?

Thanks,
Anganna
Puneet Vashisht
Ranch Hand

Joined: Jul 30, 2005
Posts: 44
I have a question.
What are callback methods and why are they named so?

Thanks,
Anganna

Hi,
If u are talking of container callback methods, then these are the methods only container has the privelege to call, like ur ejbcreate().
As to y they are called callback methods, i dont even have a hint. The whole nomenclature used wid EJB is so confusing.
Thankz,
Puneet
SCJP1.4
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Callback methods are methods called by the container on the EJB to notify the EJB of important events in it's lifecycle such as creation, activation, passivation, removal etc. They are given a different name to distinguish them from normal business methods which are also actually invoked by the container on the EJB.

If you are from a WCD background, this might help - you can consider them to be similar to say, the contextInitialized(ServletContextEvent se) and contextDestroyed(ServletContextEvent se) methods of ServletContextListener. These are methods called by the web container on the listener class to notify the class of context-related events
Sankar Subbiramaniam
Ranch Hand

Joined: Oct 03, 2000
Posts: 116
In Client-Server applications, normally it is the client which (initiates the) call to the server for services (Client ---> Server). However there are situations where the server wants to notify the client of some event (eg: ejb lifecycle status change). In these situation the server initiates a call back to the client. (Client <----- Server)
Hence they are called callback methods.

Note: In EJB, a deployed bean is a client of the container.

Hope this helps.
Devender Thareja
Ranch Hand

Joined: Jul 14, 2005
Posts: 187
Originally posted by Sankar Subbiramaniam:

Note: In EJB, a deployed bean is a client of the container.

Hope this helps.


It's confusing. Sankar, I don't think it's right to say that bean is a client to container.

This is how I understand it so far: A bean is an object inside container. However, whatever business methods you call on a bean, you are really calling on a subclass of bean you wrote. The container adds more meat to the class you write and extends it. So in the grand scheme of things, container is controlling everything but in between at appropriate times, it calls methods which you wrote. This is already agreed upon in spec that what services container will provide and at what time and situation it will callback the bean methods. The agreed upon methods are container callback methods. You can also add methods which are not defined in the spec or in other words are not container callback methods but they will never be called by container and should be called from container callback methods you write, otherwise they will be use-less.
The container callback name seems to appropriate in this situation. Do you have more appropriate name in mind?


Devender Thareja
SCEA, SCBCD, SCJP
 
jQuery in Action, 2nd edition
 
subject: Callback Methods in EJB
 
Similar Threads
Ajax callback methds
callback implementation
callback methods
Container callback and inline methods
callback and lifecycle methods