📄 mod_jk2.c
字号:
/* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2002 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: Apache 1.3 plugin for Jakarta/Tomcat * * Author: Gal Shachor <shachor@il.ibm.com> * * Henri Gomez <hgomez@slib.fr> * * Version: $Revision: 1.25 $ * ***************************************************************************//* * mod_jk: keeps all servlet/jakarta related ramblings together. */#include "httpd.h"#include "http_config.h"#include "http_request.h"#include "http_core.h"#include "http_protocol.h"#include "http_main.h"#include "http_log.h"#include "util_script.h"#include "http_conf_globals.h"/* * Jakarta (jk_) include files */#include "jk_global.h"#include "jk_map.h"#include "jk_pool.h"#include "jk_env.h"#include "jk_service.h"#include "jk_worker.h"#include "jk_workerEnv.h"#include "jk_uriMap.h"#include "jk_requtil.h"#ifdef WIN32static char file_name[_MAX_PATH];#endif#define JK_HANDLER ("jakarta-servlet2")#define JK_MAGIC_TYPE ("application/x-jakarta-servlet2")module MODULE_VAR_EXPORT jk2_module;int jk2_service_apache13_init(jk_env_t *env, jk_ws_service_t *s);/* In apache1.3 this is reset when the module is reloaded ( after * config. No good way to discover if it's the first time or not. */static jk_workerEnv_t *workerEnv;/* ==================== Options setters ==================== *//* * JkSet name value * * Set jk options. Same as using workers.properties or a * config application. * * Known properties: see workers.properties documentation * * XXX Shouldn't abuse it, there is no way to write back * the properties. */static const char *jk2_set2(cmd_parms *cmd, void *per_dir, const char *name, char *value){ server_rec *s = cmd->server; jk_uriEnv_t *serverEnv=(jk_uriEnv_t *) ap_get_module_config(s->module_config, &jk2_module); jk_env_t *env=workerEnv->globalEnv; int rc; rc=workerEnv->config->setPropertyString( env, workerEnv->config, (char *)name, value ); if( rc!=JK_OK ) { fprintf( stderr, "mod_jk2: Unrecognized option %s %s\n", name, value); } return NULL;}#ifdef HAS_APRapr_pool_t *jk_globalPool;#endif/* Create the initial set of objects. You need to cut&paste this and adapt to your server. */static int jk2_create_workerEnv(ap_pool *p, const server_rec *s){ jk_env_t *env; jk_pool_t *globalPool; jk_bean_t *jkb;#ifdef HAS_APR apr_initialize(); apr_pool_create( &jk_globalPool, NULL ); jk2_pool_apr_create( NULL, &globalPool, NULL, jk_globalPool );#else /** First create a pool. We use the default ( jk ) pool impl, * other choices are apr or native. */ jk2_pool_create( NULL, &globalPool, NULL, 2048 );#endif /** Create the global environment. This will register the default factories, to be overriten later. */ env=jk2_env_getEnv( NULL, globalPool ); /* Optional. Register more factories ( or replace existing ones ) Insert your server-specific objects here. */ /* Create the logger . We use the default jk logger, will output to a file. Check the logger for default settings. */ jkb=env->createBean2( env, env->globalPool, "logger.file", ""); env->alias( env, "logger.file:", "logger"); env->alias( env, "logger.file:", "logger:"); if( jkb==NULL ) { fprintf(stderr, "Error creating logger "); return JK_ERR; } env->l=jkb->object; env->alias( env, "logger.file:", "logger"); /* Create the workerEnv */ jkb=env->createBean2( env, env->globalPool,"workerEnv", ""); if( jkb==NULL ) { fprintf(stderr, "Error creating workerEnv "); return JK_ERR; } workerEnv= jkb->object; env->alias( env, "workerEnv:", "workerEnv"); if( workerEnv==NULL || env->l == NULL ) { fprintf( stderr, "Error initializing jk, NULL objects \n"); return JK_ERR; } /* serverRoot via ap_server_root */ workerEnv->initData->add( env, workerEnv->initData, "serverRoot", workerEnv->pool->pstrdup( env, workerEnv->pool, ap_server_root)); /* Local initialization. */ env->l->jkLog(env, env->l, JK_LOG_INFO, "Set serverRoot %s\n", ap_server_root); workerEnv->_private = (void *)s; return JK_OK;}/* -------------------- Apache specific initialization -------------------- *//* Command table. */static const command_rec jk2_cmds[] = { /* This is the 'main' directive for tunning jk2. It takes 2 parameters, and it behaves _identically_ as a setting in workers.properties. */ { "JkSet", jk2_set2, NULL, RSRC_CONF, TAKE2, "Set a jk property, same syntax and rules as in JkWorkersFile" }, NULL };/** Create default jk_config. This is the first thing called by apache ( or should be ) */static void *jk2_create_config(ap_pool *p, server_rec *s){ jk_uriEnv_t *newUri; jk_bean_t *jkb; if( workerEnv==NULL ) { jk2_create_workerEnv(p, s ); } if( s->is_virtual == 1 ) { /* Virtual host */ fprintf( stderr, "Create config for virtual host\n"); } else { /* Default host */ fprintf( stderr, "Create config for main host\n"); } jkb=workerEnv->globalEnv->createBean2( workerEnv->globalEnv, workerEnv->pool, "uri", "" ); newUri = jkb->object; newUri->workerEnv=workerEnv; return newUri;}/** Standard apache callback, merge jk options specified in <Host> context. Used to set per virtual host configs */static void *jk2_merge_config(ap_pool *p, void *basev,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -