• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Container callback and inline methods

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are container callback and inline methods?
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..??
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still wonder, why is doFilter() a inline method?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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%
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic