• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call back and inline functions

 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

What are container call back functions and the inline functions. What are difference in these two

Thanks
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Container callback methods are those that you write expecting that the container will call them. Inline methods, as you are calling them, I believe are methods that you call.

As an example, see in the Filter API that each of its 3 methods are called by the container - they are all container callback methods.
[ March 14, 2007: Message edited by: Marc Peabody ]
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an example, see in the Filter API that each of its 3 methods are called by the container - they are all container callback methods.


The doFilter() is a callback functiona as well as an inline function

Am I right
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The doFilter() is a callback functiona as well as an inline function

No, doFilter is a callback function called by the web container.
 
Aniket Patil
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pg 700, K&B mentions doFilter as both callback and an inline function. The reason could be is because apart from getting called by the container, the devloper himself could put in a call to doFilter(request,response) to call the next filter/servlet in chain.
[ March 14, 2007: Message edited by: Aniket Patil ]
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satou
I have seen a question about callback functions in filter API in Filters chapetr of HFSJ book. In the answer the destroy()is selected as callback function.
On other thing is that we call chain.doFilter() to invoke next filter in chain. Is this call not making doFilter() an inline method.

Anyone please confirm

Thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would call FilterChain.doFilter an "inline" function as it's being called, but not Filter.doFilter. I don't think that you ever call it directly.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be more specific when asking. If I'm correct, question is :
Q1: Which are true about filters?
C. The doFilter method is always a container callback method.

They don't specify which doFilter it is. Question is about filters, not the Filter class only.

Filter.doFilter is a container callback, but FilterChain.doFilter is an inline method. A dirty trick, which fortunately won't have at the exam
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greate explanation Satou
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic