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/core Container.java ContextManager.java
Date Sat, 30 Sep 2000 04:58:07 GMT
costin      00/09/29 21:58:07

  Modified:    src/facade22/org/apache/tomcat/facade ServletWrapper.java
               src/facade23/org/apache/tomcat/facade23 ServletWrapper.java
               src/share/org/apache/tomcat/core Container.java
                        ContextManager.java
  Log:
  Moved doPreServletInit/doPostServletInit and Destroy from
  contextmanager to ServletWrapper.
  
  There is no benefit in having it in ContextManager ( and same will happen
  with most doXXX methods), while having them in the code that actually
  needs it seems better.
  ( for example it's easier to understand when the hooks are called
  and what's the return convention - i.e. errors are ignored )
  
  It seems pre/postServletDestroy wasn't called when it should.
  
  Revision  Changes    Path
  1.7       +35 -5     jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletWrapper.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServletWrapper.java	2000/09/29 06:59:52	1.6
  +++ ServletWrapper.java	2000/09/30 04:57:51	1.7
  @@ -251,8 +251,25 @@
   	    }
   
   	    try {
  -		if( servlet!=null) 
  +		if( servlet!=null) {
  +		    BaseInterceptor cI[]=contextM.getContextInterceptors(context);
  +		    for( int i=0; i< cI.length; i++ ) {
  +			try {
  +			    cI[i].preServletDestroy( context, this );
  +			} catch( TomcatException ex) {
  +			    log("preServletDestroy", ex);
  +			}
  +		    }
   		    servlet.destroy();
  +
  +		    for( int i=0; i< cI.length; i++ ) {
  +			try {
  +			    cI[i].postServletDestroy( context, this );
  +			} catch( TomcatException ex) {
  +			    log("postServletDestroy", ex);
  +			}
  +		    }
  +		}
   	    } catch(Exception ex) {
   		// Should never come here...
   		log( "Error in destroy ", ex );
  @@ -304,15 +321,28 @@
   	//	} catch( InstantiationException ex ) {
   	//} catch( IllegalStateException ex ) {
   	//}
  -	
  +
   	// Call pre, doInit and post
  -	contextM.doPreServletInit( context, this);
  +	BaseInterceptor cI[]=contextM.getContextInterceptors(context);
  +	for( int i=0; i< cI.length; i++ ) {
  +	    try {
  +		cI[i].preServletInit( context, this );
  +	    } catch( TomcatException ex) {
  +		log("preServletInit" , ex);
  +	    }
  +	}
  +
   	doInit();
   	
   	// if an exception is thrown in init, no end interceptors will
   	// be called. that was in the origianl code J2EE used
  -	
  -	contextM.doPostServletInit( context, this);
  +	for( int i=0; i< cI.length; i++ ) {
  +	    try {
  +		cI[i].postServletInit( context, this );
  +	    } catch( TomcatException ex) {
  +		log("postServletInit" , ex);
  +	    }
  +	}
       }
   
       protected void doInit()
  
  
  
  1.5       +35 -5     jakarta-tomcat/src/facade23/org/apache/tomcat/facade23/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/facade23/org/apache/tomcat/facade23/ServletWrapper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServletWrapper.java	2000/09/29 06:59:57	1.4
  +++ ServletWrapper.java	2000/09/30 04:57:51	1.5
  @@ -248,8 +248,25 @@
   	    }
   
   	    try {
  -		if( servlet!=null) 
  +		if( servlet!=null) {
  +		    BaseInterceptor cI[]=contextM.getContextInterceptors(context);
  +		    for( int i=0; i< cI.length; i++ ) {
  +			try {
  +			    cI[i].preServletDestroy( context, this );
  +			} catch( TomcatException ex) {
  +			    log("preServletDestroy", ex);
  +			}
  +		    }
   		    servlet.destroy();
  +
  +		    for( int i=0; i< cI.length; i++ ) {
  +			try {
  +			    cI[i].postServletDestroy( context, this );
  +			} catch( TomcatException ex) {
  +			    log("postServletDestroy", ex);
  +			}
  +		    }
  +		}
   	    } catch(Exception ex) {
   		// Should never come here...
   		log( "Error in destroy ", ex );
  @@ -301,15 +318,28 @@
   	//	} catch( InstantiationException ex ) {
   	//} catch( IllegalStateException ex ) {
   	//}
  -	
  +
   	// Call pre, doInit and post
  -	contextM.doPreServletInit( context, this);
  +	BaseInterceptor cI[]=contextM.getContextInterceptors(context);
  +	for( int i=0; i< cI.length; i++ ) {
  +	    try {
  +		cI[i].preServletInit( context, this );
  +	    } catch( TomcatException ex) {
  +		log("preServletInit" , ex);
  +	    }
  +	}
  +
   	doInit();
   	
   	// if an exception is thrown in init, no end interceptors will
   	// be called. that was in the origianl code J2EE used
  -	
  -	contextM.doPostServletInit( context, this);
  +	for( int i=0; i< cI.length; i++ ) {
  +	    try {
  +		cI[i].postServletInit( context, this );
  +	    } catch( TomcatException ex) {
  +		log("postServletInit" , ex);
  +	    }
  +	}
       }
   
       protected void doInit()
  
  
  
  1.35      +18 -0     jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Container.java	2000/09/28 03:25:46	1.34
  +++ Container.java	2000/09/30 04:57:56	1.35
  @@ -372,6 +372,24 @@
   
       // -------------------- Interceptors --------------------
       public static final int MAX_HOOKS=20;
  +
  +    // Hook Ids - keep them in sync with PREDEFINED_I
  +    // ( static final for performance and to simplify code )
  +    // H_ is from "hook"
  +    
  +    public static final int H_requestMap=0;
  +    public static final int H_contextMap=1;
  +    public static final int H_authenticate=2;
  +    public static final int H_authorize=3;
  +    public static final int H_preService=4;
  +    public static final int H_beforeBody=5;
  +    public static final int H_newSessionRequest=6;
  +    public static final int H_beforeCommit=7;
  +    public static final int H_afterBody=8;
  +    public static final int H_postService=9;
  +    public static final int H_postRequest=10;
  +    public static final int H_engineInit=11;
  +
       public static final String PREDEFINED_I[]= {
   	"requestMap", "contextMap", "authenticate",
   	"authorize", "preService", "beforeBody",
  
  
  
  1.140     +0 -26     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.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- ContextManager.java	2000/09/30 04:43:29	1.139
  +++ ContextManager.java	2000/09/30 04:57:56	1.140
  @@ -1308,32 +1308,6 @@
   	removeContext( context);
       }
   
  -    public void doPreServletInit(Context ctx, Handler sw)
  -	throws TomcatException
  -    {
  -	BaseInterceptor cI[]=getContextInterceptors(ctx);
  -	for( int i=0; i< cI.length; i++ ) {
  -	    try {
  -		cI[i].preServletInit( ctx, sw );
  -	    } catch( TomcatException ex) {
  -		log("preServletInit" , ex);
  -	    }
  -	}
  -    }
  -
  -    public void doPostServletInit(Context ctx, Handler sw)
  -	throws TomcatException
  -    {
  -	BaseInterceptor cI[]=getContextInterceptors(ctx);
  -	for( int i=0; i< cI.length; i++ ) {
  -	    try {
  -		cI[i].postServletInit( ctx, sw );
  -	    } catch( TomcatException ex) {
  -		log("postServletInit", ex);
  -	    }
  -	}
  -    }
  -
       public void doPreServletDestroy(Context ctx, Handler sw)
   	throws TomcatException
       {
  
  
  

Mime
View raw message