tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/include jk_channel.h jk_env.h jk_global.h jk_map.h jk_msg.h jk_service.h jk_worker.h
Date Sat, 01 Dec 2001 22:30:58 GMT
costin      01/12/01 14:30:58

  Added:       jk/native2/include jk_channel.h jk_env.h jk_global.h
                        jk_map.h jk_msg.h jk_service.h jk_worker.h
  Log:
  The other interfaces from jk. Small changes only.
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_channel.h
  
  Index: jk_channel.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  #ifndef JK_CHANNEL_H
  #define JK_CHANNEL_H
  
  #include "jk_global.h"
  #include "jk_logger.h"
  #include "jk_pool.h"
  #include "jk_msg_buff.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  struct jk_worker;
  struct jk_endpoint;
  struct jk_channel;
  
  typedef struct jk_channel jk_channel_t;
  
  /**
   * Abstraction (interface) for sending/receiving blocks of data ( packets ).
   * This will be used to replace the current TCP/socket code and allow other
   * transports. JNI, shmem, doors and other mechanisms can be tryed out, and 
   * we can also have a gradual transition to APR. The current tcp-based transport
   * will be refactored to this interface.
   * 
   * XXX Experimental
   * 
   * Issues:
   *  - Should the transport also check the packet integrity ( envelope ) ?
   *  - This is supposed to work for send/receive sequences, and the buffer
   *   shouldn't be modified until a send/receive is completed ( we want to
   *   avoid memcpy )
   *  - We need to extend/generalize the mechanisms in 'worker' to support other
   *   types of internal interfaces.
   *  - this interface is using get/setProperty model, like in Java beans ( well, 
   *    just a generic get/set method, no individual setters ). This is different
   *    from worker, which gets a map at startup. This model should also allow 
   *    run-time queries for status, management, etc - but it may be too complex.
   * 
   * @author Costin Manolache
   */
  struct jk_channel {
      char *name;
  
      /** List of properties this channel 'knows'. 
       *  This will permit admin code to 'query' each channel
       *  and the setting code can better report errors.
       */
      char **supportedProperties;
      
      struct jk_worker *worker; /* XXX Do we need it ? */
      jk_logger_t *logger;
      jk_map_t *properties;
      jk_pool_t *pool; /* XXX Do we need it ? */
      
      
      /** Prepare the channel, check the properties. This 
       * will resolve the host and do all the validations.
       * ( needed to remove the dependencies on sockets in ajp)
       * 
       * The channel may save or use data from the worker ( like cache
       *  the inet addr, etc )
       *  XXX revisit this - we may pass too much that is not needed
       */
      int (JK_METHOD *init)(jk_channel_t *_this,
  			  jk_map_t *properties,
  			  char *worker_name,
  			  struct jk_worker *worker, 
  			  jk_logger_t *l );
      
      /** Open the communication channel
       */
      int (JK_METHOD *open)(jk_channel_t *_this, 
  			  struct jk_endpoint *endpoint );
      
      /** Close the communication channel
       */
      int (JK_METHOD *close)(jk_channel_t *_this, 
  			   struct jk_endpoint *endpoint );
      
    /** Send a packet
     */
      int (JK_METHOD *send)(jk_channel_t *_this,
  			  struct jk_endpoint *endpoint,
  			  char *b, int len );
      
      /** Receive a packet
       */
      int (JK_METHOD *recv)(jk_channel_t *_this,
  			  struct jk_endpoint *endpoint,
  			  char *b, int len );
      
      /** Set a channel property. Properties are used to configure the 
       * communication channel ( example: port, host, file, shmem_name, etc).
       */
      int (JK_METHOD *setProperty)(jk_channel_t *_this, 
  				 char *name, char *value);
      
      /** Get a channel property 
       */
      int (JK_METHOD *getProperty)(jk_channel_t *_this, 
  			       char *name, char **value);
      
      void *_privatePtr;
  };
      
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif 
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_env.h
  
  Index: jk_env.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  #ifndef JK_ENV_H
  #define JK_ENV_H
  
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  #include "jk_logger.h"
  #include "jk_pool.h"
  #include "jk_map.h"
  #include "jk_worker.h"
  
  /** 
   *  Common environment for all jk functions. Provide uniform
   *  access to pools, logging, factories and other 'system' services.
   * 
   * 
   *
   * ( based on jk_worker.c, jk_worker_list.c )
   * @author Gal Shachor <shachor@il.ibm.com>                           
   * @author Henri Gomez <hgomez@slib.fr>                               
   * @author Costin Manolache
   * 
   */
  struct jk_env;
  typedef struct jk_env jk_env_t;
  
  /**
   * Factory used to create all jk objects. Factories are registered with 
   * jk_env_registerFactory ( or automatically - LATER ), and created
   * with jk_env_getFactory.
   * 
   * Essentially, an abstract base class (or factory class) with a single
   * method -- think of it as createWorker() or the Factory Method Design
   * Pattern.  There is a different worker_factory function for each of the
   * different types of workers.  The set of all these functions is created
   * at startup from the list in jk_worker_list.h, and then the correct one
   * is chosen in jk_worker.c->wc_create_worker().  See jk_worker.c and
   * jk_ajp13_worker.c/jk_ajp14_worker.c for examples.
   *
   * This allows new workers to be written without modifing the plugin code
   * for the various web servers (since the only link is through
   * jk_worker_list.h).  
   */
  typedef int (JK_METHOD *jk_env_objectFactory_t)(jk_env_t *env,
                                                  void **result, 
                                                  const char *type,
                                                  const char *name);
  
  /** Get a pointer to the jk_env. We could support multiple 
   *  env 'instances' in future - for now it's a singleton.
   */
  jk_env_t* JK_METHOD jk_env_getEnv( char *id );
  
  
  /**
   *  The env will be used in a similar way with the JniEnv, to provide 
   *  access to various low level services ( pool, logging, system properties )
   *  in a consistent way. In time we should have all methods follow 
   *  the same pattern, with env as a first parameter, then the object ( this ) and 
   *  the other methods parameters.  
   */
  struct jk_env {
      jk_logger_t *logger;
      /*jk_pool_t   global_pool; */
      
      /** Global properties ( similar with System properties in java)
       */
      /*   jk_map_t *properties; */
      /** Factory to create an instance of a particular type.
       * 
       */
      jk_env_objectFactory_t 
      (JK_METHOD *getFactory)( jk_env_t *env, const char *type,
                               const char *name );
  
      /** Create an object instance. It'll first get the factory, then
          call it. This is a very frequent operation.
      */
      void *
      (JK_METHOD *getInstance)( jk_env_t *env, const char *type,
                                const char *name );
      
  
      /** Register a factory for a type ( channel, worker ).
       */
      void (JK_METHOD *registerFactory)( jk_env_t *env, const char *type,
                                         const char *name, 
                                         jk_env_objectFactory_t factory);
      
      
      /** (Future)
       *  Register a factory for a type ( channel, worker ), using a .so 
       *  model.
       */
      void (JK_METHOD *registerExternalFactory)( jk_env_t *env, char *type, 
                                                 char *name, char *dll,
                                                 char *factorySymbol);
      
      /* private */
      jk_map_t *_registry;
      
  };
  
  void JK_METHOD jk_registry_init(jk_env_t *env);
  
  
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif 
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_global.h
  
  Index: jk_global.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  /***************************************************************************
   * Description: Global definitions and include files that should exist     *
   *              anywhere                                                   *
   * Author:      Gal Shachor <shachor@il.ibm.com>                           *
   * Version:     $Revision: 1.1 $                                               *
   ***************************************************************************/
  
  #ifndef JK_GLOBAL_H
  #define JK_GLOBAL_H
  
  #include "jk_version.h"
  
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <stdarg.h>
  #include <errno.h>
  #include <time.h>
  #include <ctype.h>
  
  #include <sys/types.h>
  #include <sys/stat.h>
  
  #ifdef WIN32
      #include <windows.h>
      #include <winsock.h>
  #else
      #include <unistd.h>
      #include <netdb.h>
  
      #include <netinet/in.h>
      #include <sys/socket.h>
      #ifndef NETWARE
          #include <netinet/tcp.h>
          #include <arpa/inet.h>
          #include <sys/un.h>
          #ifndef _OSD_POSIX
              #include <sys/socketvar.h>
          #endif
          #ifndef HPUX11
              #include <sys/select.h>
          #endif
      #endif
          
      #include <sys/time.h>
      #include <sys/ioctl.h>
  #endif
  
  #ifdef WIN32
  /* define snprint to match windows version */
  #define snprintf _snprintf
  #endif
  
  
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  /* Some compileers support 'inline'. How to guess ?
     #define INLINE inline
   */
  #define INLINE 
  
  #define JK_WORKER_FILE_TAG      ("worker_file")
  #define JK_MOUNT_FILE_TAG       ("worker_mount_file")
  #define JK_LOG_LEVEL_TAG        ("log_level")
  #define JK_LOG_FILE_TAG         ("log_file")
  #define JK_WORKER_NAME_TAG      ("worker")
  
  #define JK_WORKER_FILE_DEF  ("workers.properties")
  #define JK_LOG_LEVEL_DEF    ("emerg")
  
  #define JK_TRUE  (1)
  #define JK_FALSE (0)
  
  #define JK_LF (10)
  #define JK_CR (13)
  
  #define JK_SESSION_IDENTIFIER "JSESSIONID"
  #define JK_PATH_SESSION_IDENTIFIER ";jsessionid"
  
  #if defined(WIN32) || defined(NETWARE)
      #define JK_METHOD __stdcall
      #define C_LEVEL_TRY_START       __try {
      #define C_LEVEL_TRY_END         }
      #define C_LEVEL_FINALLY_START   __finally {
      #define C_LEVEL_FINALLY_END     }
      #define PATH_SEPERATOR          (';')
      #define FILE_SEPERATOR          ('\\')
      #define PATH_ENV_VARIABLE       ("PATH")
  
      /* incompatible names... */
      #ifndef strcasecmp 
          #define strcasecmp stricmp
      #endif
  #else
      #define JK_METHOD
      #define C_LEVEL_TRY_START       
      #define C_LEVEL_TRY_END         
      #define C_LEVEL_FINALLY_START   
      #define C_LEVEL_FINALLY_END     
      #define PATH_SEPERATOR          (':')
      #define FILE_SEPERATOR          ('/')
      #define PATH_ENV_VARIABLE       ("LD_LIBRARY_PATH")
  #endif
  
  /*
   * JK options
   */
  
  #define JK_OPT_FWDURIMASK           0x0003
  
  #define JK_OPT_FWDURICOMPAT         0x0001
  #define JK_OPT_FWDURICOMPATUNPARSED 0x0002
  #define JK_OPT_FWDURIESCAPED        0x0003
  
  #define JK_OPT_FWDURIDEFAULT        JK_OPT_FWDURICOMPAT
  
  #define JK_OPT_FWDKEYSIZE           0x0004
  
  /* Check for EBCDIC systems */
  
  /* Check for Apache 2.0 running on an EBCDIC system */
  #if APR_CHARSET_EBCDIC 
  
  #define USE_CHARSET_EBCDIC
  #define jk_xlate_to_ascii(b, l) ap_xlate_proto_to_ascii(b, l)
  #define jk_xlate_from_ascii(b, l) ap_xlate_proto_from_ascii(b, l)
  
  #else   /* APR_CHARSET_EBCDIC */
  
  /* Check for Apache 1.3 running on an EBCDIC system */
  #ifdef CHARSET_EBCDIC
  
  #define USE_CHARSET_EBCDIC
  #define jk_xlate_to_ascii(b, l) ebcdic2ascii(b, b, l)
  #define jk_xlate_from_ascii(b, l) ascii2ebcdic(b, b, l)
  
  #else /* CHARSET_EBCDIC */
  
  /* We're in on an ASCII system */
  
  #define jk_xlate_to_ascii(b, l)             /* NOOP */
  #define jk_xlate_from_ascii(b, l)           /* NOOP */
  
  #endif /* CHARSET_EBCDIC */
  
  #endif /* APR_CHARSET_EBCDIC */
  
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif /* JK_GLOBAL_H */
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_map.h
  
  Index: jk_map.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  /***************************************************************************
   * Description: Map object header file                                     *
   * Author:      Gal Shachor <shachor@il.ibm.com>                           *
   * Version:     $Revision: 1.1 $                                           *
   ***************************************************************************/
  
  #ifndef JK_MAP_H
  #define JK_MAP_H
  
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  
  struct jk_map;
  typedef struct jk_map jk_map_t;
  
  int map_alloc(jk_map_t **m);
  
  int map_free(jk_map_t **m);
  
  int map_open(jk_map_t *m);
  
  int map_close(jk_map_t *m);
  
  void *map_get(jk_map_t *m,
                const char *name,
                const void *def);
  
  int map_get_int(jk_map_t *m,
                  const char *name,
                  int def);
  
  double map_get_double(jk_map_t *m,
                        const char *name,
                        double def);
  
  char *map_get_string(jk_map_t *m,
                       const char *name,
                       const char *def);
  
  char **map_get_string_list(jk_map_t *m,
                             const char *name,
                             unsigned *list_len,
                             const char *def);
  
  int map_put(jk_map_t *m,
              const char *name,
              const void *value,
              void **old);
  
  int map_read_properties(jk_map_t *m,
                          const char *f);
  
  int map_size(jk_map_t *m);
  
  char *map_name_at(jk_map_t *m,
                    int idex);
  
  void *map_value_at(jk_map_t *m,
                     int idex);
    
  /**
   *  Replace $(property) in value.
   * 
   */
  char *map_replace_properties(const char *value, jk_map_t *m);
  
  /** Get a string property, using the worker's style
      for properties.
      Example worker.ajp13.host=localhost.
  */
  char *map_getStrProp(jk_map_t *m,
                       const char *objType,
                       const char *objName,
                       const char *pname,
                       const char *def);
  
  int map_getIntProp(jk_map_t *m,
                     const char *objType,
                     const char *objName,
                     const char *pname,
                     const int def);
  
      
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif /* JK_MAP_H */
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_msg.h
  
  Index: jk_msg.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  #ifndef JK_REQ_H
  #define JK_REQ_H
  
  #include "jk_global.h"
  #include "jk_logger.h"
  #include "jk_pool.h"
  #include "jk_msg_buff.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  /**
   * Abstract interface to jk marshalling. Different encodings and
   * communication mechanisms can be supported.
   *
   * This object is recyclable, but is not thread safe - it can
   * handle a single message at a time.
   *
   * It is created by a channel( XXX endpoint ? )
   * and can be sent/received only on that channel.
   *
   * XXX Lifecycle: on send the buffer will be reused after send
   *     On receive - it will be recycled after reset() or equiv.
   *     Same as on the java side.
   *
   * XXX JNI: this was specially designed so it can be used for a JNI
   * channel. It'll collect the params and convert them to java types.
   *
   * @author Costin Manolache
   */
  struct jk_msg {
      /** Human-readable method name */
      char *name;
  
      /** Method id - to be sent in the packet
       */
      int id;
   
      /** List of properties. The handler can be configured.
       *  ( password for login, etc ).
       */
      /*
        char **supportedProperties;
        jk_map_t *properties;
      */
  
      /*
       * Prepare the buffer for a new invocation 
       */
      void (*reset)(struct jk_msg *_this);
  
      /*
       * Finalize the buffer before sending - set length fields, etc
       */
      void (*end)(struct jk_msg *_this);
  
      /*
       * Dump the buffer header
       *   @param err Message text
       */
      void (*dump)(struct jk_msg *_this, char *err);
  
      void (*appendByte)(struct jk_msg *_this, unsigned char val);
      
      void (*appendBytes)(struct jk_msg *_this, 
                         const unsigned char * param,
                         const int len);
  
      void (*appendInt)(struct jk_msg *_this, 
                        const unsigned short val);
  
      void (*appendLong)(struct jk_msg *_this, 
                         const unsigned long val);
  
      void (*appendString)(struct jk_msg *_this, 
                           const char *param);
  
      unsigned char (*getByte)(struct jk_msg *_this);
  
      unsigned short (*getInt)(struct jk_msg *_this);
  
      unsigned long (*getLong)(struct jk_msg *_this);
  
      char * (*getString)(struct jk_msg *_this);
                               
      
      void (*getBytes)(struct jk_msg *_this, char *buf, int len);
                               
      
      void *_privatePtr;
  };
      
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif 
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_service.h
  
  Index: jk_service.h
  ===================================================================
  /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil-*- */
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  /***************************************************************************
   * Description: Definitions of the objects used during the service step.   *
   *              These are the web server (ws) the worker and the connection*
   *              JVM connection point                                       *
   * Author:      Gal Shachor <shachor@il.ibm.com>                           *
   * Author:      Dan Milstein <danmil@shore.net>                            *
   * Author:      Henri Gomez <hgomez@slib.fr>                               *
   * Version:     $Revision: 1.1 $                                           *
   ***************************************************************************/
  
  #ifndef JK_SERVICE_H
  #define JK_SERVICE_H
  
  #include "jk_global.h"
  #include "jk_map.h"
  #include "jk_workerEnv.h"
  #include "jk_logger.h"
  #include "jk_pool.h"
  #include "jk_uriMap.h"
  #include "jk_worker.h"
  #include "jk_endpoint.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
      
  struct jk_ws_service;
  struct jk_endpoint;
  struct jk_worker;
  struct jk_workerEnv;
  struct jk_channel;
  typedef struct jk_ws_service jk_ws_service_t;
  
  /*
   * The web server service 'class'.  An instance of this class is created
   * for each request which is forwarded from the web server to the servlet
   * container.  Contains the basic information about the request
   * (e.g. protocol, req_uri, etc), and also contains a series of methods
   * which provide access to core web server functionality (start_response,
   * read, write).  This class might be more accurately called ws_request.
   *
   * As with all the core jk classes, this is essentially an abstract base
   * class which is implemented/extended by classes which are specific to a
   * particular web server.  By using an abstract base class in this manner,
   * workers can be written for different protocols (e.g. ajp12, ajp13, ajp14)
   * without the workers having to worry about which web server they are
   * talking to.
   *
   * This particular OO-in-C system uses a 'ws_private' pointer to point to
   * the platform-specific data.  So in the subclasses, the methods do most
   * of their work by getting their hands on the ws_private pointer and then
   * using that to get at the correctly formatted data and functions for
   * their platform.
   *
   * Try imagining this as a 'public abstract class', and the ws_private
   * pointer as a sort of extra 'this' reference.  Or imagine that you are
   * seeing the internal vtables of your favorite OO language.  Whatever
   * works for you.
   *
   * See apache1.3/mod_jk.c and iis/jk_isapi_plugin.c for examples.  
   */
  struct jk_ws_service {
      struct jk_workerEnv *workerEnv;
      
      /* 
       * A 'this' pointer which is used by the subclasses of this class to
       * point to data which is specific to a given web server platform
       * (e.g. Apache or IIS).  
       */
      void *ws_private;
  
      int response_started;
      int read_body_started;
      
      /*
       * Provides memory management.  All data specific to this request is
       * allocated within this pool, which can then be reclaimed at the end
       * of the request handling cycle. 
       *
       * Alive as long as the request is alive.  
       */
      jk_pool_t *pool;
  
      /* 
       * CGI Environment needed by servlets
       */
      char    *method;        
      char    *protocol;      
      char    *req_uri;       
      char    *remote_addr;   
      char    *remote_host;   
      char    *remote_user;   
      char    *auth_type;     
      char    *query_string;  
      char    *server_name;   
      unsigned server_port;   
      char    *server_software;
      unsigned content_length;    /* integer that represents the content  */
                                  /* length should be 0 if unknown.        */
      unsigned is_chunked;        /* 1 if content length is unknown (chunked rq) */
      unsigned no_more_chunks;    /* 1 if last chunk has been read */
      unsigned content_read;      /* number of bytes read */
  
      /*
       * SSL information
       *
       * is_ssl       - True if request is in ssl connection
       * ssl_cert     - If available, base64 ASN.1 encoded client certificates.
       * ssl_cert_len - Length of ssl_cert, 0 if certificates are not available.
       * ssl_cipher   - The ssl cipher suite in use.
       * ssl_session  - The ssl session string
       *
       * In some servers it is impossible to extract all this information, in this 
       * case, we are passing NULL.
       */
      int      is_ssl;
      char     *ssl_cert;
      unsigned ssl_cert_len;
      char     *ssl_cipher;
      char     *ssl_session;
  
  	/*
  	 * SSL extra information for Servlet 2.3 API
  	 * 
  	 * ssl_key_size - ssl key size in use
  	 */
  	int		ssl_key_size;
  	
      /*
       * Headers, names and values.
       */
      char    **headers_names;    /* Names of the request headers  */
      char    **headers_values;   /* Values of the request headers */
      unsigned num_headers;       /* Number of request headers     */
  
  
      /*
       * Request attributes. 
       *
       * These attributes that were extracted from the web server and are 
       * sent to Tomcat.
       *
       * The developer should be able to read them from the ServletRequest
       * attributes. Tomcat is required to append org.apache.tomcat. to 
       * these attrinbute names.
       */
      char    **attributes_names;    /* Names of the request attributes  */
      char    **attributes_values;   /* Values of the request attributes */
      unsigned num_attributes;       /* Number of request attributes     */
  
      /*
       * The jvm route is in use when the adapter load balance among
       * several JVMs. It is the ID of a specific JVM in the load balance
       * group. We are using this variable to implement JVM session 
       * affinity
       */
      char    *jvm_route;
  
      /*
       * Callbacks into the web server.  For each, the first argument is
       * essentially a 'this' pointer.  All return JK_TRUE on success
       * and JK_FALSE on failure.
       */
  
      /*
       * Send the response headers to the browser.
       */
      int (JK_METHOD *start_response)(jk_ws_service_t *s,
                                      int status,
                                      const char *reason,
                                      const char * const *header_names,
                                      const char * const *header_values,
                                      unsigned num_of_headers);
  
      /*
       * Read a chunk of the request body into a buffer.  Attempt to read len
       * bytes into the buffer.  Write the number of bytes actually read into
       * actually_read.  
       */
      int (JK_METHOD *read)(jk_ws_service_t *s,
                            void *buffer,
                            unsigned len,
                            unsigned *actually_read);
  
      /*
       * Write a chunk of response data back to the browser.
       */
      int (JK_METHOD *write)(jk_ws_service_t *s,
                             const void *buffer,
                             unsigned len);
  };
  
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif /* JK_SERVICE_H */
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/native2/include/jk_worker.h
  
  Index: jk_worker.h
  ===================================================================
  /* ========================================================================= *
   *                                                                           *
   *                 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 <apache@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/>.   *
   *                                                                           *
   * ========================================================================= */
  
  /***************************************************************************
   * Description: Workers controller header file                             *
   * Author:      Gal Shachor <shachor@il.ibm.com>                           * 
   * Version:     $Revision: 1.1 $                                           *
   ***************************************************************************/
  
  #ifndef JK_WORKER_H
  #define JK_WORKER_H
  
  #include "jk_logger.h"
  #include "jk_service.h"
  #include "jk_endpoint.h"
  #include "jk_map.h"
  #include "jk_uriMap.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif /* __cplusplus */
  
  struct jk_worker;
  struct jk_endpoint;
  struct jk_env;
  typedef struct jk_worker jk_worker_t;
  
  /*
   * The worker 'class', which represents something to which the web server
   * can delegate requests. 
   *
   * This can mean communicating with a particular servlet engine instance,
   * using a particular protocol.  A single web server instance may have
   * multiple workers communicating with a single servlet engine (it could be
   * using ajp12 for some requests and ajp13/ajp14 for others).  Or, a single web
   * server instance could have multiple workers communicating with different
   * servlet engines using the same protocol (it could be load balancing
   * among many engines, using ajp13/ajp14 for all communication).
   *
   * There is also a load balancing worker (jk_lb_worker.c), which itself
   * manages a group of workers.
   *
   * Web servers are configured to forward requests to a given worker.  To
   * handle those requests, the worker's get_endpoint method is called, and
   * then the service() method of that endpoint is called.
   *
   * As with all the core jk classes, this is essentially an abstract base
   * class which is implemented/extended by classes which are specific to a
   * particular protocol (or request-handling system).  By using an abstract
   * base class in this manner, plugins can be written for different servers
   * (e.g. IIS, Apache) without the plugins having to worry about which
   * protocol they are talking.
   *
   * This particular OO-in-C system uses a 'worker_private' pointer to
   * point to the protocol-specific data/functions.  So in the subclasses, the
   * methods do most of their work by getting their hands on the
   * worker_private pointer and then using that to get at the functions for
   * their protocol.
   *
   * Try imagining this as a 'public abstract class', and the
   * worker_private pointer as a sort of extra 'this' reference.  Or
   * imagine that you are seeing the internal vtables of your favorite OO
   * language.  Whatever works for you.
   *
   * See jk_ajp14_worker.c, jk_ajp13_worker.c and jk_ajp12_worker.c for examples.  
   */
  struct jk_worker {
  
      struct jk_workerEnv *workerEnv;
      char *name;
      
      /* 
       * A 'this' pointer which is used by the subclasses of this class to
       * point to data/functions which are specific to a given protocol 
       * (e.g. ajp12 or ajp13 or ajp14).  
       */
      void *worker_private;
      
      /* XXX Add name and all other common properties !!! 
       */
  
      /** Communication channle used by the worker 
       */
      struct jk_channel *channel;
  
      /*
       * For all of the below (except destroy), the first argument is
       * essentially a 'this' pointer.  
       */
  
      /*
       * Given a worker which is in the process of being created, and a list
       * of configuration options (or 'properties'), check to see if it the
       * options are.  This will always be called before the init() method.
       * The init/validate distinction is a bit hazy to me.
       * See jk_ajp13_worker.c/jk_ajp14_worker.c and jk_worker.c->wc_create_worker() 
       */
      int (JK_METHOD *validate)(jk_worker_t *_this,
                                jk_map_t *props, 
                                struct jk_workerEnv *we,
                                jk_logger_t *l);
  
      /*
       * Do whatever initialization needs to be done to start this worker up.
       * Configuration options are passed in via the props parameter.  
       */
      int (JK_METHOD *init)(jk_worker_t *w,
                            jk_map_t *props, 
                            struct jk_workerEnv *we,
                            jk_logger_t *l);
  
  
      /*
       * Obtain an endpoint to service a particular request.  A pointer to
       * the endpoint is stored in pend.  
       */
      int (JK_METHOD *get_endpoint)(jk_worker_t *w,
                                    struct jk_endpoint **pend,
                                    jk_logger_t *l);
  
      /*
       * Shutdown this worker.  The first argument is not a 'this' pointer,
       * but rather a pointer to 'this', so that the object can be free'd (I
       * think -- though that doesn't seem to be happening.  Hmmm).  
       */
      int (JK_METHOD *destroy)(jk_worker_t **w,
                               jk_logger_t *l);
  };
  
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif /* JK_WORKER_H */
  
  
  

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


Mime
View raw message