public class Serve extends Object implements javax.servlet.ServletContext, Serializable
Modifier and Type | Class and Description |
---|---|
protected static class |
Serve.AcceptLocaleEnumeration |
static interface |
Serve.Acceptor |
static class |
Serve.AcmeSession
Http session support
TODO: provide lazy session restoring, it should allow to load classes from wars 1st step it read serialization data and store under session attribute 2nd
when the session requested, it tries to deserialize all session attributes considered that all classes available
|
protected static class |
Serve.BasicAuthRealm |
protected static class |
Serve.HttpSessionContextImpl |
protected static class |
Serve.LocaleWithWeight |
static class |
Serve.PathTreeDictionary
Class PathTreeDictionary - this class allows to put path elements in format n1/n2/n2[/*.ext] and get match to a pattern and a unmatched tail
|
protected static class |
Serve.ServeConfig |
static class |
Serve.ServeConnection
provides request/response
|
static class |
Serve.ServeInputStream |
static class |
Serve.ServeOutputStream |
protected class |
Serve.SimpleRequestDispatcher |
Constructor and Description |
---|
Serve()
Default constructor to create TJWS as a bean
|
Serve(Map arguments,
PrintStream logStream) |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultServlets(String cgi) |
void |
addDefaultServlets(String cgi,
String throttles)
Register a standard set of Servlets, with optional throttles.
|
void |
addServlet(String urlPat,
javax.servlet.Servlet servlet)
Register a Servlet.
|
void |
addServlet(String urlPat,
javax.servlet.Servlet servlet,
Hashtable initParams)
Register a Servlet
|
void |
addServlet(String urlPat,
String className) |
void |
addServlet(String urlPat,
String className,
Hashtable initParams)
Adds a servlet to run
|
protected void |
addWarDeployer(String deployerFactory,
String throttles) |
protected Serve.Acceptor |
createAcceptor() |
void |
destroyAllServlets() |
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
javax.servlet.ServletContext |
getContext(String uripath) |
String |
getContextPath() |
String |
getInitParameter(String param) |
Enumeration |
getInitParameterNames() |
protected int |
getKeepAliveDuration() |
protected String |
getKeepAliveParamStr() |
int |
getMajorVersion() |
protected int |
getMaxTimesConnectionUse() |
String |
getMimeType(String file) |
int |
getMinorVersion() |
javax.servlet.RequestDispatcher |
getNamedDispatcher(String name) |
protected File |
getPersistentFile() |
String |
getRealPath(String path) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(String urlpath) |
URL |
getResource(String path)
Returns a URL to the resource that is mapped to a specified path.
|
InputStream |
getResourceAsStream(String path)
Returns the resource located at the named path as an
InputStream object. |
Set |
getResourcePaths(String path)
Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.
|
String |
getServerInfo() |
javax.servlet.Servlet |
getServlet(String name) |
String |
getServletContextName()
Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the
display-name element.
|
Enumeration |
getServletNames() |
Enumeration |
getServlets() |
void |
init() |
protected void |
initMime() |
protected boolean |
isAccessLogged() |
protected boolean |
isKeepAlive() |
protected boolean |
isShowReferer() |
protected boolean |
isShowUserAgent() |
void |
log(Exception exception,
String message) |
void |
log(String message) |
void |
log(String message,
Throwable throwable) |
void |
notifyStop()
Tells the server to stop
|
void |
removeAttribute(String name) |
void |
runInBackground() |
int |
serve()
Launches the server
It doesn't exist until server runs, so start it in a dedicated thread.
|
protected void |
setAccessLogged() |
void |
setAttribute(String name,
Object object) |
protected void |
setMappingTable(Serve.PathTreeDictionary mappingtable) |
protected void |
setRealms(Serve.PathTreeDictionary realms) |
void |
stopBackground() |
javax.servlet.Servlet |
unloadServlet(javax.servlet.Servlet servlet) |
void |
unloadServlet(String urlPat) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addFilter, addFilter, addFilter, addListener, addListener, addListener, addServlet, createFilter, createListener, createServlet, declareRoles, getClassLoader, getDefaultSessionTrackingModes, getEffectiveMajorVersion, getEffectiveMinorVersion, getEffectiveSessionTrackingModes, getFilterRegistration, getFilterRegistrations, getJspConfigDescriptor, getServletRegistration, getServletRegistrations, getSessionCookieConfig, getVirtualServerName, setInitParameter, setSessionTrackingModes
public static final String ARG_PORT
public static final String ARG_THROTTLES
public static final String ARG_SERVLETS
public static final String ARG_REALMS
public static final String ARG_ALIASES
public static final String ARG_BINDADDRESS
public static final String ARG_BACKLOG
public static final String ARG_CGI_PATH
public static final String ARG_ERR
public static final String ARG_OUT
public static final String ARG_SESSION_TIMEOUT
public static final String ARG_LOG_DIR
public static final String ARG_LOG_OPTIONS
public static final String ARG_NOHUP
public static final String ARG_JSP
public static final String ARG_WAR
public static final String ARG_KEEPALIVE
public static final String DEF_LOGENCODING
public static final String ARG_KEEPALIVE_TIMEOUT
public static final String ARG_MAX_CONN_USE
public static final String ARG_SESSION_PERSIST
public static final String ARG_MAX_ACTIVE_SESSIONS
public static final String ARG_ACCESS_LOG_FMT
public static final String ARG_ACCEPTOR_CLASS
public static final String ARG_WORK_DIRECTORY
public static final String ARG_SESSION_SEED
public static final String ARG_THREAD_POOL_SIZE
protected static final int DEF_SESSION_TIMEOUT
protected static final int DEF_MIN_ACT_SESS
protected static final int DESTROY_TIME_SEC
protected static final int HTTP_MAX_HDR_LEN
public static final int DEF_PORT
public static final String BGCOLOR
protected static final int DEF_MAX_CONN_USE
public static final String UTF8
protected String hostName
protected String keepAliveHdrParams
protected transient Serve.PathTreeDictionary registry
protected transient Serve.PathTreeDictionary realms
protected transient Serve.PathTreeDictionary mappingtable
protected transient Acme.Serve.Serve.KeepAliveCleaner keepAliveCleaner
protected transient ThreadGroup serverThreads
protected transient Utils.ThreadPool threadPool
protected transient Constructor gzipInStreamConstr
protected Serve.HttpSessionContextImpl sessions
protected int expiredIn
public Map arguments
public Properties mime
protected List<Serve.ServeConnection> connections
protected transient Serve.Acceptor acceptor
protected transient Thread ssclThread
protected transient boolean initialized
protected CountDownLatch shutdownLatch
protected Thread backgroundThread
public Serve(Map arguments, PrintStream logStream)
public Serve()
protected void setAccessLogged()
protected boolean isAccessLogged()
protected boolean isShowReferer()
protected boolean isShowUserAgent()
protected boolean isKeepAlive()
protected int getKeepAliveDuration()
protected String getKeepAliveParamStr()
protected int getMaxTimesConnectionUse()
protected void initMime()
public void addServlet(String urlPat, String className)
addServlet
in interface javax.servlet.ServletContext
public void addServlet(String urlPat, String className, Hashtable initParams)
urlPat
- servlet invoker URL patternclassName
- servlet class nameinitParams
- servlet init parameterspublic void addServlet(String urlPat, javax.servlet.Servlet servlet)
addServlet
in interface javax.servlet.ServletContext
urlPat
- servlet invoker URL patternservlet
- already instantiated servlet but initpublic void addServlet(String urlPat, javax.servlet.Servlet servlet, Hashtable initParams)
urlPat
- servlet
- initParams
- public javax.servlet.Servlet unloadServlet(javax.servlet.Servlet servlet)
public void unloadServlet(String urlPat)
public void addDefaultServlets(String cgi)
public void addDefaultServlets(String cgi, String throttles) throws IOException
cgi
- whether to run CGI programsthrottles
- filename to read FileServlet throttle settings from, can be nullIOException
protected File getPersistentFile()
public void runInBackground()
public void stopBackground()
public int serve()
public void init() throws IOException
IOException
public void notifyStop() throws IOException
IOException
protected Serve.Acceptor createAcceptor() throws IOException
IOException
public javax.servlet.Servlet getServlet(String name)
getServlet
in interface javax.servlet.ServletContext
public Enumeration getServlets()
getServlets
in interface javax.servlet.ServletContext
public Enumeration getServletNames()
getServletNames
in interface javax.servlet.ServletContext
public void destroyAllServlets()
protected void setMappingTable(Serve.PathTreeDictionary mappingtable)
protected void setRealms(Serve.PathTreeDictionary realms)
public void log(String message)
log
in interface javax.servlet.ServletContext
public void log(String message, Throwable throwable)
log
in interface javax.servlet.ServletContext
public void log(Exception exception, String message)
log
in interface javax.servlet.ServletContext
public String getRealPath(String path)
getRealPath
in interface javax.servlet.ServletContext
public String getContextPath()
getContextPath
in interface javax.servlet.ServletContext
public String getMimeType(String file)
getMimeType
in interface javax.servlet.ServletContext
public String getServerInfo()
getServerInfo
in interface javax.servlet.ServletContext
public Object getAttribute(String name)
getAttribute
in interface javax.servlet.ServletContext
public void removeAttribute(String name)
removeAttribute
in interface javax.servlet.ServletContext
public void setAttribute(String name, Object object)
setAttribute
in interface javax.servlet.ServletContext
public Enumeration getAttributeNames()
getAttributeNames
in interface javax.servlet.ServletContext
public javax.servlet.ServletContext getContext(String uripath)
getContext
in interface javax.servlet.ServletContext
public int getMajorVersion()
getMajorVersion
in interface javax.servlet.ServletContext
public int getMinorVersion()
getMinorVersion
in interface javax.servlet.ServletContext
public Set getResourcePaths(String path)
getResourcePaths
in interface javax.servlet.ServletContext
the
- -
partial path used to match the resources, which must start with a /public String getServletContextName()
getServletContextName
in interface javax.servlet.ServletContext
public URL getResource(String path) throws MalformedURLException
.war
file.
The servlet container must implement the URL handlers and URLConnection
objects that are necessary to access the resource.
This method returns null
if no resource is mapped to the pathname.
Some containers may allow writing to the URL returned by this method using the methods of the URL class.
The resource content is returned directly, so be aware that requesting a .jsp
page returns the JSP source code. Use a
RequestDispatcher
instead to include results of an execution.
This method has a different purpose than java.lang.Class.getResource
, which looks up resources based on a class loader. This method does
not use class loaders.getResource
in interface javax.servlet.ServletContext
path
- a String
specifying the path to the resourcenull
if there is no resource at that pathMalformedURLException
- if the pathname is not given in the correct formpublic InputStream getResourceAsStream(String path)
InputStream
object.
The data in the InputStream
can be of any type or length. The path must be specified according to the rules given in
getResource
. This method returns null
if no resource exists at the specified path.
Meta-information such as content length and content type that is available via getResource
method is lost when using this method.
The servlet container must implement the URL handlers and URLConnection
objects necessary to access the resource.
This method is different from java.lang.Class.getResourceAsStream
, which uses a class loader. This method allows servlet containers to
make a resource available to a servlet from any location, without using a class loader.getResourceAsStream
in interface javax.servlet.ServletContext
path
- a String
specifying the path to the resourceInputStream
returned to the servlet, or null
if no resource exists at the specified pathpublic javax.servlet.RequestDispatcher getRequestDispatcher(String urlpath)
getRequestDispatcher
in interface javax.servlet.ServletContext
public String getInitParameter(String param)
getInitParameter
in interface javax.servlet.ServletContext
public Enumeration getInitParameterNames()
getInitParameterNames
in interface javax.servlet.ServletContext
public javax.servlet.RequestDispatcher getNamedDispatcher(String name)
getNamedDispatcher
in interface javax.servlet.ServletContext
Copyright © 2015 JBoss by Red Hat. All rights reserved.