org.apache.tomcat.core
Interface ContextInterceptor

All Known Implementing Classes:
BaseInterceptor

public interface ContextInterceptor

Notifications for all context events. Example: expand WAR, move files in the right directories ( Apache ?), read web.xml or check for a serialized form for faster init, etc.

Author:
costin@dnt.ro

Method Summary
 void addContainer(Container container)
          A new location was added to the server.
 void addContext(ContextManager cm, Context ctx)
          Called when a context is added to a CM.
 void contextInit(Context ctx)
          Notify when a context is initialized.
 void contextShutdown(Context ctx)
          Called when a context is stoped, before removeContext.
 void engineInit(ContextManager cm)
          Called when the ContextManger is started.
 void engineShutdown(ContextManager cm)
          Called before the ContextManager is stoped.
 void postServletDestroy(Context ctx, ServletWrapper sw)
           
 void postServletInit(Context ctx, ServletWrapper sw)
           
 void preServletDestroy(Context ctx, ServletWrapper sw)
          Servlet Destroy notification
 void preServletInit(Context ctx, ServletWrapper sw)
          Servlet Init notification.
 void reload(Request req, Context ctx)
          Reload notification - called whenever a reload is done.
 void removeContainer(Container container)
          A rule was removed, update the internal strucures.
 void removeContext(ContextManager cm, Context ctx)
          Called when a context is removed from a CM.
 

Method Detail

engineInit

public void engineInit(ContextManager cm)
                throws TomcatException
Called when the ContextManger is started.

engineShutdown

public void engineShutdown(ContextManager cm)
                    throws TomcatException
Called before the ContextManager is stoped. You need to stop any threads and remove any resources.

addContext

public void addContext(ContextManager cm,
                       Context ctx)
                throws TomcatException
Called when a context is added to a CM. The context is probably not initialized yet, only path and docRoot are probably set. If you need informations that are available in web.xml use contextInit() ( a WebXmlReader needs to be the first interceptor in the contextInit chain ). We do that to support ( eventualy ) a "lazy" init, where you have many contexts, most of them not in active use, and you'll init them at first request. ( for example an ISP with many users )

contextInit

public void contextInit(Context ctx)
                 throws TomcatException
Notify when a context is initialized. The first interceptor in the chain for contextInit must read web.xml and set the context. When this method is called you can expect the context to be filled in with all the informations from web.xml.

reload

public void reload(Request req,
                   Context ctx)
            throws TomcatException
Reload notification - called whenever a reload is done. This can be used to serialize sessions, log the event, remove any resource that was class-loader dependent.

contextShutdown

public void contextShutdown(Context ctx)
                     throws TomcatException
Called when a context is stoped, before removeContext. You must free all resources. XXX - do we need this or removeContext is enough ?? ( will be removed from 3.1 if nobody asks for it)

removeContext

public void removeContext(ContextManager cm,
                          Context ctx)
                   throws TomcatException
Called when a context is removed from a CM. A context is removed either as a result of admin ( remove or update), to support "clean" servlet reloading or at shutdown.

addContainer

public void addContainer(Container container)
                  throws TomcatException
A new location was added to the server. A location is defined as a set of URL patterns with common properties. All servlet mappings and security constraints are in this category - with a common handler and a common set of authorized roles. An interceptor interested in mapping must implement this method and construct it's internal representation. The mapper is _required_ to find the Container associated with a request using the mapping rules defined in the Servlet API. The interceptor must also take care of "merging" parent with child containers. It is possible that this method will be called several times for the same url pattern ( for example to define a handler and then security constraints), the interceptor needs to merge the 2 containers. XXX define "merging" of containers

removeContainer

public void removeContainer(Container container)
                     throws TomcatException
A rule was removed, update the internal strucures. You can also clean up and reload everything using Context.getContainers()

preServletInit

public void preServletInit(Context ctx,
                           ServletWrapper sw)
                    throws TomcatException
Servlet Init notification. XXX do we need "pre/post" for init/destroy ? transactions?

postServletInit

public void postServletInit(Context ctx,
                            ServletWrapper sw)
                     throws TomcatException

preServletDestroy

public void preServletDestroy(Context ctx,
                              ServletWrapper sw)
                       throws TomcatException
Servlet Destroy notification

postServletDestroy

public void postServletDestroy(Context ctx,
                               ServletWrapper sw)
                        throws TomcatException


Copyright © 2000 Apache Software Foundation. All Rights Reserved.