Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Container callback and inline methods

 
Roger Federer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are container callback and inline methods?
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..??
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Onno Bleyenga
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still wonder, why is doFilter() a inline method?
 
David Chait
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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%
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic