This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
posted
0
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.
I still wonder, why is doFilter() a inline method?
David Chait
Greenhorn
Joined: May 10, 2004
Posts: 5
posted
0
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).