File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Container callback and inline methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Container callback and inline methods" Watch "Container callback and inline methods" New topic

Container callback and inline methods

Roger Federer

Joined: Sep 14, 2004
Posts: 6
What are container callback and inline methods?
Sandya Bhaskara
Ranch Hand

Joined: Aug 20, 2004
Posts: 73
Generally java resolves calls to methods dynamically at run time..(late binding)..but for methods that cant be overridden a call can be resolved at compile time(example-final ,static methods)..the compiler copies the bytecode for subroutine directly inline with compiled code of the calling methods thus eliminating costly overhead associated with the method call...
This is INLINE call..

but i'm not sure what a callback is....and i did not understand why destroy() is callback method and doFilter()is both inline and callback..??

Sandy<br />SCJP1.4 SCWCD1.4<br />SCBCD(preparing)
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
A callback method is a method that somebody-else - in this case, the container - calls.
i.e. you write the method, but none of the code you write actually invokes that method. So how does the code you wrote ever run? Because having written, compiled deployed your code, the container calls you back (hence "callback") at the appropriate time and invokes your method.

So for methods like 'destroy', the container knows that when it starts shutting down, you may have resources that need freeing up, and it knows you may have a method called 'destroy', so it calls it. Hey presto, your 'callback' method runs.

Hope this helps.

Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
Onno Bleyenga

Joined: Jan 11, 2005
Posts: 4
I still wonder, why is doFilter() a inline method?
David Chait

Joined: May 10, 2004
Posts: 5
could someone please respond to this question (headfirst p700, chapter 13, q1).

specifically, why is doFilter an inline method and why does that mean it doesn't also act as a callback (ie, it could be both a callback and inline: the container calls the method, but the container's call is resolved at compile time).

thanks, david scjp 75%, scbcd 90%

David Chait<br />scjp 75%, scbcd 90%
It is sorta covered in the JavaRanch Style Guide.
subject: Container callback and inline methods
jQuery in Action, 3rd edition