You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/04/21 20:36:08 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java Request.java

costin      01/04/21 11:36:08

  Modified:    src/share/org/apache/tomcat/core ContextManager.java
                        Request.java
  Log:
  Core changes !!!
  
  engineShutdown() hook is supposed to be called when tomcat is shut down ( and modules
  must clean up resources ). The interceptor can be added/removed at any time -
  it must clean after itself on removeInterceptor - but it shouldn't get a shutdown
  notification when it's removed ( since the server will still work ).
  
  Also, shutdown will no longer remove contexts - since init() didn't add them. Whoever
  adds the contexts ( i.e. config modules ) should also remove them - if they want -
  on server stop/restart. ( the context should be cleaned up on contextShutdown, but
  it may remain added - the server will report "application unavailable" instead of
  not found ).
  
  Also, shutdown will not remove interceptors - since it didn't add them.
  
  A init->start->stop->shutdown whould return to the same state as before init
  ( i.e. the configuration hardcoded in context manager like modules and settings
  must remain ).
  
  A shutdown->init should bring the server in ready state, and after start it should
  work as before.
  
  Revision  Changes    Path
  1.177     +33 -7     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.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- ContextManager.java	2001/04/07 06:50:55	1.176
  +++ ContextManager.java	2001/04/21 18:36:07	1.177
  @@ -482,7 +482,6 @@
   	    }
   	}
   
  -	ri.engineShutdown( this );
       }
   
       // -------------------- Server functions --------------------
  @@ -577,22 +576,49 @@
        */
       public final void shutdown() throws TomcatException {
           if( state==STATE_START ) stop();
  -	while (!contextsV.isEmpty()) {
  +
  +	Enumeration enum = getContexts();
  +	while (enum.hasMoreElements()) {
  +	    Context ctx = (Context)enum.nextElement();
   	    try {
  -		removeContext((Context)contextsV.firstElement());
  -	    } catch(Exception ex ) {
  -		log( "shutdown.removeContext" , ex );
  +		ctx.shutdown();
  +	    } catch( TomcatException ex ) {
  +		log( "Error shuting down context " +ctx );
   	    }
   	}
  +	// No need to remove - since init() doesn't add the contexts.
  +	// Modules could remove contexts ( and add them in init() ), but who
  +	// adds should also remove
  +	// 	while (!contextsV.isEmpty()) {
  +	// 	    try {
  +	// 		Context ctx=(Context)contextsV.firstElement();
  +	// 		removeContext(ctx);
  +	// 	    } catch(Exception ex ) {
  +	// 		log( "shutdown.removeContext" , ex );
  +	// 	    }
  +	// 	}
  +
  +	// Notify all modules that the server will shutdown,
  +	// let them clean up all resources
   
   	BaseInterceptor cI[]=defaultContainer.getInterceptors();
   	for( int i=0; i< cI.length; i++ ) {
   	    try {
  -		removeInterceptor( cI[i] );
  +		cI[i].engineShutdown( this );
   	    } catch( Exception ex ) {
  -		log( "shutdown.removeInterceptor" , ex );
  +		log( "shutdown.engineShutdown" , ex );
   	    }
   	}
  +
  +	setState( STATE_NEW );
  +	// remove the modules ( XXX do we need that ? )
  +	// 	for( int i=0; i< cI.length; i++ ) {
  +	// 	    try {
  +	// 		removeInterceptor( cI[i] );
  +	// 	    } catch( Exception ex ) {
  +	// 		log( "shutdown.removeInterceptor" , ex );
  +	// 	    }
  +	// 	}
       }
   
       // -------------------- Contexts --------------------
  
  
  
  1.100     +4 -0      jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- Request.java	2001/04/10 06:26:14	1.99
  +++ Request.java	2001/04/21 18:36:07	1.100
  @@ -298,6 +298,10 @@
   	return uriMB;
       }
   
  +    public MessageBytes query() {
  +	return queryMB;
  +    }
  +
       public MessageBytes queryString() {
   	return queryMB;
       }