This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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..??
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.
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).