File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Call back and inline functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Call back and inline functions" Watch "Call back and inline functions" New topic
Author

Call back and inline functions

Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
Hi

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

Thanks


"Know where to find the solution and how to use it - that's the secret of success."
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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 ]

A good workman is known by his tools.
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

No, doFilter is a callback function called by the web container.


[My Blog]
All roads lead to JavaRanch
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
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 ]

SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Nov 14, 2005
Posts: 324
Greate explanation Satou
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call back and inline functions
 
Similar Threads
Does final method really improves performance
CallBack functions....
How to call a function located in another js file?
private methods
History issue and JavaScript