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

2004-03-17 Thread hgomez
hgomez  2004/03/17 08:55:48

  Modified:jk/native2/common jk_config.c
  Log:
  Remove unused vars (thanks gcc -wall)
  
  Revision  ChangesPath
  1.33  +2 -8  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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- jk_config.c   24 Feb 2004 08:44:40 -  1.32
  +++ jk_config.c   17 Mar 2004 16:55:48 -  1.33
  @@ -62,9 +62,6 @@
char *propertyString,
char **objName, char 
**propertyName )
   {
  -jk_bean_t *w = NULL;
  -char *type=NULL;
  -char *dot=0;
   char *lastDot;
   char *lastDot1;
   
  @@ -181,7 +178,7 @@
   return JK_OK;
   }
   if( strcmp( name, disabled ) == 0 ) {
  -int oldDisabled=mbean-disabled;
  +/* int oldDisabled=mbean-disabled; */
   
   mbean-disabled=atoi( val );
   if(mbean-setAttribute) {
  @@ -229,9 +226,6 @@
char *name, char *value)
   {
   jk_bean_t *mbean;
  -
  -jk_workerEnv_t *wEnv=cfg-workerEnv;
  -jk_map_t *initData=cfg-map;
   int status;
   char *objName=NULL;
   char *propName=NULL;
  @@ -352,7 +346,7 @@
   int jk2_config_processConfigData(jk_env_t *env, jk_config_t *cfg,int firstTime )
   {
   int i;
  -int rc;
  +int rc = 0;
   
   /* Set the config
*/
  
  
  

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



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

2003-03-04 Thread costin
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  ChangesPath
  1.31  +69 -37jakarta-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 -   1.30
  +++ jk_config.c   4 Mar 2003 23:58:30 -   1.31
  @@ -394,23 +394,76 @@
   {
   int i;
   int rc;
  -
  +
  +/* Set the config
  + */
   for( i=0; icfg-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, 

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

2003-03-03 Thread costin
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  ChangesPath
  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 -   1.29
  +++ jk_config.c   4 Mar 2003 07:14:40 -   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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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

2002-10-28 Thread mturk
mturk   2002/10/28 11:09:26

  Modified:jk/native2/common jk_config.c
  Log:
  Simple patch that allows setting quasi-environment variables that
  will be resolved later in the config.
  If the option name starts with $ like $TOMCAT_HOME=/some/path
  then that will be set to the cfg-map and resolved later in the config.
  Keeps the config smaller and requires no reboot.
  
  Revision  ChangesPath
  1.28  +7 -2  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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- jk_config.c   8 Jul 2002 13:40:54 -   1.27
  +++ jk_config.c   28 Oct 2002 19:09:25 -  1.28
   -157,10 +157,15 
   strcat( pname, . );
   strcat( pname, name );
   }
  -
  +
   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;
  +}
  +
   /** Save it on the config. XXX no support for deleting yet */
   /* The _original_ value. Will be saved with $() in it */
   if( mbean-settings == NULL )
  
  
  

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




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

2002-07-08 Thread mturk

mturk   2002/07/08 06:40:54

  Modified:jk/native2/common jk_config.c
  Log:
  no message
  
  Revision  ChangesPath
  1.27  +5 -5  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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- jk_config.c   10 Jun 2002 21:55:06 -  1.26
  +++ jk_config.c   8 Jul 2002 13:40:54 -   1.27
  @@ -199,7 +199,7 @@
   }
   
   if( cfg-mbean-debug  0 )
  -env-l-jkLog( env, env-l, JK_LOG_INFO, config: set %s / %s / %#lx / %s = 
%s\n,
  +env-l-jkLog( env, env-l, JK_LOG_DEBUG, config: set %s / %s / %#lx / %s 
= %s\n,
  mbean-name, name, mbean, pname, val);
   
   if( strcmp( name, name ) == 0 ) {
  @@ -234,7 +234,7 @@
   /* 'file' property on ourself, avoid rec.
*/
   if( cfg-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,
 config.setAttribute() ignore %s %s %s\n, mbean-name, 
name, val );
   
   return JK_OK;
  @@ -247,7 +247,7 @@
 config.setAttribute() Error setting %s %s %s\n, 
mbean-name, name, val );
   }
   if( cfg-mbean-debug  0 ) 
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,
 config.setAttribute() %d setting %s %s %s\n,
 cfg-mbean-debug, mbean-name, name, val );
   return rc;
  @@ -401,13 +401,13 @@
   char *verString;
   
   if( cfg-mbean-debug  5 ) 
  -env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG, 
 config.setConfig():  process %s\n, name );
   
   bean=env-getBean( env, name );
   if( bean==NULL ) {
   if( cfg-mbean-debug  0 ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG, 
 config.setConfig():  Creating %s\n, name );
   }
   bean=env-createBean( env, cfg-pool, name );
  
  
  

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




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

2002-05-30 Thread costin

costin  02/05/30 11:20:49

  Modified:jk/native2/common jk_config.c
  Log:
  Pass the disabled and debug attributes to the component.
  
  Revision  ChangesPath
  1.24  +24 -7 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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- jk_config.c   29 May 2002 17:51:23 -  1.23
  +++ jk_config.c   30 May 2002 18:20:49 -  1.24
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.23 $   *
  + * Version: $Revision: 1.24 $   *
