costin      01/02/02 23:34:41

  Modified:    src/share/org/apache/tomcat/core Context.java
               src/share/org/apache/tomcat/modules/config LogSetter.java
  Log:
  Ops, made a mistake - the context modules can't be initialized
  before the context is added - since there is no context manager.
  
  Also added some comments about the fact that the only tested
  mode is: create context, add modules to it, add it to the server.
  Adding/removing modules at run time may work, but it's not
  supported or tested.
  
  Revision  Changes    Path
  1.137     +24 -2     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.136
  retrieving revision 1.137
  diff -u -r1.136 -r1.137
  --- Context.java      2001/02/03 07:08:00     1.136
  +++ Context.java      2001/02/03 07:34:41     1.137
  @@ -482,8 +482,18 @@
        throws TomcatException
       {
        if(this.state==STATE_NEW && state==STATE_ADDED ) {
  +         // we are just beeing added
            BaseInterceptor cI[]=getContainer().getInterceptors();
            for( int i=0; i< cI.length; i++ ) {
  +             if( cI[i].getContext() != this )
  +                 continue; // not ours, don't have to initialize it.
  +             cI[i].addInterceptor( contextM, this , cI[i] ); 
  +             BaseInterceptor existingI[]=defaultContainer.getInterceptors();
  +             for( int j=0; j<existingI.length; j++ ) {
  +                 if( existingI[j] != cI[i] )
  +                     existingI[j].addInterceptor( contextM, this, cI[i] );
  +             }
  +             
                // set all local interceptors 
                cI[i].setContextManager( contextM );
                cI[i].engineInit( contextM );
  @@ -1164,6 +1174,20 @@
        ri.setContext( this );
        defaultContainer.addInterceptor(ri);
   
  +     if( getState() == STATE_NEW ) return;
  +
  +     // This shouldn't happen in most cases - the "normal"
  +     // case is to construct a Context, add the local modules
  +     // and then add it to a server. Later, when the server
  +     // is initialized it'll init the contexts and that will
  +     // init local modules.
  +
  +     // The following code is not tested - it deals with the
  +     // case that a module is added at runtime. Even if this
  +     // is not a 'normal' case we should handle it. 
  +     
  +     // we are at least ADDED - that means the CM is initialized
  +     // if we can find the global modules and announce our presence
        ri.addInterceptor( contextM, this , ri ); 
        BaseInterceptor existingI[]=defaultContainer.getInterceptors();
        for( int i=0; i<existingI.length; i++ ) {
  @@ -1172,8 +1196,6 @@
            // contextM  can be null
        }
        
  -     if( getState() == STATE_NEW ) return;
  -     // we are at least ADDED - that means the CM is initialized
        ri.setContextManager( contextM );
   
        ri.engineInit( contextM );
  
  
  
  1.5       +3 -2      
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LogSetter.java
  
  Index: LogSetter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LogSetter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LogSetter.java    2001/02/03 05:36:24     1.4
  +++ LogSetter.java    2001/02/03 07:34:41     1.5
  @@ -199,7 +199,8 @@
            name=name +  "/"  + ctx.getId();
        }
   
  -     log( "Constructing logger " + name + " " + path + " " + ctx );
  +     if( debug>0) 
  +         log( "Constructing logger " + name + " " + path + " " + ctx );
        
        // construct a queue logger
        QueueLogger ql=new QueueLogger();
  @@ -218,7 +219,7 @@
            // this will be the Log interface to the log we just created
            // ( the way logs and channels are created is a bit
            // complicated - work for later )
  -         cm.setLog( Log.getLog( name, "ContextManager");
  +         cm.setLog( Log.getLog( name, "ContextManager"));
        }
   
        if( ctx!=null ) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to