📄 servletcontainer.h
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
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 name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
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 AUTHORS 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.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/Servlet/ServletContainer.h,v $
* $Date: 2003/05/13 18:42:19 $
*
Description:
\*____________________________________________________________________________*/
//$SourceTop:$
#ifndef SERVLETCONTAINER_H_
#define SERVLETCONTAINER_H_
#include <assert.h>
#include "PIAlloc.h"
#include "Pi3API.h"
#include "PIStrStr.h"
#include "DeQuote.h"
#include "PiAPI.h"
#include <jni.h> /* where everything is defined */
#undef SERVLET_REF
#ifdef WIN32
#ifdef _EXPORTING
#define SERVLET_REF __declspec(dllexport)
#else
#define SERVLET_REF __declspec(dllimport)
#endif
#else
#define SERVLET_REF
#endif
/*
** #define D { cerr << __FILE__ << ": " << __LINE__ << endl; }
*/
#define D
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
#define CONFIG_ERR(this, msg) \
{ PILog_addMessage( PIObject_getDB(this), \
PIObject_getConfigurationDB(this), PILOG_ERROR, "%s", (msg) ); }
#define CONFIG_WARN(this, msg) \
{ PILog_addMessage( PIObject_getDB(this), \
PIObject_getConfigurationDB(this), PILOG_WARNING, (msg) ); }
#define KEY_CONF_JVMOPTION "JvmOption"
#define KEY_CONF_JVMNUMBER "JvmNumber"
#define KEY_CONF_JVMIGNOREUNRECOGN "JvmIgnoreUnrecognized"
#define KEY_CONF_JVMLOCALREFS "JvmLocalReferences"
#define KEY_CONF_SERVLETLOGFILE "LogFile"
#define KEY_CONF_OPENMODE "OpenMode"
#define KEY_CONF_EXPRESSION "Expression"
#define KEY_CONF_DOCBASE "DocBase"
#define MAX_VMOPTIONS 16
#define MAX_JVMNUMBER 1
#define MAX_LOCAL_CAPACITY 128
class HandlerBaseServlet;
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
class ServletContainer
{
friend class HandlerBaseServlet;
private:
/* ---
Configuration data
--- */
PIObject *pObject; /* the object */
int iOK; /* status */
PIDB *pServlets; /* DB for registered Servlets */
JNIEnv *env; /* the JNI environment */
JavaVM *jvm; /* denotes a Java VM */
jobject jSessionPool;
jobject jJspFactory;
jobject jContext; /* servlet context */
JavaVMOption options[MAX_VMOPTIONS]; /* VM init options */
int iOptions; /* the actual used options */
int numJVM;
int numLocalRefs;
int ignoreUnrecognized;
PIString sOpenMode; /* file open mode */
PIPLATFORM_FD logfile;
PIString sLogfileName;
Pi3Expression *pExpr; /* expression to log */
PIString sDocBase; /* document root for servlet context */
void *pStartupTID;
int createSessionPool( JNIEnv *env );
int validateSessionPool( JNIEnv *env );
int setDefaultJspFactory( JNIEnv *env );
int createServletContext( JNIEnv *env );
protected:
inline JavaVM *JVM() { return jvm; };
inline JNIEnv *ENV() { return env; };
inline Pi3Expression *Expression() { return pExpr; }
inline jobject SessionPool() { return jSessionPool; };
inline jobject ServletContext() { return jContext; };
static int ParameterFn( void *pData, const char *pVar, const char *pVal,
const char *pWhere )
{
assert( pData );
return ((ServletContainer *)pData)->Parameter( pVar, pVal,
pWhere ? pWhere : "" );
};
int LoadExpression( const char *pName, Pi3Expression **ppExpression,
FnPi3Write *pFunctions, const char *pValue, PIOStrStream &os );
int Parameter( const char *pVariable, const char *pValue,
const char *pWhere );
public:
ServletContainer( PIObject *pObj, int iArgc, const char *ppArgv[] );
virtual ~ServletContainer();
int Log( PIHTTP *pPIHTTP, const char *msg );
int registerServlet( const char *ClassName, jobject Servlet );
int unregServlet( const char *ClassName );
jobject getServlet( const char *ClassName );
SERVLET_REF int Log( const char *msg );
inline int IsOK() { return iOK; };
inline PIObject *Object() { return pObject; };
inline int validateSessions(JNIEnv *Env) { return validateSessionPool(Env); };
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -