costin      00/12/28 13:03:18

  Modified:    src/share/org/apache/tomcat/core BaseInterceptor.java
                        ContextManager.java
  Log:
  Added a new hook - engineState, to notify modules of state changes in core.
  ( it is important since modules can do different things in different states,
  for example AutoConfig shouldn't add contexts until all interceptors are added)
  
  engineStart,engineStop were added in 3.3 to allow connectors to start after
  the server is in a stable state - engineState() is a much better hook.
  
  Revision  Changes    Path
  1.34      +12 -2     
jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- BaseInterceptor.java      2000/12/28 07:14:44     1.33
  +++ BaseInterceptor.java      2000/12/28 21:03:17     1.34
  @@ -301,15 +301,25 @@
       {
       }
   
  -    public void engineStart( ContextManager cm )
  -     throws TomcatException
  +    public  void engineStart(ContextManager cm )
  +     throws TomcatException
       {
       }
  +    
   
       public  void engineStop(ContextManager cm )
        throws TomcatException
       {
       }
  +
  +    /** Notifies the module that the server changed it's state.
  +     *  XXX this seems more flexible than init/start/stop/shutdown.
  +     */
  +    public void engineState( ContextManager cm, int state )
  +     throws TomcatException
  +    {
  +    }
  +
   
       // -------------------- Context hooks --------------------
       
  
  
  
  1.161     +20 -5     
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.160
  retrieving revision 1.161
  diff -u -r1.160 -r1.161
  --- ContextManager.java       2000/12/28 01:15:38     1.160
  +++ ContextManager.java       2000/12/28 21:03:17     1.161
  @@ -303,6 +303,20 @@
        return state;
       }
   
  +    /** Change the state, after notifying all modules about the change
  +     *  Any error will be propagated - the server will not change the
  +     *  state and should fail if any module can't handle that.
  +     */
  +    public final void setState( int state )
  +     throws TomcatException
  +    {
  +     BaseInterceptor existingI[]=defaultContainer.getInterceptors();
  +     for( int i=0; i<existingI.length; i++ ) {
  +         existingI[i].engineState( this, state );
  +     }
  +     this.state=state;
  +    }
  +    
       /**
        *  Parent loader is the "base" class loader of the
        *       application that starts tomcat, and includes no
  @@ -366,7 +380,7 @@
   
        if( state==STATE_CONFIG ) return;
   
  -     // we are at least initialized, call engineInit hook
  +     // we are at last initialized, call engineInit hook
        ri.engineInit( this );
   
        // make sure the interceptor knows about all existing contexts.
  @@ -434,12 +448,13 @@
            return;
        if(debug>0 ) log( "Tomcat init");
        
  +     setState(STATE_INIT);
  +     
        BaseInterceptor existingI[]=defaultContainer.getInterceptors();
        for( int i=0; i<existingI.length; i++ ) {
            existingI[i].engineInit( this );
        }
   
  -     state=STATE_INIT;
       }
   
       /** Will start the connectors and begin serving requests.
  @@ -471,13 +486,13 @@
        }
   
        // requests can be processed now
  -     state=STATE_START;
  +     setState(STATE_START);
       }
   
       /** Will stop all connectors
        */
  -    public final void stop() throws Exception {
  -     state=STATE_INIT; // initialized, but not accepting connections
  +    public final void stop() throws TomcatException {
  +     setState(STATE_INIT); // initialized, but not accepting connections
        
        BaseInterceptor cI[]=defaultContainer.getInterceptors();
        for( int i=0; i< cI.length; i++ ) {
  
  
  

Reply via email to