org.apache.tomcat.core
Class BaseInterceptor

java.lang.Object
  |
  +--org.apache.tomcat.core.BaseInterceptor

public class BaseInterceptor
extends java.lang.Object
implements RequestInterceptor, ContextInterceptor


Field Summary
protected  ContextManager cm
           
protected  int debug
           
protected  java.lang.String[] methods
           
protected  java.lang.String name
           
 
Fields inherited from interface org.apache.tomcat.core.RequestInterceptor
OK
 
Constructor Summary
BaseInterceptor()
           
 
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 addSecurityConstraint(Context ctx, java.lang.String path, Container ct)
           
 int afterBody(Request request, Response response)
          Called after the output stream is closed ( either by servlet or automatically at end of service ).
 int authenticate(Request request, Response response)
          This callback is used to extract and verify the user identity and credentials.
 int authorize(Request request, Response response, java.lang.String[] reqRoles)
          Will check if the current ( authenticated ) user is authorized to access a resource, by checking if it have one of the required roles.
 int beforeBody(Request rrequest, Response response)
          Called before the first body write, and before sending the headers.
 int beforeCommit(Request request, Response response)
          Called before the output buffer is commited.
 void contextInit(Context ctx)
          Notify when a context is initialized.
 int contextMap(Request rrequest)
          Will detect the context path for a request.
 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.
 java.lang.String[] getMethods()
          Will return the methods fow which this interceptor is interested in notification.
protected  void log(java.lang.String s)
           
 int newSessionRequest(Request request, Response response)
          New Session notification - called when the servlet asks for a new session.
 int postService(Request request, Response response)
          Called after service method ends.
 void postServletDestroy(Context ctx, ServletWrapper sw)
           
 void postServletInit(Context ctx, ServletWrapper sw)
           
 int preService(Request request, Response response)
          Called before service method is invoked.
 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
 int requestMap(Request request)
          Handle mappings inside a context.
 void setContextManager(ContextManager cm)
           
 void setDebug(int d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cm

protected ContextManager cm

methods

protected java.lang.String[] methods

debug

protected int debug

name

protected java.lang.String name
Constructor Detail

BaseInterceptor

public BaseInterceptor()
Method Detail

setDebug

public void setDebug(int d)

setContextManager

public void setContextManager(ContextManager cm)

log

protected void log(java.lang.String s)

requestMap

public int requestMap(Request request)
Description copied from interface: RequestInterceptor
Handle mappings inside a context. You are required to respect the mappings in web.xml.
Specified by:
requestMap in interface RequestInterceptor

contextMap

public int contextMap(Request rrequest)
Description copied from interface: RequestInterceptor
Will detect the context path for a request. It need to set: context, contextPath, lookupPath A possible use for this would be a "user-home" interceptor that will implement ~costin servlets ( add and map them at run time).
Specified by:
contextMap in interface RequestInterceptor

authenticate

public int authenticate(Request request,
                        Response response)
Description copied from interface: RequestInterceptor
This callback is used to extract and verify the user identity and credentials. It will set the RemoteUser field if it can authenticate. The auth event is generated by a user asking for the remote user field of by tomcat if a request requires authenticated id.
Specified by:
authenticate in interface RequestInterceptor

authorize

public int authorize(Request request,
                     Response response,
                     java.lang.String[] reqRoles)
Description copied from interface: RequestInterceptor
Will check if the current ( authenticated ) user is authorized to access a resource, by checking if it have one of the required roles. This is used by tomcat to delegate the authorization to modules. The authorize is called by isUserInRole() and by ContextManager if the request have security constraints.
Specified by:
authorize in interface RequestInterceptor

preService

public int preService(Request request,
                      Response response)
Description copied from interface: RequestInterceptor
Called before service method is invoked.
Specified by:
preService in interface RequestInterceptor

beforeBody

public int beforeBody(Request rrequest,
                      Response response)
Description copied from interface: RequestInterceptor
Called before the first body write, and before sending the headers. The interceptor have a chance to change the output headers.
Specified by:
beforeBody in interface RequestInterceptor

newSessionRequest

public int newSessionRequest(Request request,
                             Response response)
Description copied from interface: RequestInterceptor
New Session notification - called when the servlet asks for a new session. You can do all kind of stuff with this notification - the most important is create a session object. This will be the base for controling the session allocation.
Specified by:
newSessionRequest in interface RequestInterceptor

beforeCommit

public int beforeCommit(Request request,
                        Response response)
Description copied from interface: RequestInterceptor
Called before the output buffer is commited.
Specified by:
beforeCommit in interface RequestInterceptor

afterBody

public int afterBody(Request request,
                     Response response)
Description copied from interface: RequestInterceptor
Called after the output stream is closed ( either by servlet or automatically at end of service ).
Specified by:
afterBody in interface RequestInterceptor

postService

public int postService(Request request,
                       Response response)
Description copied from interface: RequestInterceptor
Called after service method ends. Log is a particular use.
Specified by:
postService in interface RequestInterceptor

getMethods

public java.lang.String[] getMethods()
Description copied from interface: RequestInterceptor
Will return the methods fow which this interceptor is interested in notification. This will be used by ContextManager to call only the interceptors that are interested, avoiding empty calls. ( not implemented yet ).
Specified by:
getMethods in interface RequestInterceptor

contextInit

public void contextInit(Context ctx)
                 throws TomcatException
Description copied from interface: ContextInterceptor
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.
Specified by:
contextInit in interface ContextInterceptor

contextShutdown

public void contextShutdown(Context ctx)
                     throws TomcatException
Description copied from interface: ContextInterceptor
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)
Specified by:
contextShutdown in interface ContextInterceptor

