Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Cookbook : Providing Callbacks via Interfaces

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, mr.ian, what do you means by "callback" in chapter9 - object-oriented techniques ? thank you !
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitions of Callback Method on the Web:

´┐ŻA method used to return the results of an asynchronous processing call. Typically, methods are called in a synchronous fashion, where the call does not return until the results (i.e., the output or return value) of the call are available. An asynchronous method call returns prior to the results, and then sometime later a callback method is called to return the actual results. The callback method itself contains program statements that are executed in response to the reception of the results. Also referred to as a callback function under the Win32 API. See Event.



A method that is implemented by application code and that is invoked by system code when needed to perform a specific function. Callback methods are never intended to be invoked directly by application code.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Examples are Java Swing Listener classes

http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html

Consider Key Listener class ehich listens for Key events. The implementation class will be registered with some UI component. When a key event occurs for e.g. when key is Pressed, keyPressed method in KeyListener class is called. The method keyPressed is the callback method.

Callback methods are the method which your code does not call but will be invoked by some other code. Hope this helps.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Examples are Java Swing Listener classes

http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html

Consider Key Listener class ehich listens for Key events. The implementation class will be registered with some UI component. When a key event occurs for e.g. when key is Pressed, keyPressed method in KeyListener class is called. The method keyPressed is the callback method.

Callback methods are the method which your code does not call but will be invoked by some other code. Hope this helps.


Great explanation, Pradeep... In addition to Swing listener classes, many servlet listener classes and servlet context listeners are also under the title of "callback"...

Just my 2 cents....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic