Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between methods

 
raghu dubey
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Can you please tell me the difference between a callback mathod and a inline methods...Page 700...excplanation for Q1 in HFSJ

Thanks,
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A callback method, in the context of Web applications, is a method invoked by the container rather than by your own code. For example, you never invoke a servlet's service method yourself, instead the container does that for you when a client makes a request. In general, you'll write the callback method's implementation but never invoke it.

I imagine what's meant here by an "inline method" is one which you invoke directly in your own application's code: this may or may not be a method you have implemented yourself. For example, getServletConfig() is an "inline method" (I imagine). I may have that incorrect as I find it somewhat confusing terminology (for example, an invocation of an inline method in C++ is replaced by the expanded form of the method on compilation, a "feature" which doesn't exist in Java).

Not having a copy of HFSJ, it would have helped me (and others without the book) if you had quoted the relevant paragraph(s) - it would help to put your question in context.
 
raghu dubey
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question in the book says:

Which are true about filters:

1) The destroy method is always a container callback.
2) the doFilter method is always a container callback.
3) The only way a filter can be invoked is through a DD declaration.

and it said that the options 1 and 3 are correct. 2 is not correct because doFilter is both a container callback and inline method.

destroy is only called b y container, but doFilter can also be indirectly invoked using chain.doFilter() while we are doing a filter chaining. so it becomes an inline method as well.


Charles, I think I get that now from your explanation. The book explanation is "inline" with what you said.


Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic