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 2002/03/01 01:45:59 UTC

cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache2 mod_jk2.c

costin      02/02/28 16:45:58

  Modified:    jk/native2/common jk_registry.h jk_uriMap.c
                        jk_worker_status.c
               jk/native2/include jk_uriEnv.h
               jk/native2/server/apache13 mod_jk2.c
               jk/native2/server/apache2 mod_jk2.c
  Added:       jk/native2/common jk_uriEnv.c
  Log:
  Move the uriEnv code in a separate object.
  
  Fix jk2 for apache1.3 ( again, compiles - I haven't tested it yet ).
  
  Few more fixes.
  
  Revision  Changes    Path
  1.8       +8 -1      jakarta-tomcat-connectors/jk/native2/common/jk_registry.h
  
  Index: jk_registry.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_registry.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jk_registry.h	21 Feb 2002 11:12:11 -0000	1.7
  +++ jk_registry.h	1 Mar 2002 00:45:58 -0000	1.8
  @@ -62,7 +62,7 @@
   
   /***************************************************************************
    * Description: Worker list                                                *
  - * Version:     $Revision: 1.7 $                                           *
  + * Version:     $Revision: 1.8 $                                           *
    ***************************************************************************/
   
   /** Static declarations for all 'hardcoded' modules. This is a hack, 
  @@ -154,3 +154,10 @@
   int JK_METHOD jk2_handler_response_factory(jk_env_t *env, jk_pool_t *pool,
                                              void **result,
                                              const char *type, const char *name);
  +
  +int JK_METHOD jk2_uriMap_factory(jk_env_t *env, jk_pool_t *pool, void **result,
  +                                 const char *type, const char *name);
  +
  +int JK_METHOD jk2_uriEnv_factory(jk_env_t *env, jk_pool_t *pool, void **result,
  +                                 const char *type, const char *name);
  +
  
  
  
  1.16      +13 -146   jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c
  
  Index: jk_uriMap.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_uriMap.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- jk_uriMap.c	28 Feb 2002 23:07:01 -0000	1.15
  +++ jk_uriMap.c	1 Mar 2002 00:45:58 -0000	1.16
  @@ -67,19 +67,13 @@
    * servlet container.                                                      
    *                                                                         
    * Author:      Gal Shachor <sh...@il.ibm.com>                           
  - * Version:     $Revision: 1.15 $                                           
  + * Version:     $Revision: 1.16 $                                           
    */
   
   #include "jk_pool.h"
   #include "jk_env.h"
   #include "jk_uriMap.h"
  -
  -int JK_METHOD jk2_uriMap_factory(jk_env_t *env, jk_pool_t *pool, void **result,
  -                                 const char *type, const char *name);
  -
  -static int jk2_uriMap_init(jk_env_t *env, jk_uriMap_t *_this,
  -                           jk_workerEnv_t *workerEnv,
  -                           jk_map_t *init_data);
  +#include "jk_registry.h"
   
   static jk_uriEnv_t *jk2_uriMap_addMapping(jk_env_t *env, jk_uriMap_t *_this,
                                             const char *vhost,
  @@ -174,50 +168,21 @@
       return JK_TRUE;
   }
   
  -/* -------------------- XXX Move to uriEnv.c -------------------- */
  -static jk_uriEnv_t *jk2_uriEnv_setProperty(jk_env_t *env,
  -                                           jk_uriEnv_t *uriEnv,
  -                                           const char *nameParam,
  -                                           const char *valueParam)
  -{
  -    char *name=uriEnv->pool->pstrdup(env,uriEnv->pool, nameParam);
  -    char *val=uriEnv->pool->pstrdup(env,uriEnv->pool, valueParam);
  -
  -    uriEnv->properties->add( env ,uriEnv->properties,
  -                             name, val );
  -    if( strcmp("worker", name) == 0 ) {
  -        uriEnv->workerName=val;
  -    }
  -    
  -}
  -
  -
   static jk_uriEnv_t *jk2_uriEnv_createUriEnv(jk_env_t *env,
                                               jk_uriMap_t *uriMap,
  -                                            const char *vhost,
  -                                            const char *path) 
  +                                            char *vhost,
  +                                            char *path) 
   {
  -    jk_pool_t *uriPool;
       int err;
       jk_uriEnv_t *uriEnv;
  -    jk_workerEnv_t *wEnv=uriMap->workerEnv;
   
  -    /** Will be discarded/flushed on reload */
  -    /** XXX Group by webapp */
  -    uriPool=(jk_pool_t *)uriMap->pool->create( env, uriMap->pool,
  -                                                 HUGE_POOL_SIZE);
  +    jk2_uriEnv_factory( env, uriMap->pool, (void *)&uriEnv, "uriEnv", NULL );
   
  -    uriEnv=(jk_uriEnv_t *)uriMap->pool->calloc(env, uriPool,
  -                                              sizeof(jk_uriEnv_t));
  -    
  -    uriEnv->setProperty=&jk2_uriEnv_setProperty;
  -    uriEnv->pool=uriPool;
  -    
       uriEnv->workerEnv=uriMap->workerEnv;
  -    jk2_map_default_create( env, &uriEnv->properties, uriPool );
  -
  -    uriEnv->uri=uriPool->pstrdup(env, uriPool, path);
  -    uriEnv->virtual=uriPool->pstrdup(env, uriPool, vhost);
  +    
  +    uriEnv->setProperty( env, uriEnv, "uri", path );
  +    uriEnv->setProperty( env, uriEnv, "vhost", vhost );
  +    uriEnv->init( env, uriEnv );
   
       /* Register it */
       /* make sure we have space */
  @@ -234,106 +199,8 @@
   }
   
   
  -static jk_uriEnv_t *jk2_uriMap_prepareUriEnv(jk_env_t *env, jk_uriMap_t *_this,
  -                                             jk_uriEnv_t *uwr,
  -                                             char *vhost, char *uri, char *worker)
  -{
  -    int err;
  -    char *asterisk;
  -    
  -    if ('/' != uri[0]) {
  -        /*
  -         * JFC: please check...
  -         * Not sure what to do, but I try to prevent problems.
  -         * I have fixed jk_mount_context() in apaches/mod_jk2.c so we should
  -         * not arrive here when using Apache.
  -         */
  -        env->l->jkLog(env, env->l, JK_LOG_ERROR,
  -                      "uriMap.addMapping() context must start with '/' in %s\n",
  -                      uri);
  -        return NULL;
  -    }
  -
  -    asterisk = strchr(uri, '*');
  -
  -    // set the mapping type
  -    if (!asterisk) {
  -        /* Something like:  JkMount /login/j_security_check ajp13 */
  -        uwr->prefix      = uri;
  -        uwr->prefix_len  =strlen( uwr->prefix );
  -        uwr->suffix      = NULL;
  -        uwr->match_type  = MATCH_TYPE_EXACT;
  -        if( _this->debug > 0 ) {
  -            env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                          "uriMap.addMapping() exact mapping %s=%s was added\n",
  -                          uri, worker);
  -        }
  -        return uwr;
  -    }
  -
  -    /*
  -     * Now, lets check that the pattern is /context/STAR.suffix
  -     * or /context/STAR
  -     * we need to have a '/' then a '*' and the a '.' or a
  -     * '/' then a '*'
  -     */
  -    asterisk--;
  -    if ('/' == asterisk[0]) {
  -        if ('.' == asterisk[2]) {
  -            /* suffix rule: /foo/bar/STAR.extension */
  -            asterisk[1]      = '\0';
  -            asterisk[2]      = '\0';
  -            uwr->prefix      = uri;
  -            uwr->prefix_len  =strlen( uwr->prefix );
  -            uwr->suffix      = asterisk + 3;
  -            uwr->match_type  = MATCH_TYPE_SUFFIX;
  -            if( _this->debug > 0 ) {
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                      "uriMap.addMapping() suffix mapping %s.%s=%s was added\n",
  -                              uri, asterisk + 3, worker);
  -            }
  -        } else if ('\0' != asterisk[2]) {
  -            /* general suffix rule /foo/bar/STARextraData */
  -            asterisk[1] = '\0';
  -            uwr->suffix  = asterisk + 2;
  -            uwr->prefix  = uri;
  -            uwr->prefix_len  =strlen( uwr->prefix );
  -            uwr->match_type = MATCH_TYPE_GENERAL_SUFFIX;
  -            if( _this->debug > 0 ) {
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                         "uriMap.addMapping() general suffix mapping %s.%s=%s\n",
  -                              uri, asterisk + 2, worker);
  -            }
  -        } else {
  -            /* context based /foo/bar/STAR  */
  -            asterisk[1]      = '\0';
  -            uwr->suffix      = NULL;
  -            uwr->prefix      = uri;
  -            uwr->prefix_len  =strlen( uwr->prefix );
  -            uwr->match_type  = MATCH_TYPE_CONTEXT;
  -            if( _this->debug > 0 ) {
  -                env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                              "uriMap.addMapping() prefix mapping %s=%s\n",
  -                              uri, worker);
  -            }
  -        }
  -    } else {
  -        /* Something like : JkMount /servlets/exampl* ajp13 */
  -        /* Is this valid ??? */
  -        uwr->prefix      = uri;
  -        uwr->prefix_len  =strlen( uwr->prefix );
  -        uwr->suffix      = NULL;
  -        uwr->match_type  = MATCH_TYPE_EXACT;
  -        if( _this->debug > 0 ) {
  -            env->l->jkLog(env, env->l, JK_LOG_INFO,
  -                     "uriMap.addMapping() prefix mapping2 %s=%s\n",
  -                          uri, worker);
  -        }
  -    }
  -
  -    return uwr;
  -}
  -
  +/** XXX remove
  + */
   static jk_uriEnv_t *jk2_uriMap_addMapping(jk_env_t *env, jk_uriMap_t *_this,
                                             const char *vhost,
                                             const char *puri, 
  @@ -351,7 +218,7 @@
   
       uwr->setProperty( env, uwr, "worker", pworker );
   
  -    return jk2_uriMap_prepareUriEnv(env, _this, uwr, vhost, uwr->uri, worker);
  +    return uwr;
   }
   
   static int jk2_uriMap_init(jk_env_t *env, jk_uriMap_t *_this,
  @@ -559,7 +426,7 @@
                   }
               }
           } else /* MATCH_TYPE_SUFFIX */ {
  -            if( suffix != NULL ) {
  +            if( uwr->suffix!=NULL && suffix != NULL ) {
                   /* for WinXX, fix the JsP != jsp problems */
   #ifdef WIN32                        
                   if(0 == strcasecmp(suffix, uwr->suffix))  {
  
  
  
  1.7       +7 -3      jakarta-tomcat-connectors/jk/native2/common/jk_worker_status.c
  
  Index: jk_worker_status.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_status.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_worker_status.c	28 Feb 2002 23:07:22 -0000	1.6
  +++ jk_worker_status.c	1 Mar 2002 00:45:58 -0000	1.7
  @@ -172,9 +172,13 @@
       for( i=0; i< map->size( env, map ) ; i++ ) {
           char *name=map->nameAt( env, map, i );
           char *value=(char *)map->valueAt( env, map,i );
  -
  -        jk2_printf(env, buf, "<tr><td>%s</td><td>%s</td></tr>", name,
  -                  value);
  +        /* Don't display worker properties or uris, those are displayed separately
  +           for each worker */
  +/*         if( strncmp( name, "worker.", 7 ) !=0 && */
  +/*             name[0] != '/' ) { */
  +            jk2_printf(env, buf, "<tr><td>%s</td><td>%s</td></tr>", name,
  +                       value);
  +/*         } */
       }
       jk2_printf(env, buf, "</table>\n");
   
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/common/jk_uriEnv.c
  
  Index: jk_uriEnv.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 <ap...@apache.org>.                        *
   *                                                                           *
   * 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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  /**
   * Location properties. UriEnv can be:
   *                                                                 
   * Exact Context -> /exact/uri=worker e.g. /examples/do[STAR]=ajp12
   * Context Based -> /context/[STAR]=worker e.g. /examples/[STAR]=ajp12
   * Context and suffix ->/context/[STAR].suffix=worker e.g. /examples/[STAR].jsp=ajp12
   *                                                                         
   */
  
  #include "jk_pool.h"
  #include "jk_env.h"
  #include "jk_uriMap.h"
  #include "jk_registry.h"
  
  static int jk2_uriEnv_setProperty(jk_env_t *env,
                                    jk_uriEnv_t *uriEnv,
                                    const char *nameParam,
                                    char *valueParam)
  {
      char *name=uriEnv->pool->pstrdup(env,uriEnv->pool, nameParam);
      char *val=uriEnv->pool->pstrdup(env,uriEnv->pool, valueParam);
  
      uriEnv->properties->add( env ,uriEnv->properties,
                               name, val );
      if( strcmp("worker", name) == 0 ) {
          uriEnv->workerName=val;
      }
      if( strcmp("debug", name) == 0 ) {
          uriEnv->debug=atoi( val );
      }
      if( strcmp("uri", name) == 0 ) {
          if( val==NULL )
              uriEnv->uri=NULL;
          else
              uriEnv->uri=uriEnv->pool->pstrdup(env, uriEnv->pool, val);
      }
      if( strcmp("vhost", name) == 0 ) {
          if( val==NULL )
              uriEnv->virtual=NULL;
          else
              uriEnv->virtual=uriEnv->pool->pstrdup(env, uriEnv->pool, val);
      }
  
      return JK_TRUE;
  }
  
  
  static int jk2_uriEnv_init(jk_env_t *env, jk_uriEnv_t *uriEnv)
  {
      int err;
      char *asterisk;
      char *uri=uriEnv->uri;
  
      if( uri==NULL ) 
          return JK_FALSE;
      
      if ('/' != uri[0]) {
          /*
           * JFC: please check...
           * Not sure what to do, but I try to prevent problems.
           * I have fixed jk_mount_context() in apaches/mod_jk2.c so we should
           * not arrive here when using Apache.
           */
          env->l->jkLog(env, env->l, JK_LOG_ERROR,
                        "uriMap.addMapping() context must start with '/' in %s\n",
                        uri);
          return JK_FALSE;
      }
  
      asterisk = strchr(uri, '*');
  
      // set the mapping type
      if (!asterisk) {
          /* Something like:  JkMount /login/j_security_check ajp13 */
          uriEnv->prefix      = uri;
          uriEnv->prefix_len  =strlen( uriEnv->prefix );
          uriEnv->suffix      = NULL;
          uriEnv->match_type  = MATCH_TYPE_EXACT;
          if( uriEnv->debug > 0 ) {
              env->l->jkLog(env, env->l, JK_LOG_INFO,
                            "uriMap.addMapping() exact mapping %s=%s was added\n",
                            uri, uriEnv->workerName);
          }
          return JK_TRUE;
      }
  
      /*
       * Now, lets check that the pattern is /context/STAR.suffix
       * or /context/STAR
       * we need to have a '/' then a '*' and the a '.' or a
       * '/' then a '*'
       */
      asterisk--;
      if ('/' == asterisk[0]) {
          if ('.' == asterisk[2]) {
              /* suffix rule: /foo/bar/STAR.extension */
              asterisk[1]      = '\0';
              asterisk[2]      = '\0';
              uriEnv->prefix      = uri;
              uriEnv->prefix_len  =strlen( uriEnv->prefix );
              uriEnv->suffix      = asterisk + 3;
              uriEnv->match_type  = MATCH_TYPE_SUFFIX;
              if( uriEnv->debug > 0 ) {
                  env->l->jkLog(env, env->l, JK_LOG_INFO,
                        "uriMap.addMapping() suffix mapping %s.%s=%s was added\n",
                                uri, asterisk + 3, uriEnv->worker);
              }
          } else if ('\0' != asterisk[2]) {
              /* general suffix rule /foo/bar/STARextraData */
              asterisk[1] = '\0';
              uriEnv->suffix  = asterisk + 2;
              uriEnv->prefix  = uri;
              uriEnv->prefix_len  =strlen( uriEnv->prefix );
              uriEnv->match_type = MATCH_TYPE_GENERAL_SUFFIX;
              if( uriEnv->debug > 0 ) {
                  env->l->jkLog(env, env->l, JK_LOG_INFO,
                           "uriMap.addMapping() general suffix mapping %s.%s=%s\n",
                                uri, asterisk + 2, uriEnv->worker);
              }
          } else {
              /* context based /foo/bar/STAR  */
              asterisk[1]      = '\0';
              uriEnv->suffix      = NULL;
              uriEnv->prefix      = uri;
              uriEnv->prefix_len  =strlen( uriEnv->prefix );
              uriEnv->match_type  = MATCH_TYPE_CONTEXT;
              if( uriEnv->debug > 0 ) {
                  env->l->jkLog(env, env->l, JK_LOG_INFO,
                                "uriMap.addMapping() prefix mapping %s=%s\n",
                                uri, uriEnv->worker);
              }
          }
      } else {
          /* Something like : JkMount /servlets/exampl* ajp13 */
          /* Is this valid ??? */
          uriEnv->prefix      = uri;
          uriEnv->prefix_len  =strlen( uriEnv->prefix );
          uriEnv->suffix      = NULL;
          uriEnv->match_type  = MATCH_TYPE_EXACT;
          if( uriEnv->debug > 0 ) {
              env->l->jkLog(env, env->l, JK_LOG_INFO,
                       "uriMap.addMapping() prefix mapping2 %s=%s\n",
                            uri, uriEnv->worker);
          }
      }
  
      return JK_TRUE;
  }
  
  
  int JK_METHOD jk2_uriEnv_factory(jk_env_t *env, jk_pool_t *pool, void **result,
                                   const char *type, const char *name)
  {
      jk_pool_t *uriPool;
      int err;
      jk_uriEnv_t *uriEnv;
  
      uriPool=(jk_pool_t *)pool->create( env, pool,
                                         HUGE_POOL_SIZE);
  
      uriEnv=(jk_uriEnv_t *)pool->calloc(env, uriPool,
                                         sizeof(jk_uriEnv_t));
      
      uriEnv->pool=uriPool;
      
      jk2_map_default_create( env, &uriEnv->properties, uriPool );
  
      uriEnv->setProperty=&jk2_uriEnv_setProperty;
      uriEnv->init=&jk2_uriEnv_init;
      *result=uriEnv;
  
      return JK_TRUE;
  }
  
  
  
  
  1.7       +3 -0      jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h
  
  Index: jk_uriEnv.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_uriEnv.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_uriEnv.h	28 Feb 2002 22:04:31 -0000	1.6
  +++ jk_uriEnv.h	1 Mar 2002 00:45:58 -0000	1.7
  @@ -180,6 +180,9 @@
       char **(*getPropertyNames)( struct jk_env *env,
                                   struct jk_uriEnv *_this );
       
  +
  +    int (*init)( struct jk_env *env, struct jk_uriEnv *_this);
  +
   };
   
   
  
  
  
  1.3       +54 -235   jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mod_jk2.c	25 Feb 2002 22:44:36 -0000	1.2
  +++ mod_jk2.c	1 Mar 2002 00:45:58 -0000	1.3
  @@ -59,7 +59,7 @@
    * Description: Apache 1.3 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <sh...@il.ibm.com>                           *
    *                 Henri Gomez <hg...@slib.fr>                               *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   /*
  @@ -102,183 +102,36 @@
   
   
   /* ==================== Options setters ==================== */
  -
  -/*
  - * The JK2 module command processors. The options can be specified
  - * in a properties file or in httpd.conf, depending on user's taste.
  - *
  - * There is absolutely no difference from the point of view of jk,
  - * but apache config tools might prefer httpd.conf and the extra
  - * information included in the command descriptor. It also have
  - * a 'natural' feel, and is consistent with all other apache
  - * settings and modules. 
  - *
  - * Properties file are easier to parse/generate from java, and
  - * allow identical configuration for all servers. We should have
  - * code to generate the properties file or use the wire protocol,
  - * and make all those properties part of server.xml or jk's
  - * java-side configuration. This will give a 'natural' feel for
  - * those comfortable with the java side.
  - *
  - * The only exception is webapp definition, where in the near
  - * future you can expect a scalability difference between the
  - * 2 choices. If you have a large number of apps/vhosts you
  - * _should_ use the apache style, that makes use of the
  - * internal apache mapper ( known to scale to very large number
  - * of hosts ). The internal jk mapper uses linear search, ( will
  - * eventually use hash tables, when we add support for apr_hash ),
  - * and is nowhere near the apache mapper.
  - */
  -
  -/**
  - * In order to define a webapp you must add "Jk2Webapp" directive
  - * in a Location. 
  - *
  - * Example:
  - *   <VirtualHost foo.com>
  - *      <Location /examples>
  - *         Jk2Webapp worker ajp13
  - *      </Location>
  - *   </VirtualHost>
  - *
  - * This is the best way to define a webapplication in apache. It is
  - * scalable ( using apache native optimizations, you can have hundreds
  - * of hosts and thousands of webapplications ), 'natural' to any
  - * apache user.
  - */
  -static const char *jk2_setWebapp(cmd_parms *cmd, void *per_dir, 
  -                                const char *name, const char *val)
  -{
  -    jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)per_dir;
  -
  -    if( uriEnv->webapp == NULL ) {
  -        /* Do we know the url ? */
  -        uriEnv->webapp=workerEnv->createWebapp( workerEnv->globalEnv, workerEnv,
  -                                                NULL, cmd->path, NULL );
  -
  -        /* fprintf(stderr, "New webapp %p %p\n",uriEnv, uriEnv->webapp); */
  -    } else {
  -        /* fprintf(stderr, "Existing webapp %p\n",uriEnv->webapp); */
  -    }
  -
  -    if( strcmp( name, "worker") == 0 ) {
  -        /* XXX move to common in webapp->init */
  -        uriEnv->webapp->workerName=ap_pstrdup(cmd->pool, val);
  -    } else {
  -        /* Generic properties */
  -        uriEnv->webapp->properties->add( workerEnv->globalEnv,
  -                                         uriEnv->webapp->properties,
  -                                         ap_pstrdup(cmd->pool, name),
  -                                         ap_pstrdup(cmd->pool, val));
  -    }
  -    
  -    fprintf(stderr, "Jk2Webapp  %s %s \n",
  -            uriEnv->webapp->workerName, cmd->path);
  -
  -    return NULL;
  -}
  -
  -/**
  - * Associate a servlet to a <Location>. 
  - *
  - * Example:
  - *   <VirtualHost foo.com>
  - *      <Location /examples/servlet>
  - *         Jk2Servlet name servlet
  - *      </Location>
  - *   </VirtualHost>
  - */
  -static const char *jk2_setServlet(cmd_parms *cmd, void *per_dir, 
  -                                 const char *name, const char *val)
  -{
  -    jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)per_dir;
  -
  -    if( strcmp( name, "name") == 0 ) {
  -        /* XXX Move to webapp->init() */
  -        uriEnv->servlet=ap_pstrdup(cmd->pool, val);
  -    } else {
  -        /* Generic properties */
  -        uriEnv->properties->add( workerEnv->globalEnv, uriEnv->properties,
  -                                 ap_pstrdup(cmd->pool, name),
  -                                 ap_pstrdup(cmd->pool, val));
  -    }
  -    
  -    fprintf(stderr, "JkServlet %p %p %s %s \n",
  -            uriEnv, uriEnv->webapp, name, val);
  -
  -    return NULL;
  -}
  -
  -/** 
  - * Set jk options. Used to implement backward compatibility with jk1
  - *
  - * "JkFoo value" in jk1 is equivalent with a "foo=value" setting in
  - * workers.properties and "JkSet foo value" in jk2
  - *
  - * We are using a small trick to avoid duplicating the code ( the 'dummy'
  - * parm ). The values are validated and initalized in jk_init.
  - */
  -static const char *jk2_set1(cmd_parms *cmd, void *per_dir,
  -                            const char *value)
  -{
  -    server_rec *s = cmd->server;
  -    struct stat statbuf;
  -    char *oldv;
  -    int rc;
  -    jk_env_t *env;
  -
  -    jk_uriEnv_t *serverEnv=(jk_uriEnv_t *)
  -        ap_get_module_config(s->module_config, &jk2_module);
  -    jk_workerEnv_t *workerEnv = serverEnv->workerEnv;
  -    
  -    env=workerEnv->globalEnv;
  -
  -    if( cmd->info != NULL ) {
  -        workerEnv->setProperty( env, workerEnv, (char *)cmd->info, (char *)value );
  -    } else {
  -        /* ??? Maybe this is a single-option */
  -        workerEnv->setProperty( env, workerEnv, value, "On" );
  -    }
  -
  -    return NULL;
  -}
  -
  -
   /*
    * JkSet name value
    *
  - * Also used for backward compatiblity for: "JkEnv envvar envvalue" and
  - * "JkMount /context worker" ( using cmd->info trick ).
  + * Set jk options. Same as using workers.properties.
  + * Common properties: see workers.properties documentation
    */
   static const char *jk2_set2(cmd_parms *cmd,void *per_dir,
  -                           const char *name, const char *value)
  +                            const char *name,  char *value)
   {
       server_rec *s = cmd->server;
  -    struct stat statbuf;
  -    char *oldv;
  -    int rc;
  -    jk_env_t *env;
  -    char *type=(char *)cmd->info;
  -
       jk_uriEnv_t *serverEnv=(jk_uriEnv_t *)
           ap_get_module_config(s->module_config, &jk2_module);
  +    
       jk_workerEnv_t *workerEnv = serverEnv->workerEnv;
  +    char *type=(char *)cmd->info;
  +    jk_env_t *env=workerEnv->globalEnv;
  +    int rc;
       
  -    env=workerEnv->globalEnv;
  -
       if( type==NULL || type[0]=='\0') {
           /* Generic Jk2Set foo bar */
  -        workerEnv->setProperty(env, workerEnv, name, value);
  +        workerEnv->setProperty( env, workerEnv, name, value );
       } else if( strcmp(type, "env")==0) {
           workerEnv->envvars_in_use = JK_TRUE;
           workerEnv->envvars->put(env, workerEnv->envvars,
                                   ap_pstrdup(cmd->pool,name),
                                   ap_pstrdup(cmd->pool,value),
                                   NULL);
  -        fprintf( stderr, "set2.env %s %s\n", name, value );
       } else if( strcmp(type, "mount")==0) {
           if (name[0] !='/') return "Context must start with /";
  -        workerEnv->setProperty(  env, workerEnv, name, value );
  +        workerEnv->setProperty( env, workerEnv, name, value );
       } else {
           fprintf( stderr, "set2 error %s %s %s ", type, name, value );
       }
  @@ -286,53 +139,41 @@
       return NULL;
   }
   
  -/*
  - * JkWorker workerName workerProperty value
  +/**
  + * Set a property associated with a URI, using native <Location> 
  + * directives.
  + *
  + * This is used if you want to use the native mapping and
  + * integrate better into apache.
  + *
  + * Same behavior can be achieved by using uri.properties and/or JkSet.
  + * 
  + * Example:
  + *   <VirtualHost foo.com>
  + *      <Location /examples>
  + *         JkUriSet worker ajp13
  + *      </Location>
  + *   </VirtualHost>
  + *
  + * This is the best way to define a webapplication in apache. It is
  + * scalable ( using apache native optimizations, you can have hundreds
  + * of hosts and thousands of webapplications ), 'natural' to any
  + * apache user.
    *
  - * Equivalent with "worker.workerName.workerProperty=value" in
  - * workers.properties.
  - * Not used - do we want to add it ( just syntactic sugar ) ?
  + * XXX This is a special configuration, for most users just use
  + * the properties files.
    */
  -static const char *jk2_setWorker(cmd_parms *cmd,void *per_dir,
  -                                const char *wname, const char *wparam, const char *value)
  +static const char *jk2_uriSet(cmd_parms *cmd, void *per_dir, 
  +                              const char *name, const char *val)
   {
  -    char * name;
  -    name = ap_pstrcat(cmd->pool, "worker.", wname, ".", wparam, NULL);
  -    return (jk2_set2(cmd, per_dir, name, value));
  -}
  -
  -/* XXX Move to docs.
  -   Equivalence table:
  -
  -   JkWorkersFile == workerFile ( XXX make it a multi-value, add dir, reload )
  -                               ( XXX Should it be 'jkPropertiesFile' - for additional props.)
  -   
  -   JkWorker == JkSet
  -
  -   JkAutoMount - was not implemented in 1.2, will be added in 2.1 in a better form
  -
  -   JkMount ==  ( the property name is the /uri, the value is the worker )
  - 
  -   JkMountCopy == root_apps_are_global ( XXX looking for a better name, mountCopy is very confusing )
  -
  -   JkLogFile == logFile
  -
  -   JkLogLevel == logLevel
  -
  -   JkLogStampFormat == logStampFormat
  -
  -   JkXXXIndicator == XxxIndicator
  +    jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)per_dir;
   
  -   JkExtractSSL == extractSSL
  +    uriEnv->setProperty( workerEnv->globalEnv, uriEnv, name, val );
  +    
  +    return NULL;
  +}
   
  -   JkOptions == Individual properties:
  -                  forwardSslKeySize
  -                  forwardUriCompat
  -                  forwardUriCompatUnparsed
  -                  forwardUriEscaped
   
  -   JkEnvVar == env.NAME=DEFAULT_VALUE
  -*/
   /* Command table.
    */
   static const command_rec jk2_cmds[] =
  @@ -342,26 +183,20 @@
           */
           { "JkSet", jk2_set2, NULL, RSRC_CONF, TAKE2,
             "Set a jk property, same syntax and rules as in JkWorkersFile" },
  -        {"JkWebapp", jk2_setWebapp, NULL, ACCESS_CONF, TAKE2,
  -         "Defines a webapp in a Location directive and it's properties"},
  -        {"JkServlet", jk2_setServlet, NULL, ACCESS_CONF, TAKE2,
  -         "Defines a servlet in a Location directive"},
  +        {"JkUriSet", jk2_uriSet, NULL, ACCESS_CONF, TAKE2,
  +         "Defines properties for a location"},
           NULL
       };
   
   static void *jk2_create_dir_config(ap_pool *p, char *path)
   {
       jk_uriEnv_t *new =
  -        (jk_uriEnv_t *)ap_pcalloc(p, sizeof(jk_uriEnv_t));
  -
  -    fprintf(stderr, "XXX Create dir config %s %p\n", path, new);
  -    new->uri = path;
  -    new->workerEnv=workerEnv;
  +        workerEnv->uriMap->createUriEnv( workerEnv->globalEnv,
  +                                         workerEnv->uriMap, NULL, path );
       
       return new;
   }
   
  -
   static void *jk2_merge_dir_config(ap_pool *p, void *basev, void *addv)
   {
       jk_uriEnv_t *base =(jk_uriEnv_t *)basev;
  @@ -584,18 +419,18 @@
                         "mod_jk.handler() Default worker for %s %s\n",
                         r->uri, worker->name); 
       } else {
  -        worker=uriEnv->webapp->worker;
  +        worker=uriEnv->worker;
           env->l->jkLog(env, env->l, JK_LOG_INFO, 
                         "mod_jk.handler() per dir worker for %p %p\n",
  -                      worker, uriEnv->webapp );
  +                      worker, uriEnv );
           
  -        if( worker==NULL && uriEnv->webapp->workerName != NULL ) {
  +        if( worker==NULL && uriEnv->workerName != NULL ) {
               worker=workerEnv->getWorkerForName( env, workerEnv,
  -                                                uriEnv->webapp->workerName);
  +                                                uriEnv->workerName);
               env->l->jkLog(env, env->l, JK_LOG_INFO, 
                             "mod_jk.handler() finding worker for %p %p\n",
  -                          worker, uriEnv->webapp );
  -            uriEnv->webapp->worker=worker;
  +                          worker, uriEnv );
  +            uriEnv->worker=worker;
           }
       }
   
  @@ -680,27 +515,11 @@
          to parse the request.
          XXX for now just forward to tomcat
       */
  -    if( uriEnv!= NULL && uriEnv->webapp!=NULL ) {
  -        jk_uriMap_t *uriMap=uriEnv->webapp->uriMap;
  -
  -        if( uriMap!=NULL ) {
  -            /* Again, we have 2 choices. Either use our map, or again
  -               let apache. The second is probably faster, but requires
  -               using some APIs I'm not familiar with ( to modify apache's
  -               config on the fly ). After we learn the new APIs we can
  -               switch to the second method.
  -            */
  -            /* XXX Cut the context path ? */
  -            jk_uriEnv_t *target=uriMap->mapUri( env, uriMap, NULL, r->uri );
  -            if( target == NULL ) 
  -                return DECLINED;
  -            uriEnv=target;
  -        }
  -
  +    if( uriEnv!= NULL && uriEnv->workerName!=NULL ) {
           env->l->jkLog(env, env->l, JK_LOG_INFO, 
                         "PerDir mapping  %s=%s\n",
  -                      r->uri, uriEnv->webapp->workerName);
  -        
  +                      r->uri, uriEnv->workerName);
  +
           ap_set_module_config( r->request_config, &jk2_module, uriEnv );        
           r->handler=JK_HANDLER;
           return OK;
  @@ -722,7 +541,7 @@
       */
       uriEnv = workerEnv->uriMap->mapUri(env, workerEnv->uriMap,NULL,r->uri );
       
  -    if(uriEnv==NULL ) {
  +    if(uriEnv==NULL || uriEnv->workerName==NULL) {
           return DECLINED;
       }
   
  @@ -731,7 +550,7 @@
   
       env->l->jkLog(env, env->l, JK_LOG_INFO, 
                     "mod_jk.translate(): uriMap %s %s\n",
  -                  r->uri, uriEnv->webapp->workerName);
  +                  r->uri, uriEnv->workerName);
   
       return OK;
   }
  
  
  
  1.3       +3 -3      jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache2/mod_jk2.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mod_jk2.c	28 Feb 2002 23:35:26 -0000	1.2
  +++ mod_jk2.c	1 Mar 2002 00:45:58 -0000	1.3
  @@ -59,7 +59,7 @@
    * Description: Apache 2 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <sh...@il.ibm.com>                           *
    *                 Henri Gomez <hg...@slib.fr>                               *
  - * Version:     $Revision: 1.2 $                                           *
  + * Version:     $Revision: 1.3 $                                           *
    ***************************************************************************/
   
   /*
  @@ -650,8 +650,8 @@
          the real mapping. 
       */
       uriEnv = workerEnv->uriMap->mapUri(env, workerEnv->uriMap,NULL,r->uri );
  -    
  -    if(uriEnv==NULL ) {
  +
  +    if( uriEnv== NULL || uriEnv->workerName == NULL) {
           return DECLINED;
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>