tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java
Date Thu, 19 Jul 2001 05:55:30 GMT
costin      01/07/18 22:55:30

  Modified:    src/share/org/apache/tomcat/core ContextManager.java
  Log:
  Load trusted apps first.
  
  Revision  Changes    Path
  1.184     +56 -21    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.183
  retrieving revision 1.184
  diff -u -r1.183 -r1.184
  --- ContextManager.java	2001/07/13 06:04:30	1.183
  +++ ContextManager.java	2001/07/19 05:55:30	1.184
  @@ -544,44 +544,79 @@
   
   	// deal with contexts that were added before init()
   	// ( by user or modules during engineInit )
  +
  +	// first trusted apps - they may do special actions
   	Enumeration enum = getContexts();
   	while (enum.hasMoreElements()) {
   	    Context ctx = (Context)enum.nextElement();
  -	    ctx.setContextManager( this );
  -	    try {
  -		for( int i=0; i<existingI.length; i++ ) {
  -		    existingI[i].addContext( this, ctx );
  +	    if( ctx.isTrusted() )
  +		fireAddContext(ctx, existingI );
  +	}
  +	
  +	// Initialize the contexts
  +	enum = getContexts();
  +	while (enum.hasMoreElements()) {
  +	    Context ctx = (Context)enum.nextElement();
  +	    if( ctx.isTrusted() ) {
  +		try {
  +		    ctx.init();
  +		} catch( TomcatException ex ) {
  +		    // just log the error - the context will not serve requests
  +		    log( "Error initializing " + ctx , ex );
  +		    continue; 
   		}
  -	    } catch( TomcatException ex ) {
  -		log( "Error adding context " + ctx , ex );
  -		continue; 
  -	    }
  -	    try {
  -		// set state may throw exception
  -		ctx.setState( Context.STATE_ADDED );
  -		log("Adding  " +  ctx.toString());
  -	    } catch( TomcatException ex ) {
  -		log( "Error adding context " + ctx , ex );
  -		continue; 
   	    }
   	}
   
  +	// again - it may change
  +	existingI=defaultContainer.getInterceptors();
  +
  +	// Same thing for untrusted apps 
  +	enum = getContexts();
  +	while (enum.hasMoreElements()) {
  +	    Context ctx = (Context)enum.nextElement();
  +	    if( ! ctx.isTrusted() )
  +		fireAddContext(ctx, existingI );
  +	}
  +
   	// Initialize the contexts
   	enum = getContexts();
   	while (enum.hasMoreElements()) {
   	    Context ctx = (Context)enum.nextElement();
  -	    try {
  -		ctx.init();
  -	    } catch( TomcatException ex ) {
  -		// just log the error - the context will not serve requests
  -		log( "Error initializing " + ctx , ex );
  -		continue; 
  +	    if( ! ctx.isTrusted() ) {
  +		try {
  +		    ctx.init();
  +		} catch( TomcatException ex ) {
  +		    // just log the error - the context will not serve requests
  +		    log( "Error initializing " + ctx , ex );
  +		    continue; 
  +		}
   	    }
   	}
   
   	setState( STATE_INIT );
       }
   
  +    private void fireAddContext(Context ctx, BaseInterceptor existingI[] ) {
  +	ctx.setContextManager( this );
  +	try {
  +	    for( int i=0; i<existingI.length; i++ ) {
  +		existingI[i].addContext( this, ctx );
  +	    }
  +	} catch( TomcatException ex ) {
  +	    log( "Error adding context " + ctx , ex );
  +	    return; 
  +	}
  +	try {
  +	    // set state may throw exception
  +	    ctx.setState( Context.STATE_ADDED );
  +	    log("Adding  " +  ctx.toString());
  +	} catch( TomcatException ex ) {
  +	    log( "Error adding context " + ctx , ex );
  +	    return; 
  +	}
  +    }
  +    
       /** Will start the connectors and begin serving requests.
        *  It must be called after init.
        */
  
  
  

Mime
View raw message