|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.GenericServer SK.gnome.dwarf.http.ServletWrapper
This class wraps the servlet instances.
This class implements the javax.servlet.ServletConfig interface, which provides
a way how to configure the servlet environment. Each servlet object must be wrapped by an
instance of this class in order to be added to the Application
.
Field Summary | |
protected SK.gnome.dwarf.utils.cache.Cache |
cache
The cache instance. |
protected SK.gnome.dwarf.utils.Counter |
counter
The servlet statistics. |
protected java.lang.String |
mapping
The servlet mapping. |
protected javax.servlet.Servlet |
servlet
The servlet instance. |
protected java.lang.String |
servletClass
The servlet class. |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
ServletWrapper(java.lang.String name)
Creates a new ServletWrapper. |
Method Summary | |
void |
addService(SK.gnome.dwarf.Service service)
Adds a service to the server. |
SK.gnome.dwarf.utils.cache.Cache |
getCache()
Returns the cache instance. |
java.lang.String |
getInitParameter(java.lang.String name)
Returns a String containing the value of the
named initialization parameter, or null if
the parameter does not exist. |
java.util.Enumeration |
getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects,
or an empty Enumeration if the servlet has
no initialization parameters. |
java.lang.String |
getMapping()
Returns the servlet path mapping. |
javax.servlet.ServletContext |
getServletContext()
Returns a reference to the ServletContext in which the servlet is executing. |
java.lang.String |
getServletName()
Returns the name of this servlet instance. |
protected int |
getShutdownTimeout()
Returns the shutdown timeout. |
void |
init(SK.gnome.dwarf.Server parent)
Initializes the service. |
java.lang.String |
report()
Returns the service report. |
void |
service(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Services the request. |
void |
setMapping(java.lang.String mapping)
Sets the servlet mapping. |
void |
setServletClass(java.lang.String servletClass)
Sets the servlet class. |
void |
shutdown()
Shuts down the service. |
Methods inherited from class SK.gnome.dwarf.GenericServer |
addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, start, stop |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthFacility, getFullName, getLogFacility, getName, getPrincipal, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface SK.gnome.dwarf.Service |
getFullName, getName, getState, log, log, login, logout |
Field Detail |
protected java.lang.String servletClass
setServletClass(String)
protected javax.servlet.Servlet servlet
protected java.lang.String mapping
Contains mapping between the URL patterns and servlets. The list of URL patterns separated by commas may be specified instead of a single pattern.
setMapping(String)
protected SK.gnome.dwarf.utils.cache.Cache cache
Contains a reference to the SK.gnome.dwarf.utils.cache.Cache implementation if it is contained by the servlet wrapper. The derived classes should feel free to use it for any purpose.
The field value is initialized in the addService
method.
protected SK.gnome.dwarf.utils.Counter counter
Contains the current/peak/total number of requests served by this servlet since it was initialized.
Constructor Detail |
public ServletWrapper(java.lang.String name)
Method Detail |
public void setServletClass(java.lang.String servletClass)
servletClass
- the classservletClass
public void setMapping(java.lang.String mapping)
mapping
- the mappingmapping
public java.lang.String getMapping()
mapping
public SK.gnome.dwarf.utils.cache.Cache getCache()
cache
public void addService(SK.gnome.dwarf.Service service) throws SK.gnome.dwarf.ServiceException
If the service being added to the ServletWrapper is an implementation
of the SK.gnome.dwarf.util.Cache interface, it is stored also in the
cache
field.
The method does not allow to add a service implementing the Parameters
interface since the HTTPParameters
must be inherited from the HTTP
server object.
addService
in interface SK.gnome.dwarf.Server
SK.gnome.dwarf.ServiceException
public void init(SK.gnome.dwarf.Server parent) throws SK.gnome.dwarf.ServiceException
It loads and initializes the servlet instance according to the value of the
servletClass
field. Any exception throwed by the servlet's init method
is catched and forwarded as the ServiceException.
init
in interface SK.gnome.dwarf.Service
SK.gnome.dwarf.ServiceException
public void shutdown()
It waits for all requests being currently serviced by the servlet to complete, then destroys the servlet instance by invoking its destroy method.
shutdown
in interface SK.gnome.dwarf.Service
protected int getShutdownTimeout()
It returns the Constants.DEFAULT_SHUTDOWN_TIMEOUT
value if the persistent
connections are not enabled, or the value returned from the getKeepAliveTimeout
method in the opposit case.
public java.lang.String report()
Returns the servlet class, init parameters and current/peak/total number of requests serviced by the servlet so far.
report
in interface SK.gnome.dwarf.Reportable
public void service(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Calls the servlets' service method and updates the counter
.
If the servlet instance implements the SingleThreadModel interface, the calls
to the service method are serialized.
java.io.IOException
javax.servlet.ServletException
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.ServletConfig
ServletContext
public java.lang.String getInitParameter(java.lang.String name)
String
containing the value of the
named initialization parameter, or null
if
the parameter does not exist.
getInitParameter
in interface javax.servlet.ServletConfig
name
- a String
specifying the name
of the initialization parameter
String
containing the value
of the initialization parameterpublic java.util.Enumeration getInitParameterNames()
Enumeration
of String
objects,
or an empty Enumeration
if the servlet has
no initialization parameters.
getInitParameterNames
in interface javax.servlet.ServletConfig
Enumeration
of String
objects containing the names of the servlet's
initialization parameterspublic java.lang.String getServletName()
getServletName
in interface javax.servlet.ServletConfig
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |