costin      02/04/11 12:34:30

  Modified:    jk/native2/common jk_workerEnv.c
  Log:
  Channel initialization.
  
  If no worker is found we create a default ajp13 worker.
  
  Revision  Changes    Path
  1.26      +70 -4     jakarta-tomcat-connectors/jk/native2/common/jk_workerEnv.c
  
  Index: jk_workerEnv.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_workerEnv.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- jk_workerEnv.c    10 Apr 2002 23:48:33 -0000      1.25
  +++ jk_workerEnv.c    11 Apr 2002 19:34:30 -0000      1.26
  @@ -59,7 +59,7 @@
    * Description: Workers controller                                         *
    * Author:      Gal Shachor <[EMAIL PROTECTED]>                           *
    * Author:      Henri Gomez <[EMAIL PROTECTED]>                               *
  - * Version:     $Revision: 1.25 $                                           *
  + * Version:     $Revision: 1.26 $                                           *
    ***************************************************************************/
   
   #include "jk_env.h"
  @@ -166,9 +166,9 @@
                                        jk_workerEnv_t *wEnv)
   {
       int i;
  -    char **wlist=wEnv->worker_list;
   
       for( i=0; i< wEnv->worker_map->size( env, wEnv->worker_map ); i++ ) {
  +
           char *name= wEnv->worker_map->nameAt( env, wEnv->worker_map, i );
           jk_worker_t *w= wEnv->worker_map->valueAt( env, wEnv->worker_map, i );
           int err;
  @@ -188,6 +188,59 @@
       return JK_TRUE;
   }
   
  +static int jk2_workerEnv_initChannel(jk_env_t *env,
  +                                     jk_workerEnv_t *wEnv, jk_channel_t *ch)
  +{
  +    int rc=JK_TRUE;
  +    
  +    ch->workerEnv=wEnv;
  +    
  +    if( ch->init != NULL ) {
  +        rc=ch->init(env, ch);
  +        
  +        if(rc!=JK_TRUE) {
  +            env->l->jkLog(env, env->l, JK_LOG_ERROR,
  +                          "workerEnv.initChannel() init failed for %s\n", 
  +                          ch->mbean->name); 
  +        }
  +    }
  +    
  +    if( ch->workerName != NULL ) {
  +        jk_worker_t *w=wEnv->worker_map->get( env, wEnv->worker_map, ch->workerName 
);
  +        ch->worker=w;
  +    }
  +
  +    /* If a worker is not defined ( yet ) for the channel, define a default one ( 
ajp13 )*/
  +    if( ch->worker == NULL ) {
  +        jk_bean_t *jkb;
  +        
  +        env->l->jkLog(env, env->l, JK_LOG_INFO,
  +                      "workerEnv.initChannel(): default worker ajp13:%s\n", 
ch->mbean->localName );
  +        
  +        jkb=env->createBean2(env, ch->mbean->pool, "worker.ajp13", 
ch->mbean->localName );
  +        ch->worker=jkb->object;
  +        ch->worker->channelName=ch->mbean->name;
  +        ch->worker->channel=ch;
  +            
  +        /* XXX Set additional parameters - use defaults otherwise */
  +    }
  +    return rc;
  +}
  +
  +static int jk2_workerEnv_initChannels(jk_env_t *env,
  +                                      jk_workerEnv_t *wEnv)
  +{
  +    int i;
  +
  +    for( i=0; i< wEnv->channel_map->size( env, wEnv->channel_map ); i++ ) {
  +
  +        char *name= wEnv->channel_map->nameAt( env, wEnv->channel_map, i );
  +        jk_channel_t *ch= wEnv->channel_map->valueAt( env, wEnv->channel_map, i );
  +        jk2_workerEnv_initChannel( env, wEnv, ch );
  +    }
  +    return JK_TRUE;
  +}
  +
   
   static void jk2_workerEnv_initHandlers(jk_env_t *env, jk_workerEnv_t *wEnv)
   {
  @@ -212,7 +265,6 @@
       }
   }
   
  -
   static void jk2_workerEnv_registerHandler(jk_env_t *env, jk_workerEnv_t *wEnv,
                                             jk_handler_t *handler)
   {
  @@ -239,9 +291,10 @@
       if(  configFile == NULL ) {
           wEnv->config->setPropertyString( env, wEnv->config,
                                            "config.file",
  -                                         "$(serverRoot)/conf/jk2.properties" );
  +                                         "${serverRoot}/conf/workers2.properties" );
       }
       
  +    jk2_workerEnv_initChannels( env, wEnv );
       jk2_workerEnv_initWorkers( env, wEnv );
       jk2_workerEnv_initHandlers( env, wEnv );
   
  @@ -392,6 +445,16 @@
       
   }
   
  +static int jk2_workerEnv_addChannel(jk_env_t *env, jk_workerEnv_t *wEnv,
  +                                    jk_channel_t *w) 
  +{
  +    int err=JK_TRUE;
  +
  +    wEnv->channel_map->put(env, wEnv->channel_map, w->mbean->name, w, NULL);
  +            
  +    return JK_TRUE;
  +}
  +
   
   static int jk2_workerEnv_addWorker(jk_env_t *env, jk_workerEnv_t *wEnv,
                                      jk_worker_t *w) 
  @@ -543,6 +606,7 @@
       jk2_map_default_create(env, &wEnv->envvars, pool);
   
       jk2_map_default_create(env,&wEnv->worker_map, wEnv->pool);
  +    jk2_map_default_create(env,&wEnv->channel_map, wEnv->pool);
   
       jkb=env->createBean2(env, wEnv->pool,"uriMap", "");
   
  @@ -575,6 +639,8 @@
       wEnv->init=&jk2_workerEnv_init;
       wEnv->close=&jk2_workerEnv_close;
       wEnv->addWorker=&jk2_workerEnv_addWorker;
  +    wEnv->addChannel=&jk2_workerEnv_addChannel;
  +    wEnv->initChannel=&jk2_workerEnv_initChannel;
       wEnv->registerHandler=&jk2_workerEnv_registerHandler;
       wEnv->processCallbacks=&jk2_workerEnv_processCallbacks;
       wEnv->dispatch=&jk2_workerEnv_dispatch;
  
  
  

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

Reply via email to