You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/03/04 08:14:42 UTC

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_config.c

costin      2003/03/03 23:14:40

  Modified:    jk/native2/common jk_config.c
  Log:
  Deal with changes in "disabled" - call init/destroy methods.
  
  Few other small config fixes.
  
  Revision  Changes    Path
  1.30      +42 -6     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- jk_config.c	4 Feb 2003 07:39:59 -0000	1.29
  +++ jk_config.c	4 Mar 2003 07:14:40 -0000	1.30
  @@ -160,7 +160,7 @@
       
       name= cfg->pool->pstrdup( env, cfg->pool, name );
       val= cfg->pool->pstrdup( env, cfg->pool, val );
  -
  +    
       if (strlen(name) && *name == '$') {
           cfg->map->put(env, cfg->map, name + 1, val, NULL);
           return JK_OK;
  @@ -222,10 +222,16 @@
           return JK_OK;
       }
       if( strcmp( name, "disabled" ) == 0 ) {
  +        int oldDisabled=mbean->disabled;
  +        
           mbean->disabled=atoi( val );
           if(mbean->setAttribute) {
               mbean->setAttribute( env, mbean, name, val );
           }
  +
  +        /* State change ... - it needs to be handled at the end*/
  +        /*         if( oldDisabled != mbean->disabled ) { */
  +        /*         } */
           return JK_OK;
       }
       if( strcmp( name, "info" ) == 0 ) {
  @@ -402,8 +408,9 @@
       
       jk_map_t *prefNode=cfg->cfgData->get(env, cfg->cfgData, name);
       jk_bean_t *bean;
  -    int ver;
  +    long ver;
       char *verString;
  +    int oldDisabled=0;
   
       if( cfg->mbean->debug > 5 ) 
       env->l->jkLog(env, env->l, JK_LOG_DEBUG, 
  @@ -417,7 +424,7 @@
           }
           bean=env->createBean( env, cfg->pool, name );
       }
  -
  +    
       if( bean == NULL ) {
           /* Can't create it, save the value in our map */
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  @@ -425,14 +432,17 @@
           return JK_ERR;
       }
   
  +    oldDisabled=bean->disabled;
  +    
       verString= prefNode->get( env, prefNode, "ver" );
       if( !firstTime ) {
  +        /* No ver option - assume it didn't change */
           if( verString == NULL ) {
               return JK_OK;
           }
  -        ver=atoi( verString );
  +        ver=atol( verString );
           
  -        if( ver <= bean->ver) {
  +        if( ver == bean->ver) {
               /* Object didn't change
                */
               return JK_OK;
  @@ -441,7 +451,7 @@
       
       if( !firstTime )
           env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "config.update(): Updating %s\n", name );
  +                      "config.update(): Updating %s %ld %ld %d\n", name, ver, bean->ver, getpid() );
       
       /* XXX Maybe we shoud destroy/init ? */
       
  @@ -452,5 +462,31 @@
           cfg->setProperty( env, cfg, bean, pname, pvalue );
       }
   
  +    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