tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tp...@borland.com (Thom Park)
Subject Re: Catalina vs.preServletInit et. al.
Date Fri, 23 Mar 2001 23:30:47 GMT
Hmm..

interesting - In my modification(s) I was setting some
thread-local objects which were then used by some objects
referred to in my servlet.

i.e. I was setting a naming-context such that it referred to the
naming context that was appropriate for my execution thread.

If I register an event-listener - can I be assured that it will
run in the same thread as that using the servlet-instance? - in
which case I home free.

If not, then one way to solve my problem would be to alter the
wrapper class and 'wrap' the points where the servlet init,
service and destroy method calls are invoked.

Not very pluggable though and involves a nasty hack of the
Catalina source.

Are there any other alternatives to this?

-Thom





>
>
>On Fri, 23 Mar 2001, T. Park wrote:
>
>> 
>> Hello,
>> 
>> I'm a newbie to the Catalina code line and need some guidance
(lots actually)...
>> 
>> I have a custom interceptor that works really well with
Tomcat 3.x that does
>> some special setup work
>> in the preServletInit/postServletInit, preService/postService
and
>> preServletDestroy/postServletDestroy methods of
>> the special RequestInterceptor.
>> 
>> My problem is determining functional equivalents to these in
Catalina.
>> 
>
>The model for customized request processing in Catalina is
quite a bit
>different than Tomcat 3.x.  Fundamentally, you use a Valve for
most
>processing.  Valves implement the "chain of responsibility"
pattern from
>the GoF book -- and once you understand them, you will also
understand how
>Filters work in the servlet 2.3 spec :-).  However, Valves
don't directly
>do what you're asking for here.
>
>The Context element supports the registration of
InstanceListener objects,
>which receive InstanceEvent notifications of the six events you
mentioned
>above, plus beforeFilter and afterFilter (2.3 specific).  This
follows the
>usual JavaBeans patterns for event notification.
>
>>From server.xml, you can configure instance listeners by
nesting a new
>element inside the <Context>
>
>	<Context path="/..." ...>
>		<InstanceListener className="com.mycompany.MyListener/>
>	</Context>
>
>> Can anyone give me any pointers - I sort of lost my way in
the source code and
>> documentation
>> (primarily due to existing references to 'interceptors' in
both comments and
>> docs.)
>> 
>> Is there still a way to do some pre/post processing for each
corresponding
>> servlet call (init,destroy and service).
>> 
>> I looked at VavleBase and couldn't see any direct
comparison.
>> 
>> -Thom
>> 
>> 
>> 
>> 
>
>Craig McClanahan
>
>



Mime
View raw message