|
|||||||||
| Home >> All >> org >> enhydra >> servlet >> [ servletManager overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.enhydra.servlet.servletManager
Class ServletManager

java.lang.Objectorg.enhydra.servlet.servletManager.ServletManager
- All Implemented Interfaces:
- java.lang.Runnable
- public class ServletManager
- extends java.lang.Object
- implements java.lang.Runnable
- extends java.lang.Object
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.
| Nested Class Summary | |
(package private) class |
ServletManager.SingleContextServer
|
(package private) class |
ServletManager.TableEntry
|
| 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. |
private void |
applyFilters(java.lang.String servletID)
|
private org.apache.tomcat.core.Context |
buildContext(java.lang.String servletID)
|
private java.lang.String |
buildKey(java.lang.String id,
java.lang.String path)
Build a key out of the servletid and the path if the path is null this is the base context that will be stored by the servletid only. |
private org.apache.tomcat.core.Context |
createContext(java.lang.String servletID,
java.lang.String path)
Create the context. |
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. |
private org.apache.tomcat.core.Context |
getContext(java.lang.String id,
java.lang.String path)
|
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. |
private java.net.URL |
getURLFromPath(java.lang.String path)
helper function to convert a string fie name to a url |
private void |
initContext(org.apache.tomcat.core.Context context,
org.apache.tomcat.core.Context baseContext,
java.lang.String path,
java.net.URL url,
java.lang.String servletID)
|
org.apache.tomcat.core.Context |
lookuptContextByPath(java.lang.String path)
|
private static java.util.Properties |
parsePropertyString(java.lang.String properties)
|
private void |
putContext(java.lang.String id,
java.lang.String path,
org.apache.tomcat.core.Context context)
|
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,
com.lutris.util.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 |
private void |
removeContext(java.lang.String id,
java.lang.String path)
|
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(org.enhydra.servlet.connectionMethods.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 |
private void |
startEnhydraApp(java.lang.String servletID,
ServletManager.TableEntry t)
|
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 |
SESSION_MANAGER_KEY
public static final java.lang.String SESSION_MANAGER_KEY
- Attribute key to store session manager in context.
- See Also:
- Constant Field Values
RPMBufferSize
private static final int RPMBufferSize
- See Also:
- Constant Field Values
SERVER_INFO_DISPLAY
private static final java.lang.String SERVER_INFO_DISPLAY
- See Also:
- Constant Field Values
contextByKey
private java.util.Hashtable contextByKey
filters
private java.util.Hashtable filters
logChannel
private com.lutris.logging.LogChannel logChannel
myTable
private java.util.Hashtable myTable
myMime
private com.lutris.http.MimeType myMime
RPM_thread
private java.lang.Thread RPM_thread
RPM_stayAlive
private boolean RPM_stayAlive
defaultSessionTimeOutDefault
private static java.lang.String defaultSessionTimeOutDefault
isWARExpandedDefault
private static java.lang.String isWARExpandedDefault
isWARValidatedDefault
private static java.lang.String isWARValidatedDefault
isInvokerEnabledDefault
private static java.lang.String isInvokerEnabledDefault
isWorkDirPersistentDefault
private static java.lang.String isWorkDirPersistentDefault
workDir
private java.lang.String workDir
rez
org.enhydra.i18n.ResManager rez
contextManager
private org.apache.tomcat.core.ContextManager contextManager
- The Tomcat ContextManager used to handle servlet requests.
defaultContext
private org.apache.tomcat.core.Context defaultContext
- The default context
| Constructor Detail |
ServletManager
public ServletManager()
- Create a new ServletManager, initially containing no Servlets.
| Method Detail |
setWorkDir
public void setWorkDir(java.lang.String workDir)
destroy
public void destroy()
- Shut down the ServletManager. This stops all the Servlets, then
deletes all the Servlets, then kills the statistics gathering
thread. There is no way to restart the thread.
run
public void run()
- This function is for internal use only. Do not call this method.
When the request per minute monitoring thread starts, this is
the code it starts executing. The thread sleeps, waking up once
a minute to compute the current request per minute stats, and the
maximum request per minute stats.
- Specified by:
runin interfacejava.lang.Runnable
add
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
- Register a new Servlet with the ServletManager. You pass in
everything needed to find and create the Servlet, but it is not
created until
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 usejava.io.File.pathSeparatorCharbetween 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 wascom.lutrisit would allow access tocom.lutris.TheClassas well ascom.lutrisMisc.UnwatedClass. If the mask wascom.lutris.the classUnwantedClasswould not be loaded from this source.
buildKey
private java.lang.String buildKey(java.lang.String id, java.lang.String path)
- Build a key out of the servletid and the path if the path is null
this is the base context that will be stored by the servletid only.
the separator between the id and the path is some string that can never
be in the id. e.g. a space.
putContext
private void putContext(java.lang.String id, java.lang.String path, org.apache.tomcat.core.Context context)
removeContext
private void removeContext(java.lang.String id, java.lang.String path)
getContext
private org.apache.tomcat.core.Context getContext(java.lang.String id, java.lang.String path)
recordContextPath
public void recordContextPath(java.lang.String servletID, java.lang.String urlPrefix) throws org.enhydra.servlet.connectionMethods.ConnectionMethodException
- Record the url prefix that will be used by the context
The url path for the context is set when the channel is defined.
This is after the application is defined in the .conf file.
removeContextPath
public void removeContextPath(java.lang.String servletID, java.lang.String urlPrefix)
- A channel has been closed remove the context.
recordWarOnlySettings
public 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
recordSessionConfig
public void recordSessionConfig(java.lang.String servletID, com.lutris.util.Config sessionConfig)
- The context may have configuration information relating to the
sessionManager
startAllContexts
public void startAllContexts()
throws javax.servlet.ServletException
- 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
buildContext
private org.apache.tomcat.core.Context buildContext(java.lang.String servletID) throws javax.servlet.ServletException
createContext
private org.apache.tomcat.core.Context createContext(java.lang.String servletID, java.lang.String path)
- Create the context. (duh?)
applyFilters
private void applyFilters(java.lang.String servletID)
initContext
private void initContext(org.apache.tomcat.core.Context context, org.apache.tomcat.core.Context baseContext, java.lang.String path, java.net.URL url, java.lang.String servletID)
addFilter
public 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.
removeFilter
public void removeFilter(java.lang.String servletID, java.lang.String filterID)
service
public void service(org.enhydra.servlet.connectionMethods.Channel channel, org.apache.tomcat.core.Request rrequest, org.apache.tomcat.core.Response rresponse) throws java.lang.Exception
- Service the request. The servletManager is taking over the role that the
ContextManager plays in Tomcat. So this routine is a close copy of the
ContextManager's
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.
start
public void start(java.lang.String servletID) throws javax.servlet.ServletException
- Force the instantiation of a Servlet. It will be created, and it's
init()method will be called.
startEnhydraApp
private void startEnhydraApp(java.lang.String servletID, ServletManager.TableEntry t) throws javax.servlet.ServletException
stop
public void stop(java.lang.String servletID) throws javax.servlet.ServletException
- Stop a Servlet. This calls the Servlet's
destroy()method, then discards the Servlet (making it available for garbage collection). After calling this, you may callstart()to cause a new instance of the Servlet to be created.
get
public javax.servlet.Servlet get(java.lang.String servletID) throws javax.servlet.ServletException
- Fetch a Servlet.
If the identifier string can not be found, an exception will be
thrown. If the Servlet has not been started, or if it failed to
start up, then null will be returned. The counters will be incremented
to reflect this access.
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'sservice()method.
get
public javax.servlet.Servlet get(java.lang.String servletID, boolean counter) throws javax.servlet.ServletException
- Fetch a Servlet, with optional control over the counter.
This is exactly like
get(String servletID), except when counter is false, in which case the total references counter, and the requests per minute counter are not incremented.
This should only be used if you are not going to callservice()on the Servlet. It is assumed that the number ofget(String servletID)is exactly the same as the number of timesservice()was called on the Servlet.
getStatus
public ServletStatus getStatus(java.lang.String servletID)
- Get the current status of a Servlet.
getStatistics
public ServletStatistics getStatistics(java.lang.String servletID)
- Get the current request-per-minute statistics of a Servlet.
This returns a copy of all the stored data! In the future we
should return a sub-range of the data.
resetStats
public void resetStats(java.lang.String servletID) throws javax.servlet.ServletException
- Resets the maxmimum requests per minute to the current value,
and the time of the maximum to now.
delete
public void delete(java.lang.String servletID) throws javax.servlet.ServletException
- Unregister a Servlet from the ServletManager.
stop()is called on the Servlet, then it is removed from the set of Servlets. The name servletID is no longer valid.
getServletIDs
public java.lang.String[] getServletIDs()
- Get the names of all the Servlets in the ServletManager.
getServletNames
public java.util.Enumeration getServletNames()
- Get the names of all the Servlets in the ServletManager.
resetRefCount
public void resetRefCount(java.lang.String servletID) throws javax.servlet.ServletException
- Reset the reference count for a particular Servlet.
This is the count of how many times the Servlet was asked for
by
get().
getMimeType
protected java.lang.String getMimeType(java.lang.String file)
- This is for internal use only.
It is part of the Servlet initalization.
parsePropertyString
private static java.util.Properties parsePropertyString(java.lang.String properties)
lookuptContextByPath
public org.apache.tomcat.core.Context lookuptContextByPath(java.lang.String path)
getServerInfoString
public java.lang.String getServerInfoString()
- Get server info string to pass to the contexts
getContextByServletID
public org.apache.tomcat.core.Context getContextByServletID(java.lang.String id)
- Return the Context for the given servlet id.
getURLFromPath
private java.net.URL getURLFromPath(java.lang.String path)
- helper function to convert a string fie name to a url
|
|||||||||
| Home >> All >> org >> enhydra >> servlet >> [ servletManager overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.enhydra.servlet.servletManager.ServletManager