tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers ReloadInterceptor.java
Date Wed, 21 Aug 2002 04:07:35 GMT
billbarker    2002/08/20 21:07:35

  Modified:    src/share/org/apache/tomcat/modules/mappers
                        ReloadInterceptor.java
  Log:
  Support for reloading session.
  
  Also synchronized reloading, to prevent a double-adding bug.
  Reported by: Hugh J.L. hughjlee@yahoo.com
  
  Revision  Changes    Path
  1.15      +61 -53    jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/ReloadInterceptor.java
  
  Index: ReloadInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/ReloadInterceptor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ReloadInterceptor.java	2 Oct 2001 05:50:30 -0000	1.14
  +++ ReloadInterceptor.java	21 Aug 2002 04:07:35 -0000	1.15
  @@ -160,7 +160,6 @@
   	context.setAttribute( "org.apache.tomcat.classloader", loader);
       }
   
  -    
       public int contextMap( Request request ) {
   	Context ctx=request.getContext();
   	if( ctx==null) return 0;
  @@ -184,59 +183,68 @@
   	    ContextManager cm=ctx.getContextManager();
   	    
   	    if( fullReload ) {
  -		Vector sI=new Vector();  // saved local interceptors
  -		BaseInterceptor[] eI;    // all exisiting interceptors
  -
  -		// save the ones with the same context, they are local
  -		eI=ctx.getContainer().getInterceptors();
  -		for(int i=0; i < eI.length ; i++)
  -		    if(ctx == eI[i].getContext()) sI.addElement(eI[i]);
  -                
  -		Enumeration e;
  -		// Need to find all the "config" that
  -		// was read from server.xml.
  -		// So far we work as if the admin interface was
  -		// used to remove/add the context.
  -		// Or like the deploytool in J2EE.
  -		Context ctx1=cm.createContext();
  -		ctx1.setContextManager( cm );
  -		ctx1.setPath(ctx.getPath());
  -		ctx1.setDocBase(ctx.getDocBase());
  -		ctx1.setReloadable( ctx.getReloadable());
  -		ctx1.setDebug( ctx.getDebug());
  -		ctx1.setHost( ctx.getHost());
  -		ctx1.setTrusted( ctx.isTrusted());
  -		e=ctx.getHostAliases();
  -		while( e.hasMoreElements())
  -		    ctx1.addHostAlias( (String)e.nextElement());
  -
  -		cm.removeContext( ctx );
  -
  -		cm.addContext( ctx1 );
  -
  -		// put back saved local interceptors
  -		e=sI.elements();
  -		while(e.hasMoreElements()){
  -		    BaseInterceptor savedI=(BaseInterceptor)e.nextElement();
  -
  -		    ctx1.addInterceptor(savedI);
  -		    savedI.setContext(ctx1);
  -		    savedI.reload(request,ctx1);
  +		synchronized(ctx) {
  +		    if(ctx.getState() == Context.STATE_NEW)
  +			return 0; // Already reloaded.
  +		    Vector sI=new Vector();  // saved local interceptors
  +		    BaseInterceptor[] eI;    // all exisiting interceptors
  +
  +		    // save the ones with the same context, they are local
  +		    eI=ctx.getContainer().getInterceptors();
  +		    for(int i=0; i < eI.length ; i++)
  +			if(ctx == eI[i].getContext()) sI.addElement(eI[i]);
  +		    
  +		    Enumeration e;
  +		    // Need to find all the "config" that
  +		    // was read from server.xml.
  +		    // So far we work as if the admin interface was
  +		    // used to remove/add the context.
  +		    // Or like the deploytool in J2EE.
  +		    Context ctx1=cm.createContext();
  +		    ctx1.setContextManager( cm );
  +		    ctx1.setPath(ctx.getPath());
  +		    ctx1.setDocBase(ctx.getDocBase());
  +		    ctx1.setReloadable( ctx.getReloadable());
  +		    ctx1.setDebug( ctx.getDebug());
  +		    ctx1.setHost( ctx.getHost());
  +		    ctx1.setTrusted( ctx.isTrusted());
  +		    e=ctx.getHostAliases();
  +		    while( e.hasMoreElements())
  +			ctx1.addHostAlias( (String)e.nextElement());
  +
  +		    BaseInterceptor ri[] = 
  +			cm.getContainer().getInterceptors(Container.H_copyContext);
  +		    int i;
  +		    for( i=0; i < ri.length; i++) {
  +			ri[i].copyContext(request, ctx, ctx1);
  +		    }
  +		    cm.removeContext( ctx );
  +		    
  +		    cm.addContext( ctx1 );
  +
  +		    // put back saved local interceptors
  +		    e=sI.elements();
  +		    while(e.hasMoreElements()){
  +			BaseInterceptor savedI=(BaseInterceptor)e.nextElement();
  +			
  +			ctx1.addInterceptor(savedI);
  +			savedI.setContext(ctx1);
  +			savedI.reload(request,ctx1);
  +		    }
  +
  +		    ctx1.init();
  +
  +		    // remap the request
  +		    request.setAttribute("tomcat.ReloadInterceptor", this);
  +		    ri = cm.getContainer().getInterceptors(Container.H_contextMap);
  +		    
  +		    for( i=0; i< ri.length; i++ ) {
  +			if( ri[i]==this ) break;
  +			int status=ri[i].contextMap( request );
  +			if( status!=0 ) return status;
  +		    }
   		}
  -
  -		ctx1.init();
  -
  -		// remap the request
  -		request.setAttribute("tomcat.ReloadInterceptor", this);
  -		BaseInterceptor ri[]=
  -		    cm.getContainer().getInterceptors(Container.H_contextMap);
  -		
  -		for( int i=0; i< ri.length; i++ ) {
  -		    if( ri[i]==this ) break;
  -		    int status=ri[i].contextMap( request );
  -		    if( status!=0 ) return status;
  -		}
  -
  +		    
   	    } else {
   		// This is the old ( buggy) behavior
   		// ctx.reload() has some fixes - it removes most of the
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message