***/
   
   #include jk_global.h
  @@ -262,9 +262,11 @@
   } else {
   cfg-map-put( env, cfg-map, pname, val, NULL );
   }
  -
  -/* env-l-jkLog( env, env-l, JK_LOG_INFO, config: set %s / %s / 
%s=%s\n, */
  -/*mbean-name, name, pname, val); */
  +
  +if( cfg-mbean-debug  0 )
  +env-l-jkLog( env, env-l, JK_LOG_INFO, config: set %s / %s / %p / %s = 
%s\n,
  +   mbean-name, name, mbean, pname, val);
  +
   if( strcmp( name, name ) == 0 ) {
   return JK_OK;
   }
  @@ -274,10 +276,16 @@
   }
   if( strcmp( name, debug ) == 0 ) {
   mbean-debug=atoi( val );
  +if(mbean-setAttribute) {
  +mbean-setAttribute( env, mbean, name, val );
  +}
   return JK_OK;
   }
   if( strcmp( name, disabled ) == 0 ) {
   mbean-disabled=atoi( val );
  +if(mbean-setAttribute) {
  +mbean-setAttribute( env, mbean, name, val );
  +}
   return JK_OK;
   }
   if( strcmp( name, info ) == 0 ) {
  @@ -460,6 +468,10 @@
   int ver;
   char *verString;
   
  +if( cfg-mbean-debug  5 ) 
  +env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +  config.setConfig():  process %s\n, name );
  +
   bean=env-getBean( env, name );
   if( bean==NULL ) {
   if( cfg-mbean-debug  0 ) {
  @@ -530,8 +542,13 @@
   return JK_ERR;
   }
   
  -if( !firstTime  statbuf.st_mtime  cfg-mtime )
  +if( !firstTime  statbuf.st_mtime  cfg-mtime ) {
  +if( cfg-mbean-debug  0 )
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
  +  config.update(): No reload needed %s %ld %ld\n, 
cfg-file,
  +  cfg-mtime, statbuf.st_mtime );
   return JK_OK;
  +}

   JK_ENTER_CS(cfg-cs, csOk);
   
  @@ -589,9 +606,9 @@
   
   
   static int jk2_config_update(jk_env_t *env,
  -   jk_config_t *cfg, int *didReload)
  + jk_config_t *cfg, int *didReload)
   {
  - return jk2_config_readFile( env, cfg, didReload, JK_FALSE );
  +return jk2_config_readFile( env, cfg, didReload, JK_FALSE );
   }
   
   /** Set a property for this config object
  
  
  

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




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

2002-05-22 Thread costin

costin  02/05/22 16:40:36

  Modified:jk/native2/common jk_config.c
  Log:
  Stupid mistake...
  
  Revision  ChangesPath
  1.20  +2 -2  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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- jk_config.c   18 May 2002 22:34:01 -  1.19
  +++ jk_config.c   22 May 2002 23:40:36 -  1.20
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.19 $   *
  + * Version: $Revision: 1.20 $   *
***/
   
   #include jk_global.h
  @@ -268,7 +268,7 @@
   if( strcmp( name, name ) == 0 ) {
   return JK_OK;
   }
  -if( strcmp( name, ver  ) == 0 ) {
  +if( strcmp( name, ver ) == 0 ) {
   mbean-ver=atol(val);
   return JK_OK;
   }
  
  
  

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




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

2002-05-14 Thread costin

costin  02/05/14 10:12:45

  Modified:jk/native2/common jk_config.c
  Log:
  Implement config reloading.
  
  IMORTANT: when the config file is reloaded we do process _only_ components
  with a 'ver' attribute that is newer than what we have.
  We will call all setters for that component - but that is not guaranteed
  to have any effect, as only few attributes are supported at runtime.
  
  We should be very conservative in what we allow reconfiguration for - it's
  dangerous to modify a running server, and adding sync can kill performance.
  
  In particular enabling/disabling workers is save, adding workers should
  be safe too. Adding uris at runtime is also possible. Changin lb_factors
  and other properties is possible.
  
  Revision  ChangesPath
  1.16  +242 -81   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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- jk_config.c   9 May 2002 21:00:53 -   1.15
  +++ jk_config.c   14 May 2002 17:12:45 -  1.16
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.15 $   *
  + * Version: $Revision: 1.16 $   *
***/
   
   #include jk_global.h
  @@ -69,9 +69,15 @@
   #define CAPACITY_INC_SIZE (50)
   #define LENGTH_OF_LINE(1024)
   
  +int jk2_config_read(struct jk_env *env, struct jk_config *cfg,
  +struct jk_map *map);
   static void jk2_trim_prp_comment(char *prp);
   static int  jk2_trim(char *s);
   
  +static int JK_METHOD jk2_config_readFile(jk_env_t *env,
  + jk_config_t *cfg,
  + int *didReload, int firstTime);
  +
   /*   */
   
   /* Set the config file, read it. The property will also be
  @@ -84,45 +90,13 @@
   {
   struct stat statbuf;
   int err;
  -jk_map_t *props;
  +jk_map_t *cfgData;
   int i;
  +int j;
   
  -if (stat(workerFile, statbuf) == -1) {
  -env-l-jkLog(env, env-l, JK_LOG_ERROR,
  -  config.setConfig(): Can't find config file %s, workerFile );
  -return JK_ERR;
  -}
  -
   cfg-file=workerFile;
  -
  -/** Read worker files
  - */
  -env-l-jkLog(env, env-l, JK_LOG_INFO, config.setConfig(): Reading config %s 
%d\n,
  -  workerFile, cfg-map-size(env, cfg-map) );
  -
  -jk2_map_default_create(env, props, wEnv-pool);
  -
  -err=jk2_config_read(env, cfg, props, workerFile );
  -
  -if( err==JK_OK ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO, 
  -  config.setConfig():  Reading properties %s %d\n,
  -  workerFile, props-size( env, props ) );
  -} else {
  -env-l-jkLog(env, env-l, JK_LOG_ERROR,
  -  config.setConfig(): Error reading properties %s\n,
  -  workerFile );
  -return JK_ERR;
  -}
   
  -for( i=0; iprops-size( env, props); i++ ) {
  -char *name=props-nameAt(env, props, i);
  -char *val=props-valueAt(env, props, i);
  -
  -cfg-setPropertyString( env, cfg, name, val );
  -}
  -
  -return JK_OK;
  +return jk2_config_readFile( env, cfg, NULL, JK_TRUE );
   }
   
   /* Experimental. Dangerous. The file param will go away, for security
  @@ -247,9 +221,12 @@
  jk_bean_t *mbean, char *name, char *val)
   {
   char *pname;
  +int multiValue=JK_FALSE;
  +
   if( mbean == cfg-mbean ) {
   pname=name;
   } else {
  +/* Make substitution work for ${OBJ_NAME.PROP} */
   pname=cfg-pool-calloc( env, cfg-pool,
strlen( name ) + strlen( mbean-name ) + 4 );
   strcpy( pname, mbean-name );
  @@ -257,14 +234,32 @@
   strcat( pname, name );
   }
   
  -/* fprintf( stderr, config.setProperty %s %s %s \n, mbean-name, name, val ); 
*/
  -
  +name= cfg-pool-pstrdup( env, cfg-pool, name );
  +val= cfg-pool-pstrdup( env, cfg-pool, val );
  +
   /** Save it on the config. XXX no support for deleting yet */
   /* The _original_ value. Will be saved with $() in it */
   if( mbean-settings == NULL )
   jk2_map_default_create(env, mbean-settings, cfg-pool);
   
  -mbean-settings-add( env, mbean-settings, name, val );
  +if( 

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

2002-05-09 Thread costin

costin  02/05/09 14:00:53

  Modified:jk/native2/common jk_config.c
  Log:
  Remove the old code.
  
  Be less verbose ( unless config.debug property is set ).
  
  Add another 'magic' attribute, info. It'll allow some comments to be
  associated with each object, and persisted automatically.
  
  ( now the config will save the workers.properties whenever it receives
  a request to do so - curently via shm, but we can easyly add the other
  channels - what used to be called 1.4 is pretty close )
  
  Revision  ChangesPath
  1.15  +20 -279   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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_config.c   8 May 2002 23:50:37 -   1.14
  +++ jk_config.c   9 May 2002 21:00:53 -   1.15
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.14 $   *
  + * Version: $Revision: 1.15 $   *
***/
   
   #include jk_global.h
  @@ -71,12 +71,6 @@
   
   static void jk2_trim_prp_comment(char *prp);
   static int  jk2_trim(char *s);
  -static char **jk2_config_getValues(jk_env_t *env, jk_config_t *m,
  -   struct jk_pool *resultPool,
  -   char *name,
  -   char *sep,
  -   int *countP);
  -
   
   /*   */
   
  @@ -203,8 +197,6 @@
   No replacement or saving is done on the val - this is
   a private method
   */
  -
  -
   static int jk2_config_processBeanPropertyString( jk_env_t *env,
jk_config_t *cfg,
char *propertyString,
  @@ -289,11 +281,21 @@
   if( strcmp( name, name ) == 0 ) {
   return JK_OK;
   }
  +if( strcmp( name, ver  ) == 0 ) {
  +mbean-ver=atol(val);
  +return JK_OK;
  +}
   if( strcmp( name, debug ) == 0 ) {
   mbean-debug=atoi( val );
  +return JK_OK;
   }
   if( strcmp( name, disabled ) == 0 ) {
   mbean-disabled=atoi( val );
  +return JK_OK;
  +}
  +if( strcmp( name, info ) == 0 ) {
  +/* do nothing, this is a comment */
  +return JK_OK;
   }
   
   if( (mbean == cfg-mbean) 
  @@ -301,8 +303,9 @@
   cfg-file != NULL ) {
   /* 'file' property on ourself, avoid rec.
*/
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  config.setAttribute() ignore %s %s %s\n, mbean-name, name, 
val );
  +if( cfg-mbean-debug  0 )
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  config.setAttribute() ignore %s %s %s\n, mbean-name, 
name, val );
   
   return JK_OK;
   }
  @@ -313,9 +316,10 @@
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 config.setAttribute() Error setting %s %s %s\n, 
mbean-name, name, val );
   }
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  config.setAttribute() %d setting %s %s %s\n,
  -  cfg-mbean-debug, mbean-name, name, val );
  +if( cfg-mbean-debug  0 ) 
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  config.setAttribute() %d setting %s %s %s\n,
  +  cfg-mbean-debug, mbean-name, name, val );
   return rc;
   }
   return JK_ERR;
  @@ -366,166 +370,6 @@
   }
   
   
  -char *jk2_config_getString(jk_env_t *env, jk_config_t *conf,
  -  const char *name, char *def)
  -{
  -char *val= conf-map-get( env, conf-map, name );
  -if( val==NULL )
  -return def;
  -return val;
  -}
  -
  -int jk2_config_getBool(jk_env_t *env, jk_config_t *conf,
  -  const char *prop, const char *def)
  -{
  -char *val=jk2_config_getString( env, conf, prop, (char *)def );
  -
  -if( val==NULL )
  -return JK_ERR;
  -
  -if( strcmp( val, 1 ) == 0 ||
  -strcasecmp( val, TRUE ) == 0 ||
  -strcasecmp( val, ON ) == 0 ) {
  -return JK_OK;
  -}
  -return JK_ERR;
  -}
  -
  -/** Get a string property, using the worker's style
  -for properties.
  -Example worker.ajp13.host=localhost.
  -*/
  -static char *jk2_config_getStrProp(jk_env_t *env, 

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

2002-05-03 Thread costin

costin  02/05/03 10:40:25

  Modified:jk/native2/common jk_config.c
  Log:
  Display an error message on unknown property names.
  
  debugEnv will turn on the messages about object creation/etc.
  
  Revision  ChangesPath
  1.13  +18 -3 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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_config.c   25 Apr 2002 18:49:37 -  1.12
  +++ jk_config.c   3 May 2002 17:40:25 -   1.13
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.12 $   *
  + * Version: $Revision: 1.13 $   *
***/
   
   #include jk_global.h
  @@ -278,8 +278,14 @@
   return JK_OK;
   }
   
  -if(mbean-setAttribute)
  -return mbean-setAttribute( env, mbean, name, val );
  +if(mbean-setAttribute) {
  +int rc= mbean-setAttribute( env, mbean, name, val );
  +if( rc != JK_OK ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  config.setAttribute() Error setting %s %s %s\n, 
mbean-name, name, val );
  +}
  +return rc;
  +}
   return JK_ERR;
   }
   
  @@ -302,7 +308,14 @@
   cfg-setProperty( env, cfg, cfg-mbean, name, value );
   return status;
   }
  +
  +if( strncmp( objName, disabled:, 9) == 0 ) {
  +return JK_OK;
  +}
   
  +/** Replace properties in the object name */
  +objName = jk2_config_replaceProperties(env, cfg-map, cfg-map-pool, objName);
  +
   mbean=env-getBean( env, objName );
   if( mbean==NULL ) {
   mbean=env-createBean( env, cfg-pool, objName );
  @@ -779,6 +792,8 @@
   
   if( strcmp( name, file )==0 ) {
   return jk2_config_setConfigFile(env, cfg, cfg-workerEnv, value);
  +} else if( strcmp( name, debugEnv )==0 ) {
  +env-debug=atoi( value );
   } else if( strcmp( name, save )==0 ) {
   /* Experimental. Setting save='foo' will save the current config in
  foo
  
  
  

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




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

2002-04-12 Thread costin

costin  02/04/12 16:08:45

  Modified:jk/native2/common jk_config.c
  Log:
  Few methods made public, fix a problem in replaceProperties.
  
  ( the public methods will be 'inherited' in config_registry ).
  
  Also use the virtual methods - so overriding can work.
  
  I love OO programming :-)
  
  Revision  ChangesPath
  1.11  +12 -10jakarta-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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- jk_config.c   12 Apr 2002 21:49:03 -  1.10
  +++ jk_config.c   12 Apr 2002 23:08:45 -  1.11
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.10 $   *
  + * Version: $Revision: 1.11 $   *
***/
   
   #include jk_global.h
  @@ -239,8 +239,8 @@
   @param name the property to be set ( can't have '.' or ':' in it )
   @param val the value, $(property) will be replaced.
*/
  -static int jk2_config_setProperty(jk_env_t *env, jk_config_t *cfg,
  -  jk_bean_t *mbean, char *name, void *val)
  +int jk2_config_setProperty(jk_env_t *env, jk_config_t *cfg,
  +   jk_bean_t *mbean, char *name, void *val)
   {
   char *pname;
   if( mbean == cfg-mbean ) {
  @@ -283,7 +283,7 @@
   return JK_FALSE;
   }
   
  -static int jk2_config_setPropertyString(jk_env_t *env, jk_config_t *cfg,
  +int jk2_config_setPropertyString(jk_env_t *env, jk_config_t *cfg,
   char *name, char *value)
   {
   jk_bean_t *mbean;
  @@ -299,7 +299,7 @@
   status=jk2_config_processBeanPropertyString(env, cfg, name, objName, propName 
);
   if( status!=JK_TRUE ) {
   /* Unknown properties ends up in our config, as 'unclaimed' or global */
  -jk2_config_setProperty( env, cfg, cfg-mbean, name, value );
  +cfg-setProperty( env, cfg, cfg-mbean, name, value );
   return status;
   }
   
  @@ -310,18 +310,18 @@
   
   if( mbean == NULL ) {
   /* Can't create it, save the value in our map */
  -jk2_config_setProperty( env, cfg, cfg-mbean, name, value );
  +cfg-setProperty( env, cfg, cfg-mbean, name, value );
   return JK_FALSE;
   }
   
   if( mbean-settings == NULL )
   jk2_map_default_create(env, mbean-settings, cfg-pool);
   
  -return jk2_config_setProperty( env, cfg, mbean, propName, value );
  +return cfg-setProperty( env, cfg, mbean, propName, value );
   }
   
   
  -static char *jk2_config_getString(jk_env_t *env, jk_config_t *conf,
  +char *jk2_config_getString(jk_env_t *env, jk_config_t *conf,
 const char *name, char *def)
   {
   char *val= conf-map-get( env, conf-map, name );
  @@ -330,7 +330,7 @@
   return val;
   }
   
  -static int jk2_config_getBool(jk_env_t *env, jk_config_t *conf,
  +int jk2_config_getBool(jk_env_t *env, jk_config_t *conf,
 const char *prop, const char *def)
   {
   char *val=jk2_config_getString( env, conf, prop, (char *)def );
  @@ -739,7 +739,7 @@
   
   if(env_value != NULL ) {
   int offset=0;
  -char *new_value = resultPool-alloc(env, resultPool, 
  +char *new_value = resultPool-calloc(env, resultPool, 
   (strlen(rc) + 
strlen(env_value)));
   if(!new_value) {
   break;
  @@ -749,6 +749,8 @@
   } else {
   strncpy(new_value, rc, env_start-rc);
   }
  +/* fprintf(stderr, XXX %s %s %s\n, new_value, env_value, env_end 
+ 1 ); */
  +
   strcat(new_value, env_value);
   strcat(new_value, env_end + 1);
offset= env_start - rc + strlen( env_value );
  
  
  

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




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

2002-04-11 Thread costin

costin  02/04/11 12:32:04

  Modified:jk/native2/common jk_config.c
  Log:
  Fix problem when ${var} was on the first position.
  
  NOTE: I changed the code to use the same syntax as ant and most java
  programs - i.e. ${} instead of $(). Since we change most of the config
  format, I hope we can change this too, it was really odd.
  
  Revision  ChangesPath
  1.9   +12 -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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_config.c   9 Apr 2002 21:00:38 -   1.8
  +++ jk_config.c   11 Apr 2002 19:32:04 -  1.9
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.8 $   *
  + * Version: $Revision: 1.9 $   *
***/
   
   #include jk_global.h
  @@ -266,6 +266,8 @@
*/
   val = jk2_config_replaceProperties(env, cfg-map, cfg-map-pool, val);
   
  +/* fprintf( stderr, config.setProperty2 %s %s %s \n, mbean-name, name, val 
); */
  +
   /** Used for future replacements
*/
   cfg-map-add( env, cfg-map, pname, val );
  @@ -291,8 +293,8 @@
   int status;
   char *objName=NULL;
   char *propName=NULL;
  -
  -/* fprintf( stderr, setPropertyString %s %s \n, name, value ); */
  +
  +/* fprintf( stderr, setPropertyString %s %s \n, name, value ); */
   
   status=jk2_config_processBeanPropertyString(env, cfg, name, objName, propName 
);
   if( status!=JK_TRUE ) {
  @@ -720,8 +722,8 @@
   rc = value;
   env_start = value;
   
  -while(env_start = strstr(env_start, $()) {
  -char *env_end = strstr(env_start, ));
  +while(env_start = strstr(env_start, ${)) {
  +char *env_end = strstr(env_start, });
   if( rec++  20 ) return rc;
   if(env_end) {
   char env_name[LENGTH_OF_LINE + 1] = ; 
  @@ -742,7 +744,11 @@
   if(!new_value) {
   break;
   }
  -strncpy(new_value, rc, env_start-rc);
  +if( env_start == rc ) {
  +new_value[0]='\0';
  +} else {
  +strncpy(new_value, rc, env_start-rc);
  +}
   strcat(new_value, env_value);
   strcat(new_value, env_end + 1);
offset= env_start - rc + strlen( env_value );
  
  
  

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




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

2002-03-25 Thread costin

costin  02/03/25 19:00:09

  Modified:jk/native2/common jk_config.c jk_logger_file.c
  Log:
  Store the name of the config file ( to write back modified info )
  
  Add the vargs method in logger.
  
  Revision  ChangesPath
  1.7   +8 -3  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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_config.c   25 Mar 2002 03:35:11 -  1.6
  +++ jk_config.c   26 Mar 2002 03:00:09 -  1.7
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.6 $   *
  + * Version: $Revision: 1.7 $   *
***/
   
   #include jk_global.h
  @@ -98,6 +98,8 @@
 config.setConfig(): Can't find config file %s, workerFile );
   return JK_FALSE;
   }
  +
  +cfg-file=workerFile;
   
   /** Read worker files
*/
  @@ -270,7 +272,10 @@
   
   /* env-l-jkLog( env, env-l, JK_LOG_INFO, config: set %s / %s / 
%s=%s\n, */
   /*mbean-name, name, pname, val); */
  - 
  +if( strcmp( name, name ) == 0 ) {
  +return JK_TRUE;
  +}
  +
   if(mbean-setAttribute)
   return mbean-setAttribute( env, mbean, name, val );
   return JK_FALSE;
  @@ -296,7 +301,7 @@
   return status;
   }
   
  -mbean=env-getMBean( env, objName );
  +mbean=env-getBean( env, objName );
   if( mbean==NULL ) {
   mbean=env-createBean( env, cfg-pool, objName );
   }
  
  
  
  1.16  +26 -10jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c
  
  Index: jk_logger_file.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- jk_logger_file.c  23 Mar 2002 17:23:15 -  1.15
  +++ jk_logger_file.c  26 Mar 2002 03:00:09 -  1.16
  @@ -59,7 +59,7 @@
* Description: Utility functions (mainly configuration)   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Henri Gomez [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.15 $   *
  + * Version: $Revision: 1.16 $   *
***/
   
   #include jk_env.h
  @@ -204,15 +204,16 @@
   }
   
   
  -static int jk2_logger_file_jkLog(jk_env_t *env, jk_logger_t *l,
  - const char *file,
  - int line,
  - int level,
  - const char *fmt, ...)
  +static int jk2_logger_file_jkVLog(jk_env_t *env, jk_logger_t *l,
  +  const char *file,
  +  int line,
  +  int level,
  +  char *fmt,
  +  va_list args)
   {
   int rc = 0;
   
  -if( !file || !fmt) {
  +if( !file || !args) {
   return -1;
   }
   
  @@ -226,7 +227,6 @@
   char buf[HUGE_BUFFER_SIZE];
   #endif
   char *f = (char *)(file + strlen(file) - 1);
  -va_list args;
   int used = 0;
   
   while(f != file  '\\' != *f  '/' != *f) {
  @@ -260,7 +260,6 @@
   return 0; /* [V] not sure what to return... */
   }
   
  -va_start(args, fmt);
   #ifdef WIN32
   rc = _vsnprintf(buf + used, HUGE_BUFFER_SIZE - used, fmt, args);
   #elif defined(NETWARE) /* until we get a vsnprintf function */
  @@ -268,7 +267,6 @@
   #else 
   rc = vsnprintf(buf + used, HUGE_BUFFER_SIZE - used, fmt, args);
   #endif
  -va_end(args);
   
   l-log(env, l, level, buf);
   #ifdef NETWARE
  @@ -280,6 +278,23 @@
   }
   
   
  +
  +static int jk2_logger_file_jkLog(jk_env_t *env, jk_logger_t *l,
  + const char *file,
  + int line,
  + int level,
  + const char *fmt, ...)
  +{
  +va_list args;
  +int rc;
  +
  +va_start(args, fmt);
  +rc=jk2_logger_file_jkVLog( env, l, file, line, level, 

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

2002-03-24 Thread costin

costin  02/03/24 19:35:11

  Modified:jk/native2/common jk_config.c jk_env.c
  Log:
  Moved the create method, use the more acurate method to extract the object
  type.
  
  Revision  ChangesPath
  1.6   +6 -54 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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_config.c   24 Mar 2002 19:24:26 -  1.5
  +++ jk_config.c   25 Mar 2002 03:35:11 -  1.6
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.5 $   *
  + * Version: $Revision: 1.6 $   *
***/
   
   #include jk_global.h
  @@ -229,58 +229,6 @@
   return JK_TRUE;
   }
   
  -/** Create a jk component using the name prefix
  - */
  -static jk_bean_t *jk2_config_createInstance( jk_env_t *env, jk_config_t *cfg,
  - char *objName )
  -{
  -jk_pool_t *workerPool;
  -jk_bean_t *w=NULL;
  -int i;
  -char *type=NULL;
  -
  -/** New object. Create it using the prefix
  - */
  -for( i=0; i env-_registry-size( env, env-_registry ) ; i++ ) {
  -char *factName=env-_registry-nameAt( env, env-_registry, i );
  -int len=strlen(factName );
  -
  -if( (strncmp( objName, factName, len) == 0) 
  -( (objName[len] == '.') ||
  -  (objName[len] == ':') ||
  -  (objName[len] == '_') ||
  -  (objName[len] == '\0') )  ) {
  -/* We found the factory. */
  -type=factName;
  -/* env-l-jkLog(env, env-l, JK_LOG_INFO, */
  -/*   Found %s  %s %s %d %d\n, type, 
objName, */
  -/*   factName, len, strncmp( objName, factName, 
len)); */
  -break;
  -}
  -}
  -if( type==NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_ERROR,
  -  config.createInstance(): Can't find type for %s \n, 
objName);
  -return NULL;
  -} 
  -
  -workerPool=cfg-pool-create(env, cfg-pool, HUGE_POOL_SIZE);
  -
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  config.createInstance(): Create [%s] %s\n, type, objName);
  -env-createInstance( env, workerPool, type, objName );
  -w=env-getMBean( env, objName );
  -if( w==NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_ERROR,
  -  config.createInstance(): Error creating  [%s] %s\n, 
objName, type);
  -return NULL;
  -}
  -if( w-settings == NULL )
  -jk2_map_default_create(env, w-settings, cfg-pool);
  -
  -return w;
  -}
  -
   
   /** Set a property on a bean. Call this when you know the bean.
   The name and values will be saved in the config tables.
  @@ -350,14 +298,18 @@
   
   mbean=env-getMBean( env, objName );
   if( mbean==NULL ) {
  -mbean=jk2_config_createInstance( env, cfg, objName );
  +mbean=env-createBean( env, cfg-pool, objName );
   }
  +
   if( mbean == NULL ) {
   /* Can't create it, save the value in our map */
   jk2_config_setProperty( env, cfg, cfg-mbean, name, value );
   return JK_FALSE;
   }
   
  +if( mbean-settings == NULL )
  +jk2_map_default_create(env, mbean-settings, cfg-pool);
  +
   return jk2_config_setProperty( env, cfg, mbean, propName, value );
   }
   
  
  
  
  1.15  +71 -3 jakarta-tomcat-connectors/jk/native2/common/jk_env.c
  
  Index: jk_env.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_env.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_env.c  24 Mar 2002 19:24:26 -  1.14
  +++ jk_env.c  25 Mar 2002 03:35:11 -  1.15
  @@ -102,11 +102,74 @@
 return (jk_env_objectFactory_t)env-_registry-get( env, env-_registry, type);
   }
   
  +/** Create a jk component, using only the name.
  + *  Now things are simpler - the 'type' is the prefix, separated by ':' - no
  + *  guessing involved.
  + */
  +static jk_bean_t *jk2_env_createBean( jk_env_t *env, jk_pool_t *pool, char *objName 
)
  +{
  +jk_bean_t *w=NULL;
  +int i;
  +char *type=NULL;
  +void *obj;
  +char *localName;
  +
  +localName=strchr( objName, ':' );
  +if( localName==NULL ) 

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

2002-03-23 Thread costin

costin  02/03/23 09:21:56

  Modified:jk/native2/common jk_config.c
  Log:
  - add experimental support for saving the config. That will enable 'autoconf'
  and runtime changes via ajp13/status worker. ( the problem was that even if
  you have autoconf, it is lost when you restart and that means you need
  tomcat up every time )
  
  - add support for [name], i.e. ini-style properties file. This allows a much
  cleaner and intuitive config format ( and it is still a familiar format, based
  on a common standard ).
  
  - store the 'original' properties ( with un-replaced $(prp) ), to be saved.
  
  - clean up the code that deals with processing the property format.
  
  - various fixes
  
  Revision  ChangesPath
  1.4   +298 -121  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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_config.c   19 Mar 2002 05:31:57 -  1.3
  +++ jk_config.c   23 Mar 2002 17:21:56 -  1.4
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.3 $   *
  + * Version: $Revision: 1.4 $   *
***/
   
   #include jk_global.h
  @@ -80,9 +80,8 @@
   
   /*   */
   
  -/* Set the file where the config will be read and
  - * ( in future ) stored.
  - *
  +/* Set the config file, read it. The property will also be
  +   used for storing modified properties.
*/
   static int jk2_config_setConfigFile( jk_env_t *env,
jk_config_t *cfg,
  @@ -130,6 +129,55 @@
   return JK_TRUE;
   }
   
  +/* Experimental. Dangerous. The file param will go away, for security
  +   reasons - it can save only in the original file.
  + */
  +static int jk2_config_saveConfig( jk_env_t *env,
  +  jk_config_t *cfg,
  +  jk_workerEnv_t *wEnv,
  +  char *workerFile)
  +{
  +FILE *fp;
  +char buf[LENGTH_OF_LINE + 1];
  +int i,j;
  +
  +fp= fopen(workerFile, w);
  +
  +if(fp==NULL)
  +return JK_FALSE;
  +
  +/* We'll save only the objects/properties that were set
  +   via config, and to the original 'string'. That keeps the config
  +   small ( withou redundant ) and close to the original. Comments
  +   will be saved/loaded later.
  +*/
  +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 || mbean-settings==NULL ) 
  +continue;
  +
  +fprintf( fp, [%s]\n, mbean-name );
  +
  +for( j=0; j  mbean-settings-size( env, mbean-settings ); j++ ) {
  +char *pname=mbean-settings-nameAt( env, mbean-settings, j);
  +/* Don't save redundant information */
  +if( strcmp( pname, name ) != NULL ) {
  +fprintf( fp, %s=%s\n,
  + pname,
  + mbean-settings-valueAt( env, mbean-settings, j));
  +}
  +}
  +fprintf( fp, \n );
  +}
  +
  +fclose(fp);
  +
  +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
  @@ -137,115 +185,147 @@
   
   Then set the property on the object that is found or
   constructed.
  +
  +No replacement or saving is done on the val - this is
  +a private method
   */
  -static int jk2_config_setBeanPropertyString( jk_env_t *env,
  - jk_config_t *cfg,
  - char *name, char *val)
  +
  +
  +static int jk2_config_processBeanPropertyString( jk_env_t *env,
  + jk_config_t *cfg,
  + char *propertyString,
  + char **objName, char 
**propertyName )
   {
   jk_bean_t *w = NULL;
   char *type=NULL;
  -char *objName= cfg-pool-pstrdup( env, cfg-pool, name );
  -char *propName=NULL;
   char *dot=0;
   int i;
   char **comp;
   int nrComp;
  +char 

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

2002-03-18 Thread costin

costin  02/03/18 10:26:15

  Added:   jk/native2/common jk_config.c
  Log:
  The initial jk_config implementation.
  
  Based on code from jk_map ( reading config file from properties ), jk_workerEnv
  ( setting properties of various components - abstracted using jk_bean )
  
  Revision  ChangesPath
  1.1  jakarta-tomcat-connectors/jk/native2/common/jk_config.c
  
  Index: jk_config.c
  ===
  /* = *
   *   *
   * The Apache Software License,  Version 1.1 *
   *   *
   *  Copyright (c) 1999-2001 The Apache Software Foundation.  *
   *   All rights reserved.*
   *   *
   * = *
   *   *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *   *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *notice, this list of conditions and the following disclaimer.  *
   *   *
   * 2. Redistributions  in binary  form  must  reproduce the  above copyright *
   *notice,  this list of conditions  and the following  disclaimer in the *
   *documentation and/or other materials provided with the distribution.   *
   *   *
   * 3. The end-user documentation  included with the redistribution,  if any, *
   *must include the following acknowlegement: *
   *   *
   *   This product includes  software developed  by the Apache  Software *
   *Foundation http://www.apache.org/.  *
   *   *
   *Alternately, this acknowlegement may appear in the software itself, if *
   *and wherever such third-party acknowlegements normally appear. *
   *   *
   * 4. The names  The  Jakarta  Project,  Jk,  and  Apache  Software *
   *Foundation  must not be used  to endorse or promote  products derived *
   *from this  software without  prior  written  permission.  For  written *
   *permission, please contact [EMAIL PROTECTED].*
   *   *
   * 5. Products derived from this software may not be called Apache nor may *
   *Apache appear in their names without prior written permission of the *
   *Apache Software Foundation.*
   *   *
   * THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES *
   * INCLUDING, BUT NOT LIMITED TO,  THE IMPLIED WARRANTIES OF MERCHANTABILITY *
   * AND FITNESS FOR  A PARTICULAR PURPOSE  ARE DISCLAIMED.  IN NO EVENT SHALL *
   * THE APACHE  SOFTWARE  FOUNDATION OR  ITS CONTRIBUTORS  BE LIABLE  FOR ANY *
   * DIRECT,  INDIRECT,   INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL *
   * DAMAGES (INCLUDING,  BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE GOODS *
   * OR SERVICES;  LOSS OF USE,  DATA,  OR PROFITS;  OR BUSINESS INTERRUPTION) *
   * HOWEVER CAUSED AND  ON ANY  THEORY  OF  LIABILITY,  WHETHER IN  CONTRACT, *
   * STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
   * ANY  WAY  OUT OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF  ADVISED  OF THE *
   * POSSIBILITY OF SUCH DAMAGE.   *
   *   *
   * = *
   *   *
   * This software  consists of voluntary  contributions made  by many indivi- *
   * duals on behalf of the  Apache Software Foundation.  For more information *
   * on the Apache Software Foundation, please see http://www.apache.org/.   *
   *   *
   * 

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

2002-03-18 Thread costin

costin  02/03/18 20:53:40

  Modified:jk/native2/common jk_config.c jk_logger_file.c jk_map.c
jk_pool.c
  Log:
  - logger.file property will set the file and open it ( and close the previous one).
  
  - fix ending in pstrdup()
  
  Revision  ChangesPath
  1.2   +2 -2  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_config.c   18 Mar 2002 18:26:15 -  1.1
  +++ jk_config.c   19 Mar 2002 04:53:40 -  1.2
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose config object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.1 $   *
  + * Version: $Revision: 1.2 $   *
***/
   
   #include jk_global.h
  @@ -247,7 +247,7 @@
   if( w != NULL ) {
   /* If we have an object with that name, set the prop */
   env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  Setting %s %s %s\n, objName, propName, val);
  +  Setting %s %s=%s\n, objName, propName, val);
   
   if( w-setAttribute != NULL )
   return w-setAttribute( env, w, propName, val );
  
  
  
  1.13  +15 -9 jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c
  
  Index: jk_logger_file.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_logger_file.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_logger_file.c  18 Mar 2002 18:38:39 -  1.12
  +++ jk_logger_file.c  19 Mar 2002 04:53:40 -  1.13
  @@ -59,7 +59,7 @@
* Description: Utility functions (mainly configuration)   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Henri Gomez [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.12 $   *
  + * Version: $Revision: 1.13 $   *
***/
   
   #include jk_env.h
  @@ -150,6 +150,11 @@
   char *value=valueP;
   if( strcmp( name, name )==0 ) {
   _this-name=(char *)value;
  +} else if( strcmp( name, file )==0 ) {
  +_this-name=(char *)value;
  +/* Set the file imediately */
  +jk2_logger_file_init(env, (jk_logger_t *)mbean-object );
  +
   } else if( strcmp( name, timeFormat )==0 ) {
   jk2_logger_file_logFmt = value;
   } else if( strcmp( name, level )==0 ) {
  @@ -164,25 +169,24 @@
   
   static int jk2_logger_file_init(jk_env_t *env,jk_logger_t *_this )
   {
  -FILE *f;
  +FILE *oldF=(FILE *)_this-logger_private;
  +FILE *f=NULL;
   
   if( _this-name==NULL )
   _this-name=mod_jk.log;
   
  -if( _this-level == 0 )
  -_this-level=JK_LOG_ERROR_LEVEL;
  -
  -if( jk2_logger_file_logFmt==NULL ) {
  -jk2_logger_file_logFmt = JK_TIME_FORMAT;
  -}
  -
   f = fopen(_this-name, a+);
   if(f==NULL) {
   _this-jkLog(env, _this,JK_LOG_ERROR,
Can't open log file %s\n, _this-name );
   return JK_FALSE;
   }
  +_this-jkLog(env, _this,JK_LOG_ERROR,
  + Initilizing log file %s\n, _this-name );
   _this-logger_private = f;
  +if( oldF!=NULL ) {
  +fclose( oldF );
  +}
   return JK_TRUE;
   }
   
  @@ -290,6 +294,8 @@
   l-init =jk2_logger_file_init;
   l-jkLog = jk2_logger_file_jkLog;
   l-level=JK_LOG_ERROR_LEVEL;
  +jk2_logger_file_logFmt = JK_TIME_FORMAT;
  +
   
   result-object=l;
   l-mbean=result;
  
  
  
  1.16  +1 -2  jakarta-tomcat-connectors/jk/native2/common/jk_map.c
  
  Index: jk_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_map.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- jk_map.c  18 Mar 2002 18:42:50 -  1.15
  +++ jk_map.c  19 Mar 2002 04:53:40 -  1.16
  @@ -58,7 +58,7 @@
   /***
* Description: General purpose map object *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 

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

2002-03-18 Thread costin

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  ChangesPath
  1.3   +41 -72jakarta-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 -  1.2
  +++ jk_config.c   19 Mar 2002 05:31:57 -  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; icfg-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,
  -