• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call back methods ..what happens in background ?

 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all know that all servlet life cycle methods are callback , even in AJAX but i want to know what exactly happens in background ?
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Callback methods follows design principle "Don't call me I will call you back". Under the hood, generally these call back methods are declared in interface. We need to implement the interface and register the implementation. So whenever (in case of servlet) container call a particular callback method respective implementation will be called.
 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivendra tripathi wrote:Callback methods follows design principle "Don't call me I will call you back". Under the hood, generally these call back methods are declared in interface. We need to implement the interface and register the implementation. So whenever (in case of servlet) container call a particular callback method respective implementation will be called.


so is it some thing like thread wait and notify happening in background or what because i cant create a picture that how container waits for a callback it must be maintaining some kind of temporary thing like stack there....
 
shivendra tripathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Callback means you have done some implementation and want someone (in this case container) to call this when needed. Say, you have written MyServlet class which implements Servlet and you have registered MyServlet in web.xml corresponding to url pattern /MyServlet. Now your job is done. And when url with pattern /MyServlet will come to the server your implementation(say, doPost) will be called back by the server.
 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivendra tripathi wrote:Callback means you have done some implementation and want someone (in this case container) to call this when needed. Say, you have written MyServlet class which implements Servlet and you have registered MyServlet in web.xml corresponding to url pattern /MyServlet. Now your job is done. And when url with pattern /MyServlet will come to the server your implementation(say, doPost) will be called back by the server.


oops dear shivendra i uderstand this basic thing please see i want to know the background operation what happens in background not the meaning..... i have already written in my question...thanks in advance
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm not sure to what extent of 'what happens in the background' you are interested in. Hope I'm able to give a right start.

In short: Callback methods are methods that get executed as a result of life-cycle events.

The implementation is usually through implementation of Interfaces. To my understanding when an application is deployed on the server, the classes which act as listeners for the events get registered. Hence the server is aware of the listeners and the events for which they have registered for. So Later when these life-cycle events occur the server invokes the corresponding call-back method associated with the event.

Does this give you a vague idea of the concept?

Cheers,
Raj.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic