Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Container Callback method doubt

Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What does it mean when it is stated "xxx method is always a container callback method" ?
eg: In case of filters,

The destroy method is always a container callback method; while doFilter is a callback and an inline method.

What do container callback and inline methods mean ?
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HeadFirst books:

container callback method = a method that is called from the container's code
inline method = a method you call from your code

For the doFilter method, it is both. This is because the doFilter method on the Filter class is a container callback but the doFilter method on the FilterChain class is an inline method. Tricky.
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we pass a method address to other thread,and let them to call our method,this method is a callback method,since in java,we can not pass method address,so we use interface,we pass a reference of real object of that interface(implement),other thread use the contract(interface) to call
method defined in our interface and implement in out real object.
about inline method,please see this(refered fome thinking in java):

The second reason for final methods is efficiency. If you make a method final, you are allowing the compiler to turn any calls to that method into inline calls. When the compiler sees a final method call, it can (at its discretion) skip the normal approach of inserting code to perform the method call mechanism (push arguments on the stack, hop over to the method code and execute it, hop back and clean off the stack arguments, and deal with the return value) and instead replace the method call with a copy of the actual code in the method body. This eliminates the overhead of the method call. Of course, if a method is big, then your code begins to bloat, and you probably won�t see any performance gains from inlining, since any improvements will be dwarfed by the amount of time spent inside the method. It is implied that the Java compiler is able to detect these situations and choose wisely whether to inline a final method. However, it�s best to let the compiler and JVM handle efficiency issues and make a method final only if you want to explicitly prevent overriding
hope it's help you
    Bookmark Topic Watch Topic
  • New Topic