/*
* Copyright (c) 1999-2008 Caucho Technology. All rights reserved.
*
* This file is part of Resin(R) Open Source
*
* Each copy or derived work must preserve the copyright notice and this
* notice unmodified.
*
* Resin Open Source is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Resin Open Source is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
* of NON-INFRINGEMENT. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with Resin Open Source; if not, write to the
*
* Free Software Foundation, Inc.
* 59 Temple Place, Suite 330
* Boston, MA 02111-1307 USA
*/
/*
* config.c is responsible for scanning the parsed registry and grabbing
* relevant data.
*
* Important data include the web-app and the servlet-mapping so any filter
* can properly dispatch the request.
*
* Also, config.c needs to grab the srun and srun-backup blocks to properly
* send the requests to the proper JVM.
*/
#ifdef WIN32
#include <winsock2.h>
#include <fcntl.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys/stat.h>
#include <errno.h>
#include "cse.h"
#define CACHE_SIZE 16384
#define AUTO_WRITE_TIME (15 * 60)
#define HMUX_DISPATCH_QUERY 'q'
#define HMUX_DISPATCH_QUERY_CLUSTER 's'
#define HMUX_DISPATCH_HOST 'h'
#define HMUX_DISPATCH_WEB_APP 'a'
#define HMUX_DISPATCH_MATCH 'm'
#define HMUX_DISPATCH_IGNORE 'i'
#define HMUX_DISPATCH_ETAG 'e'
#define HMUX_DISPATCH_NO_CHANGE 'n'
#define HMUX_DISPATCH_SRUN 's'
typedef struct hash_t {
char *host;
int port;
char *uri;
resin_host_t *match_host;
volatile int count;
volatile int update_count;
} hash_t;
static int g_update_count;
static hash_t g_url_cache[CACHE_SIZE];
static resin_host_t *
cse_match_host_impl(config_t *config, const char *host_name,
int port, time_t now);
static int
resin_atoi(char *s)
{
int sign = 1;
int value = 0;
if (*s == '-') {
sign = -1;
s++;
}
else if (*s == '+') {
s++;
}
for (; *s && '0' <= *s && *s <= '9'; s++) {
value = 10 * value + *s - '0';
if (value < 0 || value > 0x3fffffff)
return sign * 0x3fffffff;
}
return sign * value;
}
static location_t *
cse_add_unique_location(mem_pool_t *pool, web_app_t *app, char *prefix,
char *suffix, int is_exact, int ignore)
{
location_t *loc;
for (loc = app->locations; loc; loc = loc->next) {
if (is_exact != loc->is_exact)
continue;
else if ((prefix == 0) != (loc->prefix == 0))
continue;
else if (prefix && strcmp(prefix, loc->prefix))
continue;
else if ((suffix == 0) != (loc->suffix == 0))
continue;
else if (suffix && strcmp(suffix, loc->suffix))
continue;
return loc;
}
loc = (location_t *) cse_alloc(pool, sizeof(location_t));
memset(loc, 0, sizeof(location_t));
loc->next = app->locations;
app->locations = loc;
loc->application = app;
loc->prefix = prefix;
loc->suffix = suffix;
loc->is_exact = is_exact;
loc->ignore = ignore;
LOG(("%s:%d:cse_add_unique_location(): loc %s %s %x %s\n",
__FILE__, __LINE__,
loc->prefix ? loc->prefix : "(null)",
loc->suffix ? loc->suffix : "(null)",
loc->next,
loc->ignore ? "ignore" : ""));
return loc;
}
static web_app_t *
cse_add_web_app(mem_pool_t *pool, resin_host_t *host,
web_app_t *applications, char *context_path)
{
web_app_t *app;
if (! context_path)
context_path = "";
else if (! strcmp(context_path, "/"))
context_path = "";
for (app = applications; app; app = app->next) {
if (strcmp(context_path, app->context_path))
continue;
return app;
}
app = (web_app_t *) cse_alloc(pool, sizeof(web_app_t));
memset(app, 0, sizeof(web_app_t));
app->next = applications;
applications = app;
app->host = host;
/* defaults to having data. Set false if web-app is unavailable */
app->has_data = 1;
app->context_path = cse_strdup(pool, context_path);
LOG(("%s:%d:cse_add_web_app(): new web-app host:%s path:%s\n",
__FILE__, __LINE__, host->name, app->context_path));
return applications;
}
/**
* Add an application pattern to the list of recognized locations
*
* @param config the configuration
* @param host the host for the pattern
* @param prefix the web-app prefix
*
* @return the new application
*/
static web_app_t *
cse_add_application(mem_pool_t *pool, resin_host_t *host,
web_app_t *applications, char *prefix)
{
char loc_prefix[8192];
int i, j;
i = 0;
if (prefix && *prefix && *prefix != '/')
loc_prefix[i++] = '/';
#ifdef WIN32
if (prefix) {
for (j = 0; prefix[j]; j++)
loc_prefix[i++] = tolower(prefix[j]);
}
#else
if (prefix) {
for (j = 0; prefix[j]; j++)
loc_prefix[i++] = prefix[j];
}
#endif
loc_prefix[i] = 0;
return cse_add_web_app(pool, host, applications, loc_prefix);
}
/**
* Add a location pattern to the list of recognized locations
*
* @param app the containing application
* @param pattern the url-pattern to match
*
* @return the new location
*/
static void
cse_add_location(mem_pool_t *pool, web_app_t *app,
char *pattern, char *servlet_name)
{
char cleanPrefix[4096];
int prefixLength;
int cleanLength;
char *loc_prefix = 0;
char *loc_suffix = 0;
int loc_is_exact = 0;
int ignore = 0;
#ifdef WIN32
if (pattern) {
int i;
pattern = cse_strdup(pool, pattern);
for (i = 0; pattern[i]; i++)
pattern[i] = tolower(pattern[i]);
}
#endif /* WIN32 */
cleanPrefix[0] = 0;
if (pattern[0] && pattern[0] != '/' && pattern[0] != '*')
strcpy(cleanPrefix, "/");
prefixLength = strlen(cleanPrefix);
if (prefixLength > 0 && cleanPrefix[prefixLength - 1] == '/')
cleanPrefix[prefixLength - 1] = 0;
if (! pattern[0]) {
loc_prefix = cse_strdup(pool, cleanPrefix);
loc_suffix = 0;
}
else if (pattern[0] == '*') {
loc_prefix = cse_strdup(pool, cleanPrefix);
loc_suffix = cse_strdup(pool, pattern + 1);
}
else {
if (pattern[0] != '/')
strcat(cleanPrefix, "/");
strcat(cleanPrefix, pattern);
cleanLength = strlen(cleanPrefix);
if (strlen(pattern) <= 1)
cleanPrefix[cleanLength - 1] = 0;
else if (cleanPrefix[cleanLength - 1] != '*')
loc_is_exact = 1;
else if (cleanLength >= 2 && cleanPrefix[cleanLength - 2] == '/')
cleanPrefix[cleanLength - 2] = 0;
else if (cleanLength > 1)
cleanPrefix[cleanLength - 1] = 0;
loc_prefix = cse_strdup(pool, cleanPrefix);
loc_suffix = 0;
}
if (servlet_name && ! strcmp(servlet_name, "plugin_ignore"))
ignore = 1;
cse_add_unique_location(pool, app, loc_prefix, loc_suffix,
loc_is_exact, ignore);
}
/**
* Add a url-pattern to the list of matching locations.
*
* @param app the containing application
* @param pattern the url-pattern to match
*
* @return the new location
*/
static void
cse_add_match_pattern(mem_pool_t *pool, web_app_t *app, char *pattern)
{
cse_add_location(pool, app, pattern, "plugin_match");
}
/**
* Add a url-pattern to the list of matching locations.
*
* @param app the containing application
* @param pattern the url-pattern to match
*
* @return the new location
*/
static void
cse_add_ignore_pattern(mem_pool_t *pool, web_app_t *app, char *pattern)
{
cse_add_location(pool, app, pa
resin-3_2-snap.zip
需积分: 0 32 浏览量
更新于2008-07-22
收藏 11.93MB ZIP 举报
Resin 是一款高性能、轻量级的企业级Java应用服务器,由Caucho Technology开发。"resin-3_2-snap.zip" 文件很可能是Resin 3.2的一个快照版本,"snap"通常指的是软件开发过程中的一个不完整的或中间状态的版本,可能包含了最新的功能更新或bug修复。这个zip压缩包包含了Resin服务器的特定构建版本,用于测试或开发目的。
Resin 3.2是Resin服务器的一个重要版本,它提供了以下关键特性:
1. **Servlet容器**:Resin作为Servlet容器,能够运行基于Java Servlet和JavaServer Pages (JSP) 的Web应用程序。Servlet是Java平台上的标准接口,允许开发者创建动态Web内容。
2. **Java EE支持**:Resin 3.2 支持Java Enterprise Edition (Java EE)的部分规范,如EJB (Enterprise JavaBeans)、JMS (Java Message Service) 和JTA (Java Transaction API),使得开发者可以构建分布式企业级应用。
3. **快速性能**:Resin以其高效的性能而闻名,通过优化的线程管理和内存管理,能提供快速的响应时间以及高并发处理能力。
4. **负载均衡与集群**:Resin 3.2 支持负载均衡和集群部署,可以将请求分发到多个服务器,提高可用性和扩展性。
5. **缓存机制**:内置的QoS (Quality of Service) 缓存系统能加速静态内容的交付,提升用户体验。
6. **热部署**:Resin支持应用的热部署,开发者在不中断服务的情况下,可以更新和调试应用。
7. **XML处理**:Resin对XML和Web服务有良好的支持,包括SOAP和RESTful服务。
8. **日志和监控**:提供详细的日志记录和实时监控工具,帮助开发者调试和优化应用。
9. **安全管理**:Resin 3.2 包含了用户认证和授权机制,符合Java EE的安全规范,能保护应用程序免受未经授权的访问。
10. **JNDI支持**:Java Naming and Directory Interface (JNDI) 提供了一个统一的接口来查找和绑定各种资源,如数据库连接池。
在解压"resin-3.2.s080720" 文件后,你会得到Resin 3.2服务器的具体构建,包括配置文件、启动脚本、lib库和其他必要的组件。要运行Resin,你需要按照官方文档的指示配置服务器,包括设置端口、配置应用上下文、数据库连接等。此外,可能还需要根据项目需求,自定义resin.xml配置文件,以满足特定的部署需求。
总体来说,Resin 3.2 是一个强大且灵活的Java应用服务器,对于Java开发者而言,它提供了一个高效且易于管理的平台,用于构建和部署各种Web应用程序。如果你正在处理这个"resin-3_2-snap.zip" 文件,那么你将有机会深入了解Resin的运作机制,并学习如何利用其特性来优化你的Web服务。
海盗之爷
- 粉丝: 9
- 资源: 37
最新资源
- 光储并网VSG系统Matlab simulink仿真模型,附参考文献 系统前级直流部分包括光伏阵列、变器、储能系统和双向dcdc变器,后级交流子系统包括逆变器LC滤波器,交流负载 光储并网VSG系
- file_241223_024438_84523.pdf
- 质子交膜燃料电池PEMFC Matlab simulink滑模控制模型,过氧比控制,温度控制,阴,阳极气压控制
- IMG20241223015444.jpg
- 模块化多电平变器(MMC),本模型为三相MMC整流器 控制策略:双闭环控制、桥臂电压均衡控制、模块电压均衡控制、环流抑制控制策略、载波移相调制,可供参考学习使用,默认发2020b版本及以上
- Delphi 12 控件之FlashAV FFMPEG VCL Player For Delphi v7.0 for D10-D11 Full Source.7z
- Delphi 12 控件之DevExpressVCLProducts-24.2.3.exe.zip
- Mysql配置文件优化内容 my.cnf
- 中国地级市CO2排放数据(2000-2023年).zip
- smart200光栅报警程序