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-connectors/jk/native2/common jk_config.c
Date Tue, 04 Mar 2003 23:58:30 GMT
costin      2003/03/04 15:58:30

  Modified:    jk/native2/common jk_config.c
  Log:
  Move the recently added code to mirror what happens on the java side ( i.e.
  all mbeans are configured, then init is called on new ones ).
  
  Now adding channels at runtime works fine - it was broken.
  
  Revision  Changes    Path
  1.31      +69 -37    jakarta-tomcat-connectors/jk/native2/common/jk_config.c
  
  Index: jk_config.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_config.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- jk_config.c	4 Mar 2003 07:14:40 -0000	1.30
  +++ jk_config.c	4 Mar 2003 23:58:30 -0000	1.31
  @@ -394,23 +394,76 @@
   {
       int i;
       int rc;
  -    
  +
  +    /* Set the config
  +     */
       for( i=0; i<cfg->cfgData->size( env, cfg->cfgData ); i++ ) {
           char *name=cfg->cfgData->nameAt(env, cfg->cfgData, i);
           rc=cfg->processNode(env, cfg , name, firstTime);
       }
  +
  +    /* Init/stop components that need that. FirstTime will be handled by workerEnv, since
  +       some components don't support dynamic config and need a specific order.
  +     */
  +    if( !firstTime ) {
  +        for( i=0; i < env->_objects->size( env, env->_objects ); i++ ) {
  +            char *name=env->_objects->nameAt( env, env->_objects, i );
  +            jk_bean_t *mbean=env->_objects->valueAt( env, env->_objects, i );
  +        
  +            if( mbean==NULL ) continue;
  +
  +            /* New state ( == not initialized ) and disabled==0,
  +               try to reinit */
  +            if( mbean->state == JK_STATE_NEW &&
  +                mbean->disabled== 0 ) {
  +                int initOk=JK_OK;
  +
  +                if( mbean->init != NULL ) {
  +                    initOk=mbean->init(env, mbean);
  +                    env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                                  "config.update(): Starting %s %d\n", name, initOk );
  +                }
  +                if( initOk==JK_OK ) {
  +                    mbean->state=JK_STATE_INIT;
  +                }
  +            }
  +
  +            /* Initialized state - and the config changed to disabled */
  +            if( mbean->state == JK_STATE_INIT &&
  +                mbean->disabled != 0 ) {
  +                    int initOk=JK_OK;
  +
  +                    /* Stop */
  +                    if( mbean->destroy ) {
  +                        initOk=mbean->destroy(env, mbean);
  +                        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                                      "config.update(): Stopping %s %d\n", name, initOk
);
  +                    }
  +                    if( initOk ) {
  +                        mbean->state=JK_STATE_NEW;
  +                    }
  +            }
  +        }
  +    }
       return rc;
   }
   
  +/** This method will process one mbean configuration or reconfiguration.
  +    The special case for firstTime will be eventually removed - it is needed because some
  +    components may still depend on a specific startup order.
  +
  +    The goal is for each component to follow JMX patterns - you should be able to add /
remove
  +    jk components at runtime in any order.
  +*/
   int jk2_config_processNode(jk_env_t *env, jk_config_t *cfg, char *name, int firstTime )
   {
       int j;   
       
       jk_map_t *prefNode=cfg->cfgData->get(env, cfg->cfgData, name);
       jk_bean_t *bean;
  -    long ver;
  +    long ver=0;
       char *verString;
  -    int oldDisabled=0;
  +    int newBean=0;
   
       if( cfg->mbean->debug > 5 ) 
       env->l->jkLog(env, env->l, JK_LOG_DEBUG, 
  @@ -423,6 +476,7 @@
                             "config.setConfig():  Creating %s\n", name );
           }
           bean=env->createBean( env, cfg->pool, name );
  +        newBean=1;
       }
       
       if( bean == NULL ) {
  @@ -432,28 +486,29 @@
           return JK_ERR;
       }
   
  -    oldDisabled=bean->disabled;
  -    
  +    /* Don't call setters on objects that have the same ver.
  +       This is just a workaround for components that are not reconfigurable.
  +     */
       verString= prefNode->get( env, prefNode, "ver" );
       if( !firstTime ) {
           /* No ver option - assume it didn't change */
  -        if( verString == NULL ) {
  +        if( verString == NULL && ! newBean ) {
               return JK_OK;
           }
  -        ver=atol( verString );
  +        if( verString != NULL ) {    
  +            ver=atol( verString );
           
  -        if( ver == bean->ver) {
  -            /* Object didn't change
  -             */
  -            return JK_OK;
  +            if( ver == bean->ver && ! newBean ) {
  +                /* Object didn't change and is not new
  +                 */
  +                return JK_OK;
  +            }
           }
       }
       
       if( !firstTime )
           env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "config.update(): Updating %s %ld %ld %d\n", name, ver, bean->ver,
getpid() );
  -    
  -    /* XXX Maybe we shoud destroy/init ? */
  +                      "config.update(): Updating %s in %d\n", name, getpid() );
       
       for( j=0; j<prefNode->size( env, prefNode ); j++ ) {
           char *pname=prefNode->nameAt(env, prefNode, j);
  @@ -464,29 +519,6 @@
   
       env->l->jkLog(env, env->l, JK_LOG_INFO,
                     "config.update(): done %s\n", name );
  -    
  -    if( !firstTime ) {
  -        /* Deal with lifecycle - if a mbean has been enabled or disabled */
  -        if( oldDisabled != bean->disabled ) {
  -            /* State change ... */
  -            if( bean->disabled==0 ) {
  -                /* Start */
  -                if( bean->init != NULL ) {
  -                    env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                                  "config.update(): Starting %s\n", name );
  -                    bean->init(env, bean);
  -                }
  -            } else {
  -                /* Stop */
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                              "config.update(): Stopping %s\n", name );
  -                bean->destroy(env, bean);
  -            }
  -
  -        }
           
  -    }
  -    
  -    
       return JK_OK;
   }
  
  
  

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


Mime
View raw message