|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.servlet.servletManager.ServletManager
This class loads Servlet classes, creates instances of Servlets, caches the Servlets, and returns pointers to them. The Servlets are refered to by an identifer string (a symbolic name).
First Servlets are registered via add()
. Then they are
started via start()
. Then they are available for
use via get()
.
The ServletManager will call init()
on the Servlet.
It will also call destoroy()
.
Other classes which use Servlets returned by get()
must
not call these two methods. When get()
returns a Servlet,
it is ready to accept service()
calls.
Servlet
,
ServletStatus
Field Summary | |
protected static org.apache.log4j.Logger |
loggerSys
The logger that logs on System.out. |
static java.lang.String |
SESSION_MANAGER_KEY
Attribute key to store session manager in context. |
Constructor Summary | |
ServletManager()
Create a new ServletManager, initially containing no Servlets. |
Method Summary | |
void |
add(java.lang.String servletID,
java.lang.String className,
java.lang.String[] classPath,
java.lang.String docRoot,
java.util.Properties initArgs,
boolean runOnInit,
java.lang.String description,
boolean isWar)
Register a new Servlet with the ServletManager. |
void |
addFilter(java.lang.String servletID,
java.lang.String filterID)
Adds the given filter to the list of filters to be applied to the given servlet when the Context is built. |
void |
delete(java.lang.String servletID)
Unregister a Servlet from the ServletManager. |
void |
destroy()
Shut down the ServletManager. |
javax.servlet.Servlet |
get(java.lang.String servletID)
Fetch a Servlet. |
javax.servlet.Servlet |
get(java.lang.String servletID,
boolean counter)
Fetch a Servlet, with optional control over the counter. |
org.apache.tomcat.core.Context |
getContextByServletID(java.lang.String id)
Return the Context for the given servlet id. |
protected java.lang.String |
getMimeType(java.lang.String file)
This is for internal use only. |
java.lang.String |
getServerInfoString()
Get server info string to pass to the contexts |
java.lang.String[] |
getServletIDs()
Get the names of all the Servlets in the ServletManager. |
java.util.Enumeration |
getServletNames()
Get the names of all the Servlets in the ServletManager. |
ServletStatistics |
getStatistics(java.lang.String servletID)
Get the current request-per-minute statistics of a Servlet. |
ServletStatus |
getStatus(java.lang.String servletID)
Get the current status of a Servlet. |
org.apache.tomcat.core.Context |
lookuptContextByPath(java.lang.String path)
|
void |
recordContextPath(java.lang.String servletID,
java.lang.String urlPrefix)
Record the url prefix that will be used by the context The url path for the context is set when the channel is defined. |
void |
recordSessionConfig(java.lang.String servletID,
Config sessionConfig)
The context may have configuration information relating to the sessionManager |
void |
recordWarOnlySettings(java.lang.String servletID,
java.lang.String defaultSessionTimeout,
java.lang.String isWARExpanded,
java.lang.String isWARValidated,
java.lang.String isInvokerEnabled,
java.lang.String isWorkDirPersistent)
These are values that only apply to a WAR |
void |
removeContextPath(java.lang.String servletID,
java.lang.String urlPrefix)
A channel has been closed remove the context. |
void |
removeFilter(java.lang.String servletID,
java.lang.String filterID)
|
void |
resetRefCount(java.lang.String servletID)
Reset the reference count for a particular Servlet. |
void |
resetStats(java.lang.String servletID)
Resets the maxmimum requests per minute to the current value, and the time of the maximum to now. |
void |
run()
This function is for internal use only. |
void |
service(Channel channel,
org.apache.tomcat.core.Request rrequest,
org.apache.tomcat.core.Response rresponse)
Service the request. |
void |
setWorkDir(java.lang.String workDir)
|
void |
start(java.lang.String servletID)
Force the instantiation of a Servlet. |
void |
startAllContexts()
After all the configuration information has been collected it's safe to start all contexts that have been marked as runOnInit in the multiserver configuration file |
void |
stop(java.lang.String servletID)
Stop a Servlet. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String SESSION_MANAGER_KEY
protected static org.apache.log4j.Logger loggerSys
Constructor Detail |
public ServletManager()
Method Detail |
public void setWorkDir(java.lang.String workDir)
public void destroy()
public void run()
run
in interface java.lang.Runnable
public void add(java.lang.String servletID, java.lang.String className, java.lang.String[] classPath, java.lang.String docRoot, java.util.Properties initArgs, boolean runOnInit, java.lang.String description, boolean isWar) throws javax.servlet.ServletException
start()
is called on it.
Requests for the Servlet
inbetween the time it is added and started will return null.
After this call, the name passed in as servletID should be used
to refer to the Servlet.
Each element of classPath specifies a source of classes, either
a .jar file, a .zip file, or a directory tree. Each of these sources
has a set of class masks associated with it, initially null.
If a source's set of class masks
is null (the normal condition), then classes are loaded normally.
If the set is not null, then it contains a set of class masks.
Each class mask is a string.
Before a source is searched to see if it contains
a given class, the name of the class is compared with the class masks.
Only if the requested class name begins with one of the class masks
will it be loaded from the source. This lets you specify, for example,
a jar file, but limit access to a specific class, or a set of classes
that start with a common string. The syntax for specifing class
masks is (on Unix): pathname:mask,mask,...,mask
.
If no masks are specified (the normal usage), then any class found
via the pathname is used. Be sure to use
java.io.File.pathSeparatorChar
between the pathname
and the mask list (this will be : on Unix, and ; on Windows and
Macintosh). If the class mask does not specifiy a full class name,
you may want to end it with a period. For example, if your mask was
com.lutris
it would allow access to
com.lutris.TheClass
as well as
com.lutrisMisc.UnwatedClass
. If the mask was
com.lutris.
the class UnwantedClass
would not be loaded from this source.
servletID
- The identifier string used to refer to this
Servlet.className
- The name of the class to instantiate. It must
implement the Servlet interface.classPath
- An array of directories, .zip files or .jar files.
The Servlet will be loaded by it's own class loader, which will
look in these locations first. If a class is not found, the system
class loader will be used (which uses the CLASSPATH Java started
the MultiServer with).docRoot
- The root of the Servlet's filesystem on disk?initArgs
- The initial arguments to the Servlet. These will be
made available to the Servlet's init()
method.
These names and values are accessed
via the ServletConfig object passed to the Servlet's
init()
method.description
- A human readable description of this Servlet.
javax.servlet.ServletException
- If there is an error.Servlet
public void recordContextPath(java.lang.String servletID, java.lang.String urlPrefix) throws ConnectionMethodException
servletID
- The name of the contexturlPrefix
- The start of the URL that leads to this context
ConnectionMethodException
public void removeContextPath(java.lang.String servletID, java.lang.String urlPrefix)
servletID
- The name of the contexturlPrefix
- The start of the URL that leads to this contextpublic void recordWarOnlySettings(java.lang.String servletID, java.lang.String defaultSessionTimeout, java.lang.String isWARExpanded, java.lang.String isWARValidated, java.lang.String isInvokerEnabled, java.lang.String isWorkDirPersistent)
servletID
- The id of the ContextdefaultSessionTimeout
- isWARExpanded
- isWARValidated
- isInvokerEnabled
- isWorkDirPersistent
- public void recordSessionConfig(java.lang.String servletID, Config sessionConfig)
servletID
- The id of the context.public void startAllContexts() throws javax.servlet.ServletException
java.lang.Exception
- If there is an error.
javax.servlet.ServletException
public void addFilter(java.lang.String servletID, java.lang.String filterID)
servletID
- a String id for the Context (Servlet).filterID
- a String id for the Filter to apply.public void removeFilter(java.lang.String servletID, java.lang.String filterID)
public void service(Channel channel, org.apache.tomcat.core.Request rrequest, org.apache.tomcat.core.Response rresponse) throws java.lang.Exception
service()
. The main diffirence is that
contexts can be found ny name rather than by path. Which allows us to
have two contexts with the same urlprefix but diffirent channel's
e.g. diffirent ports.
channel
- The channel that called usrrequest
- rresponse
-
java.lang.Exception
public void start(java.lang.String servletID) throws javax.servlet.ServletException
init()
method will be called.
servletID
- Which Servlet to start.
javax.servlet.ServletException
- If there is an error.public void stop(java.lang.String servletID) throws javax.servlet.ServletException
destroy()
method,
then discards the Servlet (making it available for garbage
collection). After calling this, you may call start()
to
cause a new instance of the Servlet to be created.
servletID
- Which Servlet to stop.
javax.servlet.ServletException
- If there is an error.public javax.servlet.Servlet get(java.lang.String servletID) throws javax.servlet.ServletException
This is the prefered version of get()
. Only call the
other version if you need to get the Servlet and you will not
be calling it's service()
method.
servletID
- Which Servlet to get.
javax.servlet.ServletException
- If the name was not found.public javax.servlet.Servlet get(java.lang.String servletID, boolean counter) throws javax.servlet.ServletException
get(String servletID)
,
except when counter is false, in which case the total references
counter, and the requests per minute counter are not incremented. service()
on the Servlet. It is assumed that the
number of get(String servletID)
is exactly the same
as the number of times service()
was called on the
Servlet.
servletID
- Which Servlet to get.counter
- Should the counters be updated? This should only
be false if you are not going to call service()
on
the returned Servlet.
javax.servlet.ServletException
- If the name was not found.public ServletStatus getStatus(java.lang.String servletID)
servletID
- Which Servlet to get the status of.
ServletStatus
public ServletStatistics getStatistics(java.lang.String servletID)
servletID
- Which Servlet to get the status of.
ServletStatistics
public void resetStats(java.lang.String servletID) throws javax.servlet.ServletException
servletID
- Which Servlet to reset the maximum request
per minute stats for.
javax.servlet.ServletException
- If there is an error, or if the Servlet
ID is not found.public void delete(java.lang.String servletID) throws javax.servlet.ServletException
stop()
is called on the Servlet,
then it is removed from the set
of Servlets. The name servletID is no longer valid.
servletID
- Which Servlet to delete.
javax.servlet.ServletException
- If there is an error, or if the Servlet
ID is not found.public java.lang.String[] getServletIDs()
public java.util.Enumeration getServletNames()
public void resetRefCount(java.lang.String servletID) throws javax.servlet.ServletException
get()
.
servletID
- Which Servlet's counter to reset.
javax.servlet.ServletException
- If there is an error, or if the Servlet
ID is not found.ServletStatus
protected java.lang.String getMimeType(java.lang.String file)
public org.apache.tomcat.core.Context lookuptContextByPath(java.lang.String path)
public java.lang.String getServerInfoString()
public org.apache.tomcat.core.Context getContextByServletID(java.lang.String id)
id
- Serlvet id string.
|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |