tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/request BaseInterceptor.java
Date Sat, 12 Feb 2000 03:38:51 GMT
costin      00/02/11 19:38:51

  Modified:    src/j2ee/org/apache/tomcat/context WarWebXmlInterceptor.java
                        WebXmlInterceptor.java
               src/j2ee/org/apache/tomcat/core InterceptorAdapter.java
               src/j2ee/org/apache/tomcat/shell Startup.java
               src/share/org/apache/tomcat/context AutoSetup.java
                        DefaultCMSetter.java LoadOnStartupInterceptor.java
                        WebXmlReader.java WorkDirInterceptor.java
               src/share/org/apache/tomcat/core Context.java
                        ContextInterceptor.java ContextManager.java
                        RequestInterceptor.java ServletWrapper.java
  Added:       src/share/org/apache/tomcat/core BaseInterceptor.java
  Removed:     src/share/org/apache/tomcat/context
                        BaseContextInterceptor.java
               src/share/org/apache/tomcat/request BaseInterceptor.java
  Log:
  Interface change for ContextInterceptor: all methods are void instead of int,
  and throw TomcatException.
  
  RequestInterceptor still return int and doesn't throw Exceptions.
  1. performance - exception is expensive.
  2. request interceptors are supposed to be fast and do minimal operations,
  3. It's hard to define what is Exception - for example "request is not
  authorized" is a normal HTTP state, and happen the first time you access
  a protected resource - it can't generate an exception. Wrong method or
  strange URI are also normal HTTP cases, not exceptions.
  
  Revision  Changes    Path
  1.2       +3 -4      jakarta-tomcat/src/j2ee/org/apache/tomcat/context/WarWebXmlInterceptor.java
  
  Index: WarWebXmlInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/j2ee/org/apache/tomcat/context/WarWebXmlInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WarWebXmlInterceptor.java	2000/02/11 00:22:24	1.1
  +++ WarWebXmlInterceptor.java	2000/02/12 03:38:48	1.2
  @@ -77,15 +77,15 @@
    *
    * @author costin@dnt.ro
    */
  -public class WarWebXmlInterceptor extends BaseContextInterceptor implements ContextInterceptor
{
  +public class WarWebXmlInterceptor extends BaseInterceptor implements ContextInterceptor
{
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
       
       public WarWebXmlInterceptor() {
       }
   	
  -    public int contextInit(Context ctx) {
  +    public void contextInit(Context ctx) {
   	if (! ctx.getDocumentBase().getProtocol().equalsIgnoreCase("war")) {
  -	    return 0;
  +	    return ;
   	}
   	
   	// process base configuration
  @@ -112,6 +112,5 @@
   	    String msg = sm.getString("context.getConfig.e",
   				      ctx.getPath() + " " + ctx.getDocBase() );
   	}
  -	return 0;
       }
   }
  
  
  
  1.2       +2 -3      jakarta-tomcat/src/j2ee/org/apache/tomcat/context/WebXmlInterceptor.java
  
  Index: WebXmlInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/j2ee/org/apache/tomcat/context/WebXmlInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebXmlInterceptor.java	2000/02/11 00:22:24	1.1
  +++ WebXmlInterceptor.java	2000/02/12 03:38:48	1.2
  @@ -75,13 +75,13 @@
    *
    * @author costin@dnt.ro
    */
  -public class WebXmlInterceptor extends BaseContextInterceptor  implements ContextInterceptor
{
  +public class WebXmlInterceptor extends BaseInterceptor  implements ContextInterceptor {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
       
       public WebXmlInterceptor() {
       }
   	
  -    public int contextInit(Context ctx) {
  +    public void contextInit(Context ctx) {
   	//	System.out.println("Context(" + ctx.getPath() + "): " + ctx.getDocBase());
   	    
   	// process base configuration
  @@ -98,7 +98,6 @@
   	    System.out.println(msg);
   	    e.printStackTrace();
   	}
  -	return 0;
       }
       
   }
  
  
  
  1.2       +18 -14    jakarta-tomcat/src/j2ee/org/apache/tomcat/core/InterceptorAdapter.java
  
  Index: InterceptorAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/j2ee/org/apache/tomcat/core/InterceptorAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InterceptorAdapter.java	2000/02/11 00:22:25	1.1
  +++ InterceptorAdapter.java	2000/02/12 03:38:48	1.2
  @@ -126,34 +126,36 @@
       
   }
   
  -class InitInterceptorAdapter extends BaseContextInterceptor implements ContextInterceptor
{
  +class InitInterceptorAdapter extends BaseInterceptor implements ContextInterceptor {
       LifecycleInterceptor interceptor;
       
       InitInterceptorAdapter( LifecycleInterceptor interceptor) {
   	this.interceptor=interceptor;
       }
   
  -    public int preServletInit(Context ctx, ServletWrapper sw ) {
  +    public void preServletInit(Context ctx, ServletWrapper sw )
  +	throws TomcatException
  +    {
   	try {
   	    interceptor.preInvoke( ctx, sw.getServlet());
  -	    return 0;
   	} catch( InterceptorException ex ) {
  -	    return -1; // map exceptions to error codes
  +	    throw new TomcatException( ex );
   	}
       }
   
  -    public int postServletInit(Context ctx, ServletWrapper sw ) {
  +    public void postServletInit(Context ctx, ServletWrapper sw )
  +    	throws TomcatException
  +    {
   	try {
   	    interceptor.postInvoke( ctx, sw.getServlet());
  -	    return 0;
   	} catch( InterceptorException ex ) {
  -	    return -1; // map exceptions to error codes
  +	    throw new TomcatException( ex );
   	}
       }
       
   }
   
  -class DestroyInterceptorAdapter extends BaseContextInterceptor implements ContextInterceptor
{
  +class DestroyInterceptorAdapter extends BaseInterceptor implements ContextInterceptor {
       LifecycleInterceptor interceptor;
       
       DestroyInterceptorAdapter( LifecycleInterceptor interceptor) {
  @@ -161,21 +163,23 @@
       }
   
   
  -    public int preServletDestroy(Context ctx, ServletWrapper sw ) {
  +    public void preServletDestroy(Context ctx, ServletWrapper sw )
  +    	throws TomcatException
  +    {
   	try {
   	    interceptor.preInvoke( ctx, sw.getServlet());
  -	    return 0;
   	} catch( InterceptorException ex ) {
  -	    return -1; // map exceptions to error codes
  +	    throw new TomcatException( ex );
   	}
       }
   
  -    public int postServletDestroy(Context ctx, ServletWrapper sw ) {
  +    public void postServletDestroy(Context ctx, ServletWrapper sw )
  +    	throws TomcatException
  +    {
   	try {
   	    interceptor.postInvoke( ctx, sw.getServlet());
  -	    return 0;
   	} catch( InterceptorException ex ) {
  -	    return -1; // map exceptions to error codes
  +	    throw new TomcatException( ex );
   	}
       }
   
  
  
  
  1.2       +5 -1      jakarta-tomcat/src/j2ee/org/apache/tomcat/shell/Startup.java
  
  Index: Startup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/j2ee/org/apache/tomcat/shell/Startup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Startup.java	2000/02/11 00:22:37	1.1
  +++ Startup.java	2000/02/12 03:38:48	1.2
  @@ -134,7 +134,11 @@
   		context.setPath(contextConfig.getPath());
   		context.setDocumentBase(contextConfig.getDocumentBase());
   
  -                contextManager.addContext(context);
  +		try {
  +		    contextManager.addContext(context);
  +		} catch(TomcatException ex ) {
  +		    ex.printStackTrace();
  +		}
   
   		context.setSessionTimeOut(
   		    contextConfig.getDefaultSessionTimeOut());
  
  
  
  1.5       +3 -5      jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java
  
  Index: AutoSetup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AutoSetup.java	2000/02/11 02:21:46	1.4
  +++ AutoSetup.java	2000/02/12 03:38:49	1.5
  @@ -78,16 +78,16 @@
    * 
    * @author costin@dnt.ro
    */
  -public class AutoSetup { //  implements TomcatHandler
  +public class AutoSetup extends BaseInterceptor {
   
       public AutoSetup() {
       }
   	
  -    public int engineInit(ContextManager cm) {
  +    public void engineInit(ContextManager cm) throws TomcatException {
   	String home=cm.getHome();
   	File webappD=new File(home + "/webapps");
   	if (! webappD.exists() || ! webappD.isDirectory())
  -	    return 0; // nothing to set up
  +	    return ; // nothing to set up
   
   	String[] list = webappD.list();
   	for (int i = 0; i < list.length; i++) {
  @@ -143,7 +143,5 @@
   
   		
   	}
  -
  -	return 0;
       }
   }
  
  
  
  1.10      +6 -11     jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
  
  Index: DefaultCMSetter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultCMSetter.java	2000/02/11 02:21:46	1.9
  +++ DefaultCMSetter.java	2000/02/12 03:38:49	1.10
  @@ -74,12 +74,12 @@
    *
    * @author costin@dnt.ro
    */
  -public class DefaultCMSetter extends BaseContextInterceptor {
  +public class DefaultCMSetter extends BaseInterceptor {
   
       public DefaultCMSetter() {
       }
   	
  -    public int engineInit(ContextManager cm)  {
  +    public void engineInit(ContextManager cm)  {
   	// set a default connector ( http ) if none defined yet
   	Enumeration conn=cm.getConnectors();
   	if( ! conn.hasMoreElements() ) {
  @@ -99,8 +99,6 @@
   
   	    cm.addRequestInterceptor(new SessionInterceptor());
   	}
  -
  -	return 0;
       }
   
       /** Called when a new context is added to the server.
  @@ -111,7 +109,7 @@
        *
        *  - Set up defaults for context interceptors and session if nothing is set
        */
  -    public int addContext(ContextManager cm, Context ctx) {
  +    public void addContext(ContextManager cm, Context ctx) {
   	// Make sure context knows about its manager.
   	ctx.setContextManager( cm );
   	setEngineHeader( ctx );
  @@ -137,14 +135,11 @@
   	    
   	    // load initial servlets
   	    ctx.addContextInterceptor(new LoadOnStartupInterceptor());
  -	}
  -	
  +	}	
   	// XXX Loader properties - need to be set on loader!!
  -	ctx.setServletLoader( new org.apache.tomcat.loader.ServletClassLoaderImpl());
  -	//	    ctx.setServletLoader( new org.apache.tomcat.loader.AdaptiveServletLoader());
  +	//ctx.setServletLoader( new org.apache.tomcat.loader.ServletClassLoaderImpl());
  +	ctx.setServletLoader( new org.apache.tomcat.loader.AdaptiveServletLoader());
   	initURLs( ctx );
  -
  -	return 0;
       }
   
       private void initURLs(Context context) {
  
  
  
  1.6       +2 -3      jakarta-tomcat/src/share/org/apache/tomcat/context/LoadOnStartupInterceptor.java
  
  Index: LoadOnStartupInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/LoadOnStartupInterceptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LoadOnStartupInterceptor.java	2000/02/11 02:21:46	1.5
  +++ LoadOnStartupInterceptor.java	2000/02/12 03:38:49	1.6
  @@ -75,7 +75,7 @@
    *
    * @author costin@dnt.ro
    */
  -public class LoadOnStartupInterceptor extends BaseContextInterceptor  implements ContextInterceptor
{
  +public class LoadOnStartupInterceptor extends BaseInterceptor {
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.context");
       int debug=0;
       
  @@ -86,7 +86,7 @@
   	debug=i;
       }
       
  -    public int contextInit(Context ctx) {
  +    public void contextInit(Context ctx) {
   	init(ctx);
   	Vector orderedKeys = new Vector();
   	Enumeration e=getInitLevels();
  @@ -143,7 +143,6 @@
   		}
   	    }
   	}
  -	return OK;
       }
   
       void loadJsp( Context context, ServletWrapper result ) throws Exception {
  
  
  
  1.6       +2 -3      jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java
  
  Index: WebXmlReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WebXmlReader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebXmlReader.java	2000/02/11 19:23:46	1.5
  +++ WebXmlReader.java	2000/02/12 03:38:49	1.6
  @@ -18,14 +18,14 @@
   /**
    * @author costin@dnt.ro
    */
  -public class WebXmlReader extends BaseContextInterceptor  implements ContextInterceptor
{
  +public class WebXmlReader extends BaseInterceptor {
   
       private static StringManager sm =StringManager.getManager("org.apache.tomcat.core");
       
       public WebXmlReader() {
       }
   
  -    public int contextInit(Context ctx) {
  +    public void contextInit(Context ctx) {
   	//	System.out.println("Context(" + ctx.getPath() + "): " + ctx.getDocBase());
   
   	// read default web.xml
  @@ -37,7 +37,6 @@
   	    String msg = sm.getString("context.getConfig.e",ctx.getPath() + " " + ctx.getDocBase());
   	    System.out.println(msg);
   	}
  -	return 0;
   
       }
   
  
  
  
  1.5       +3 -5      jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java
  
  Index: WorkDirInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/WorkDirInterceptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WorkDirInterceptor.java	2000/02/11 02:21:46	1.4
  +++ WorkDirInterceptor.java	2000/02/12 03:38:49	1.5
  @@ -74,12 +74,12 @@
    *
    * @author costin@dnt.ro
    */
  -public class WorkDirInterceptor extends BaseContextInterceptor  implements ContextInterceptor
{
  +public class WorkDirInterceptor extends BaseInterceptor {
   
       public WorkDirInterceptor() {
       }
   	
  -    public int contextInit(Context ctx) {
  +    public void contextInit(Context ctx) {
   	// never null !! ( it is set by default to ./work ! )
   	//log	System.out.println("Preparing work dir " + ctx.getWorkDir() );
   
  @@ -94,15 +94,13 @@
   
   	ctx.setAttribute(Constants.ATTRIB_WORKDIR1, ctx.getWorkDir());
   	ctx.setAttribute(Constants.ATTRIB_WORKDIR , ctx.getWorkDir());
  -	return 0;
       }
   
  -    public int contextShutdown( Context ctx ) {
  +    public void contextShutdown( Context ctx ) {
   	
   	if (! ctx.isWorkDirPersistent()) {
               clearDir(ctx.getWorkDir());
   	}
  -	return 0;
       }
   
       private void clearDir(File dir) {
  
  
  
  1.50      +4 -4      jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- Context.java	2000/02/11 19:23:46	1.49
  +++ Context.java	2000/02/12 03:38:50	1.50
  @@ -439,7 +439,7 @@
        * <p>This method may only be called once and must be called
        * before any requests are handled by this context.
        */
  -    public synchronized void init() {
  +    public synchronized void init() throws TomcatException {
   	if (this.initialized) {
   	    String msg = sm.getString("context.init.alreadyinit");
   	    throw new IllegalStateException(msg);
  @@ -503,7 +503,7 @@
   	sessionManager= manager;
       }
       
  -    public void shutdown() {
  +    public void shutdown() throws TomcatException {
   	// shut down container
   	initialized=false;
   	Enumeration enum = servlets.keys();
  @@ -720,8 +720,8 @@
       public void setLoginConfig( String authMethod, String realmName,
   				String formLoginPage, String formErrorPage)
       {
  -	System.out.println("Login config: " + authMethod + " " + realmName + " " +
  -			   formLoginPage + " " + formErrorPage);
  +	// 	System.out.println("Login config: " + authMethod + " " + realmName + " " +
  +	// 			   formLoginPage + " " + formErrorPage);
   	this.authMethod=authMethod;
   	this.realmName=realmName;
   	this.formLoginPage=formLoginPage;
  
  
  
  1.6       +18 -20    jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java
  
  Index: ContextInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContextInterceptor.java	2000/02/10 22:28:22	1.5
  +++ ContextInterceptor.java	2000/02/12 03:38:50	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v
1.5 2000/02/10 22:28:22 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/02/10 22:28:22 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v
1.6 2000/02/12 03:38:50 costin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/02/12 03:38:50 $
    *
    * ====================================================================
    *
  @@ -74,60 +74,58 @@
    * @author costin@dnt.ro
    */
   public interface ContextInterceptor {
  -    public static final int OK=0;
   
       /** Called when the ContextManger is started
        */
  -    public int engineInit(ContextManager cm);
  -
  +    public void engineInit(ContextManager cm) throws TomcatException;
  +    
       /** Called before the ContextManager is stoped.
        *  You need to stop any threads and remove any resources.
        */
  -    public int engineShutdown(ContextManager cm);
  +    public void engineShutdown(ContextManager cm) throws TomcatException;
   
       /** Called when a context is added to a CM
        */
  -    public int addContext( ContextManager cm, Context ctx );
  +    public void addContext( ContextManager cm, Context ctx ) throws TomcatException;
   
       /** Called when a context is removed from a CM
        */
  -    public int removeContext( ContextManager cm, Context ctx );
  +    public void removeContext( ContextManager cm, Context ctx ) throws TomcatException;
   
       /** Notification when a context is initialized
        */
  -    public int contextInit(Context ctx);
  +    public void contextInit(Context ctx) throws TomcatException;
   
       /** Called when a context is stoped.
        */
  -    public int contextShutdown(Context ctx);
  -
  +    public void contextShutdown(Context ctx) throws TomcatException;
       
       /** Notify when a new servlet is added
        */
  -    public int addServlet( Context ctx, ServletWrapper sw);
  +    public void addServlet( Context ctx, ServletWrapper sw) throws TomcatException;
   
       /** Notify when a servlet is removed from context
        */
  -    public int removeServlet( Context ctx, ServletWrapper sw);
  +    public void removeServlet( Context ctx, ServletWrapper sw) throws TomcatException;
   
       /** Notify when a mapping is added to a context
        */
  -    public int addMapping( Context ctx, String path, ServletWrapper servlet);
  +    public void addMapping( Context ctx, String path, ServletWrapper servlet) throws TomcatException;
   
       /** Notify when a mapping is deleted  from  a context
        */
  -    public int removeMapping( Context ctx, String path );
  +    public void removeMapping( Context ctx, String path ) throws TomcatException;
   
       /** Servlet Init  notification
        */
  -    public int preServletInit( Context ctx, ServletWrapper sw );
  +    public void preServletInit( Context ctx, ServletWrapper sw ) throws TomcatException;
       
  -    public int postServletInit( Context ctx, ServletWrapper sw );
  +    public void postServletInit( Context ctx, ServletWrapper sw ) throws TomcatException;
   
   
       /** Servlet Destroy  notification
        */
  -    public int preServletDestroy( Context ctx, ServletWrapper sw );
  +    public void preServletDestroy( Context ctx, ServletWrapper sw ) throws TomcatException;
       
  -    public int postServletDestroy( Context ctx, ServletWrapper sw );
  +    public void postServletDestroy( Context ctx, ServletWrapper sw ) throws TomcatException;
   }
  
  
  
  1.36      +7 -2      jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ContextManager.java	2000/02/09 20:36:10	1.35
  +++ ContextManager.java	2000/02/12 03:38:50	1.36
  @@ -212,11 +212,12 @@
        *
        * @param ctx context to be added.
        */
  -    public void addContext( Context ctx ) {
  +    public void addContext( Context ctx ) throws TomcatException {
   	// it will replace existing context - it's better than 
   	// IllegalStateException.
   	String path=ctx.getPath();
   	if( getContext( path ) != null ) {
  +	    log("Warning: replacing context for " + path);
   	    removeContext(path);
   	}
   
  @@ -233,7 +234,7 @@
        *
        * @param name Name of the Context to be removed
        */
  -    public void removeContext(String name) {
  +    public void removeContext(String name) throws TomcatException {
   	if (name.equals("")){
   	    throw new IllegalArgumentException(name);
   	}
  @@ -462,6 +463,10 @@
   
       // -------------------- Utils --------------------
       // Debug ( to be replaced with the real thing )
  +    public void setDebug( String  level ) {
  +	setDebug( new Integer( level).intValue());
  +    }
  +    
       public void setDebug( int level ) {
   	log( "Setting debug " + level );
   	debug=level;
  
  
  
  1.6       +3 -5      jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java
  
  Index: RequestInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RequestInterceptor.java	2000/02/03 23:41:29	1.5
  +++ RequestInterceptor.java	2000/02/12 03:38:50	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v
1.5 2000/02/03 23:41:29 costin Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/02/03 23:41:29 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestInterceptor.java,v
1.6 2000/02/12 03:38:50 costin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/02/12 03:38:50 $
    *
    * ====================================================================
    *
  @@ -78,8 +78,6 @@
        *  in notification.
        */
       public Enumeration getMethods();
  -
  -
       
       /** Will detect the context path for a request.
        *  It need to set: context, contextPath, lookupPath
  
  
  
  1.22      +26 -7     jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ServletWrapper.java	2000/02/10 23:49:57	1.21
  +++ ServletWrapper.java	2000/02/12 03:38:50	1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
1.21 2000/02/10 23:49:57 costin Exp $
  - * $Revision: 1.21 $
  - * $Date: 2000/02/10 23:49:57 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
1.22 2000/02/12 03:38:50 costin Exp $
  + * $Revision: 1.22 $
  + * $Date: 2000/02/12 03:38:50 $
    *
    * ====================================================================
    *
  @@ -468,14 +468,23 @@
   	// 	}
   	ContextInterceptor cI[]=context.getContextInterceptors();
   	for( int i=0; i<cI.length; i++ ) {
  -	    cI[i].preServletInit( context, this ); // ignore the error - like in the original
code
  +	    try {
  +		cI[i].preServletInit( context, this ); // ignore the error - like in the original code
  +	    } catch( TomcatException ex) {
  +		ex.printStackTrace();
  +	    }
   	}
   	servlet.init(servletConfig);
   	// if an exception is thrown in init, no end interceptors will be called.
   	// that was in the origianl code
   
   	for( int i=cI.length-1; i>=0; i-- ) {
  -	    cI[i].postServletInit( context, this ); // ignore the error - like in the original
code
  +	    try {
  +		cI[i].postServletInit( context, this ); // ignore the error - like in the original code
  +	    } catch( TomcatException ex) {
  +		ex.printStackTrace();
  +	    }
  +
   	}
   	// 	for( int i=v.size()-1; i>=0 ; i-- ) {
   	// 	    try { 
  @@ -502,11 +511,21 @@
   	// 	}
   	ContextInterceptor cI[]=context.getContextInterceptors();
   	for( int i=0; i<cI.length; i++ ) {
  -	    cI[i].preServletDestroy( context, this ); // ignore the error - like in the original
code
  +	    try {
  +		cI[i].preServletDestroy( context, this ); // ignore the error - like in the original
code
  +	    } catch( TomcatException ex) {
  +		ex.printStackTrace();
  +	    }
  +
   	}
   	servlet.destroy();
   	for( int i=cI.length-1; i>=0; i-- ) {
  -	    cI[i].postServletDestroy( context, this ); // ignore the error - like in the original
code
  +	    try {
  +		cI[i].postServletDestroy( context, this ); // ignore the error - like in the original
code
  +	    } catch( TomcatException ex) {
  +		ex.printStackTrace();
  +	    }
  +
   	}
   	// if an exception is thrown in init, no end interceptors will be called.
   	// that was in the origianl code
  
  
  
  1.1                  jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat.core;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.*;
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import javax.servlet.http.*;
  
  /**
   */
  public class BaseInterceptor implements RequestInterceptor, ContextInterceptor {
      
      protected Vector methods=new Vector();
      
      public BaseInterceptor() {
      }
  
      // -------------------- Request notifications --------------------
      public int requestMap(Request request ) {
  	return 0;
      }
  
      public int contextMap( Request rrequest ) {
  	return 0;
      }
  
      public int preService(Request request, Response response) {
  	return 0;
      }
  
      public int beforeBody( Request rrequest, Response response ) {
  	return 0;
      }
  
      public int beforeCommit( Request request, Response response) {
  	return 0;
      }
  
  
      public int afterBody( Request request, Response response) {
  	return 0;
      }
  
      public int postService(Request request, Response response) {
  	return 0;
      }
  
      public Enumeration getMethods()  {
  	return methods.elements();
      }
  
      // -------------------- Context notifications --------------------
      public void contextInit(Context ctx) throws TomcatException {
      }
  
      public void contextShutdown(Context ctx) throws TomcatException {
      }
  
      /** Notify when a new servlet is added
       */
      public void addServlet( Context ctx, ServletWrapper sw) throws TomcatException {
      }
      
      /** Notify when a servlet is removed from context
       */
      public void removeServlet( Context ctx, ServletWrapper sw) throws TomcatException {
      }
  
      public void addMapping( Context ctx, String path, ServletWrapper servlet) throws TomcatException
{
      }
  
  
      public void removeMapping( Context ctx, String path ) throws TomcatException {
      }
  
      /** Called when the ContextManger is started
       */
      public void engineInit(ContextManager cm) throws TomcatException {
      }
  
      /** Called before the ContextManager is stoped.
       *  You need to stop any threads and remove any resources.
       */
      public void engineShutdown(ContextManager cm) throws TomcatException {
      }
  
  
      /** Called when a context is added to a CM
       */
      public void addContext( ContextManager cm, Context ctx ) throws TomcatException {
      }
  
      /** Called when a context is removed from a CM
       */
      public void removeContext( ContextManager cm, Context ctx ) throws TomcatException {
      }
  
      /** Servlet Init  notification
       */
      public void preServletInit( Context ctx, ServletWrapper sw ) throws TomcatException
{
      }
  
      
      public void postServletInit( Context ctx, ServletWrapper sw ) throws TomcatException
{
      }
  
      /** Servlet Destroy  notification
       */
      public void preServletDestroy( Context ctx, ServletWrapper sw ) throws TomcatException
{
      }
  
      
      public void postServletDestroy( Context ctx, ServletWrapper sw ) throws TomcatException
{
      }
  
  }
  
  
  

Mime
View raw message