addContainer

public void addContainer(Container container)
                  throws TomcatException
Description copied from interface: ContextInterceptor
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
Specified by:
addContainer in interface ContextInterceptor

removeContainer

public void removeContainer(Container container)
                     throws TomcatException
Description copied from interface: ContextInterceptor
A rule was removed, update the internal strucures. You can also clean up and reload everything using Context.getContainers()
Specified by:
removeContainer in interface ContextInterceptor

addSecurityConstraint

public void addSecurityConstraint(Context ctx,
                                  java.lang.String path,
                                  Container ct)
                           throws TomcatException

engineInit

public void engineInit(ContextManager cm)
                throws TomcatException
Called when the ContextManger is started
Specified by:
engineInit in interface ContextInterceptor

engineShutdown

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

addContext

public void addContext(ContextManager cm,
                       Context ctx)
                throws TomcatException
Called when a context is added to a CM
Specified by:
addContext in interface ContextInterceptor

removeContext

public void removeContext(ContextManager cm,
                          Context ctx)
                   throws TomcatException
Called when a context is removed from a CM
Specified by:
removeContext in interface ContextInterceptor

reload

public void reload(Request req,
                   Context ctx)
            throws TomcatException
Description copied from interface: ContextInterceptor
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.
Specified by:
reload in interface ContextInterceptor

preServletInit

public void preServletInit(Context ctx,
                           ServletWrapper sw)
                    throws TomcatException
Servlet Init notification
Specified by:
preServletInit in interface ContextInterceptor

postServletInit

public void postServletInit(Context ctx,
                            ServletWrapper sw)
                     throws TomcatException
Specified by:
postServletInit in interface ContextInterceptor

preServletDestroy

public void preServletDestroy(Context ctx,
                              ServletWrapper sw)
                       throws TomcatException
Servlet Destroy notification
Specified by:
preServletDestroy in interface ContextInterceptor

postServletDestroy

public void postServletDestroy(Context ctx,
                               ServletWrapper sw)
                        throws TomcatException
Specified by:
postServletDestroy in interface ContextInterceptor


Copyright © 2000 Apache Software Foundation. All Rights Reserved.