@ConfigurationDescription(properties=, validator=EmbeddedServletService.ConfigurationValidator.class) public class EmbeddedServletService extends AbstractADEPT2Service implements ServletService
| Modifier and Type | Class and Description |
|---|---|
static class |
EmbeddedServletService.ConfigurationValidator
Validates the configuration of the embedded servlet service, that is, an
instance of
ServletContext needs to be provided and the URL of
the outer servlet. |
AbstractADEPT2Service.ActiveSessions| Modifier and Type | Field and Description |
|---|---|
protected java.net.URL |
baseUrl
The base URL of the servlet, that is the protocol, the host, the port and
usually the servlet name or the name of the corresponding deployment file.
|
static java.lang.String |
CONF_SERVLET_CONTEXT
The configuration key with which to store a servlet context in the
configuration.
|
static java.lang.String |
CONF_SERVLET_URL
The configuration key with which to store the URL of the servlet.
|
protected javax.servlet.ServletContext |
sc
The context of the outer servlet.
|
protected java.util.Map<Pair<java.lang.String,java.lang.String>,Pair<DynamicServlet,javax.servlet.ServletContext>> |
servlets
All servlets deployed via this service.
|
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices| Modifier | Constructor and Description |
|---|---|
|
EmbeddedServletService(Configuration conf,
Registry registry)
Creates a new embedded servlet service using Servlet API 3.0 for deploying
servlets.
|
protected |
EmbeddedServletService(Configuration conf,
Registry registry,
java.lang.Class<?> cls)
Creates a new embedded servlet service using Servlet API 3.0 for deploying
servlets.
|
| Modifier and Type | Method and Description |
|---|---|
java.net.URL |
deployWebApp(java.lang.String hierarchicalContext,
java.lang.Class<?> baseClass,
DynamicServlet servlet,
java.util.Map<java.lang.String,java.lang.String> initParams,
java.util.Map<java.lang.String,java.lang.Object> contextAttrs,
java.lang.String urlMapping)
Deploys the designated servlet via this service with the designated
hierarchical context having the designated servlet context attributes.
|
java.net.URL |
deployWebApp(java.lang.String hierarchicalContext,
DynamicServlet servlet,
java.util.Map<java.lang.String,java.lang.Object> contextAttrs)
Deploys the designated servlet via this service with the designated
hierarchical context having the designated servlet context attributes.
|
java.net.URL |
getBaseURL()
Gets the base URL (without any context information) of the underlying
servlet container.
|
javax.servlet.ServletContext |
getServletContext(java.lang.Class<?> baseClass)
Gets the servlet context this servlet service runs in.
|
void |
undeployWebApp(java.lang.String hierarchicalContext,
java.lang.String servletName)
Undeploys the designated servlet deployed with the designated hierarchical
context and servlet name.
|
_sessionActive, _sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, getUserCredentials, init, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, shutdown, signalShutdown, signalStart, start, unprivilegeThreadclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, shutdown, startpublic static final java.lang.String CONF_SERVLET_CONTEXT
public static final java.lang.String CONF_SERVLET_URL
protected final java.util.Map<Pair<java.lang.String,java.lang.String>,Pair<DynamicServlet,javax.servlet.ServletContext>> servlets
protected final javax.servlet.ServletContext sc
protected final java.net.URL baseUrl
public EmbeddedServletService(Configuration conf, Registry registry) throws ConfigurationException
conf - The configuration of this service.registry - The registry to be used for accessing services by this
service. This is provided as parameter to the constructor when
creating a service.ConfigurationException - If there are problems parsing the servlet
URL, a ConfigurationException will be thrown.protected EmbeddedServletService(Configuration conf, Registry registry, java.lang.Class<?> cls) throws ConfigurationException
conf - The configuration of this service.registry - The registry to be used for accessing services by this
service. This is provided as parameter to the constructor when
creating a service.cls - The class specifying the name of the logger of this service.ConfigurationException - If there are problems parsing the servlet
URL, a ConfigurationException will be thrown.public java.net.URL getBaseURL()
ServletServicegetBaseURL in interface ServletServicepublic javax.servlet.ServletContext getServletContext(java.lang.Class<?> baseClass)
baseClass - The class with which to load resources. This allows to
have a WEB-INF-directory which is not at the
top-level. It is expected to be besides this class. If this is
null, the usual behaviour applies which is a
top-level WEB-INF-directory.public java.net.URL deployWebApp(java.lang.String hierarchicalContext,
DynamicServlet servlet,
java.util.Map<java.lang.String,java.lang.Object> contextAttrs)
throws ServletDeploymentException
ServletServiceNote that in case of an embedded servlet service, that is this service running within a servlet context, deploying service has to take place before the surrounding servlet context has been initialised.
deployWebApp in interface ServletServicehierarchicalContext - The hierarchical context of the servlet. This
corresponds to the file or directory name when deploying in the
file system (no trailing "/").servlet - The servlet which to deploy dynamically. Make sure that the
servlet name is set appropriately since this is required for
undeploying.contextAttrs - The attributes added to the servlet context when
deploying the servlet. Make sure that the keys are unique! In case
of an embedded servlet service, all servlets will have the very
same context. This may be null.ServletDeploymentException - If there are problems deploying the
designated servlet, a ServletDeploymentException
having no cause will be thrown, otherwise the causing exception
will be wrapped (mostly problems with URL-encoding or servlet
container configuration.public java.net.URL deployWebApp(java.lang.String hierarchicalContext,
java.lang.Class<?> baseClass,
DynamicServlet servlet,
java.util.Map<java.lang.String,java.lang.String> initParams,
java.util.Map<java.lang.String,java.lang.Object> contextAttrs,
java.lang.String urlMapping)
throws ServletDeploymentException
ServletServiceNote that in case of an embedded servlet service, that is this service running within a servlet context, deploying service has to take place before the surrounding servlet context has been initialised.
deployWebApp in interface ServletServicehierarchicalContext - The hierarchical context of the servlet. This
corresponds to the file or directory name when deploying in the
file system (no trailing "/").baseClass - The class with which to load resources. This allows to
have a WEB-INF-directory which is not at the
top-level. It is expected to be besides this class. If this is
null, the usual behaviour applies which is a
top-level WEB-INF-directory.servlet - The servlet which to deploy dynamically. Make sure that the
servlet name is set appropriately since this is required for
undeploying.initParams - The init parameters of the servlet. This may be
null.contextAttrs - The attributes added to the servlet context when
deploying the servlet. Make sure that the keys are unique! In case
of an embedded servlet service, all servlets will have the very
same context. This may be null.urlMapping - The mapping for the designated servlet. This corresponds
to URL-pattern in the deployment descriptor. If this is
null, the default mapping "/" will be used.ServletDeploymentException - If there are problems deploying the
designated servlet, a ServletDeploymentException
having no cause will be thrown, otherwise the causing exception
will be wrapped (mostly problems with URL-encoding or servlet
container configuration.public void undeployWebApp(java.lang.String hierarchicalContext,
java.lang.String servletName)
throws ServletDeploymentException
ServletServiceundeployWebApp in interface ServletServicehierarchicalContext - The hierarchical context with which the servlet
has been deployed.servletName - The name of the servlet which to undeploy.ServletDeploymentException - If there are problems undeploying the
designated web application, a
ServletDeploymentException will be thrown. If this
is due to undeploying a non existing web application, it will
have no cause, problems when stopping the servlet will have the
appropriate cause.