• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Callback Methods in EJB

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question.
What are callback methods and why are they named so?

Thanks,
Anganna
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic