aspose file tools*
The moose likes Beginning Java and the fly likes Callback methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Callback methods" Watch "Callback methods" New topic
Author

Callback methods

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
Hi,

Whats the difference between callback methods and methods?

Regards
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Callback methods are methods. So, it makes no sense to speak of a difference between them.

A callback method is an ordinary Java method. The only thing special about them is how you intend them to be used. You can't enforce that a method is only used for callbacks.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
but what exactly does it mean when someone writes..

"callback methods such as .."

They could as well write it as

methods...

Whats the special significance.....?
Pratibha Malhotra
Ranch Hand

Joined: Dec 21, 2003
Posts: 199
Callback is comman mechanism in C.

It is used to pass a object to a method as an argument. Method inturn can invoke other methods associated with the Object passed to it as an argument.

Callback technique is essentialy used in scenarios where user wants to
invoke different methods without leeting client know which method of which class is being invoked.

Java use interfaces for callbacks mechanism. In this case, a method holds an interface reference in its argument list and then invokes a method in the interface.

java.io.Serializable Interface is one such example from Java API.


Now the million dollar Question - Why on this Planet do we want a callback?
When we pass a parameter, method being invoked gets the information (ie parameter value etc). What is returned is a result primitive or Object which provides only meager flow of info. Callback mechanism however allows a two-way communication channel between caller and callee.

Visitor Pattern is a classic example to demonstrate how Callback technique should ideally be used

HTH
[ September 28, 2006: Message edited by: Pratibha Malhotra ]

~ Pratibha Malhotra<br /> <br />Sun Certified Java Programmer<br />SCEA 1.4 (In Progress)<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />"Many of life's failures are people who did not realize how close they were to success when they gave up!!"
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
Thanks Pratibha!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Callback methods
 
Similar Threads
callback implementation
callback and lifecycle methods
Container callback and inline methods
callback methods
Ajax callback methds