costin      02/03/18 21:31:57

  Modified:    jk/native2/common jk_config.c
  Log:
  Some 'featurism' removed. In jk1 there is a single workers.properties. The
  current code supports multiple files - but that will prevent ( or make
  extremely difficult ) writeable configs ( where ajp14 sets properties,
  and mod_jk saves them so on start apache will not need a running tomcat ).
  
  Backward compatibility can be added later, if anyone really needs it -
  I think it's far better to focus on a consistent and clean config
  format.
  
  I removed most of the 'backward compat' code - now the same patterns
  are used everywhere, with no exceptions.
  
  That means:
  workersProperties -> config.file
  logLevel -> logger.level
  logFile -> logger.file
  ( etc ).
  
  On startup, jk will define few objects like 'config', 'workerEnv', 'logger',
  etc. In addition, now objects will be automatically created on the first
  reference.
  
  This is almost identical with the mechanism used in server.xml.
  The major difference is that this is primarily intended to be
  generated and read/write.
  
  Revision  Changes    Path
  1.3       +41 -72    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_config.c       19 Mar 2002 04:53:40 -0000      1.2
  +++ jk_config.c       19 Mar 2002 05:31:57 -0000      1.3
  @@ -58,7 +58,7 @@
   /***************************************************************************
    * Description: General purpose config object                                 *
    * Author:      Gal Shachor <[EMAIL PROTECTED]>                           *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   #include "jk_global.h"
  @@ -78,9 +78,13 @@
                                      int *countP);
   
   
  -/* ==================== Backward compatibility ==================== */
  +/* ==================== ==================== */
   
  -static int jk2_config_setWorkerFile( jk_env_t *env,
  +/* Set the file where the config will be read and
  + * ( in future ) stored.
  + *
  + */
  +static int jk2_config_setConfigFile( jk_env_t *env,
                                        jk_config_t *cfg,
                                        jk_workerEnv_t *wEnv,
                                        char *workerFile)
  @@ -90,30 +94,15 @@
       jk_map_t *props;
       int i;
       
  -    /* We should make it relative to JK_HOME or absolute path.
  -       ap_server_root_relative(cmd->pool,opt); */
  -    
  -    /* Avoid recursivity */
  -    for( i=0; i<cfg->map->size( env, cfg->map ); i++ ) {
  -        char *name=cfg->map->nameAt(env, cfg->map, i);
  -        char *val=cfg->map->valueAt(env, cfg->map, i);
  -        if( strcmp( name, "workerFile" )==0 &&
  -            strcmp( val, workerFile ) == 0 ) {
  -            env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                          "Recursive init - already read %s", workerFile );
  -            return JK_FALSE;
  -        }
  -    }
  -
       if (stat(workerFile, &statbuf) == -1) {
           env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                      "Can't find the workers file %s", workerFile );
  +                      "Can't find config file %s", workerFile );
           return JK_FALSE;
       }
       
       /** Read worker files
        */
  -    env->l->jkLog(env, env->l, JK_LOG_DEBUG, "Reading properties %s %d\n",
  +    env->l->jkLog(env, env->l, JK_LOG_DEBUG, "Reading config %s %d\n",
                     workerFile, cfg->map->size(env, cfg->map) );
       
       jk2_map_default_create(env, &props, wEnv->pool);
  @@ -141,49 +130,17 @@
       return JK_TRUE;
   }
   
  +/** Interpret the 'name' as [OBJECT].[PROPERTY].
  +    If the [OBJECT] is not found, construct it using
  +    the prefix ( i.e. we'll search for a factory that matches
  +    name - XXX make it longest match ? ).
   
  -static int jk2_config_setLogLevel( struct jk_env *env,
  -                                   char *level)
  -{
  -    if(0 == strcasecmp(level, JK_LOG_INFO_VERB)) {
  -        env->l->level=JK_LOG_INFO_LEVEL;
  -    }
  -    if(0 == strcasecmp(level, JK_LOG_DEBUG_VERB)) {
  -        env->l->level=JK_LOG_DEBUG_LEVEL;
  -    }
  -    fprintf( stderr, "Setting %s %d \n", level, env->l->level );
  -    return JK_TRUE;
  -}
  -
  -/* Backward compatiblity ? This is not used in jk2, all workers are loaded
  - */
  -static int jk2_config_setWorkerList( struct jk_env *env,
  -                                     struct jk_workerEnv *wEnv,
  -                                     char *wlist)
  -{
  -    wEnv->worker_list=jk2_config_split( env, wEnv->pool,
  -                                        wlist, NULL, & wEnv->declared_workers );
  -}
  -
  -/** Backward compat
  -      host:port/path=worker
  - */
  -static int jk2_config_setUriProperty( jk_env_t *env,
  -                                      jk_config_t *cfg,
  -                                      char *name, char *val)
  -
  -{
  -    /* only /path supported for now */
  -    jk_pool_t *workerPool=cfg->pool->create(env, cfg->pool, HUGE_POOL_SIZE);
  -    
  -    env->createInstance( env, workerPool, "uri", name );
  -    return JK_TRUE;
  -}
  -
  -static int jk2_config_setWorkerProperty( jk_env_t *env,
  -                                        jk_config_t *cfg,
  -                                        char *name, char *val)
  -
  +    Then set the property on the object that is found or
  +    constructed.
  +*/
  +static int jk2_config_setBeanPropertyString( jk_env_t *env,
  +                                             jk_config_t *cfg,
  +                                             char *name, char *val)
   {
       jk_bean_t *w = NULL;
       char *type=NULL;
  @@ -256,9 +213,27 @@
       return JK_FALSE;
   }
   
  +/** Set a property for this config object
  + */
  +static int jk2_config_setAttribute( struct jk_env *env, struct jk_bean *mbean,
  +                                    char *name, void *valueP)
  +{
  +    jk_config_t *cfg=mbean->object;
  +    char *value=valueP;
  +    
  +    if( strcmp( name, "file" )==0 ) {
  +        return jk2_config_setConfigFile(env, cfg, cfg->workerEnv, value);
  +    } else {
  +        return JK_FALSE;
  +    }
   
  +    return JK_TRUE;
  +}
  +
  +/** Set a property on a bean
  + */
   static int jk2_config_setProperty(jk_env_t *env, jk_config_t *cfg,
  -                                  jk_bean_t *mbean, const char *name, void *val)
  +                                  jk_bean_t *mbean, char *name, void *val)
   {
       char *pname=cfg->pool->calloc( env, cfg->pool,
                                      strlen( name ) + strlen( mbean->name ) + 4 );
  @@ -274,7 +249,7 @@
   }
   
   static int jk2_config_setPropertyString(jk_env_t *env, jk_config_t *cfg,
  -                                          const char *name, char *value)
  +                                        char *name, char *value)
   {
       jk_bean_t *mbean;
   
  @@ -284,15 +259,8 @@
   
       value = jk2_config_replaceProperties(env, initData, initData->pool, value);
   
  -    if( strcmp( name, "workerFile" ) == 0 ) {
  -        return jk2_config_setWorkerFile(env, cfg, wEnv, value);
  -    } else if( strcmp( name, "logLevel") == 0 ) {
  -        return jk2_config_setLogLevel( env, value );
  -        /* XXX other special cases, backward compat, /, etc */
  -    }
  -    
       /* Default format */
  -    status=jk2_config_setWorkerProperty(env, cfg, name, value );
  +    status=jk2_config_setBeanPropertyString(env, cfg, name, value );
       if( status==JK_TRUE ) return status;
   
       /* It may be a 'normal' property */
  @@ -723,6 +691,7 @@
       _this->setProperty=jk2_config_setProperty;
       
       result->object=_this;
  +    result->setAttribute=jk2_config_setAttribute;
   
       
       return JK_TRUE;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to