Class EmbdServContHTTPService
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.service.AbstractAuthenticatedService
-
- de.aristaflow.adept2.ui.htmlgui.httpservice.EmbdServContHTTPService
-
- All Implemented Interfaces:
ADEPT2Service
,AuthenticatingService
,LogService
,ServiceThreadHandling
,HTTPService
public class EmbdServContHTTPService extends AbstractAuthenticatedService implements HTTPService
Simple HTTP service based on aServletService
(an embedded servlet container). This delegates to theAristaFlowHTTPService
-servlet implementingdoGet
anddoPost
-methods.- Author:
- Kevin Goeser, Ulrich Kreher
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description protected AristaFlowHTTPService
httpService
The HTTP service (servlet) handling the requests.protected static String
WEB_APP_CONTEXT
The hierarchical context of the servlet.protected static String
WEB_APP_NAME
The name used for the publishing the servlet, that is as servlet name.-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
CFG_EARLY_SERVICEAUTH_ORGPOSID, CFG_EARLY_SERVICEAUTH_ORGPOSNAME, CFG_EARLY_SERVICEAUTH_PASSWORD, CFG_EARLY_SERVICEAUTH_USERNAME, CFG_SERVICEAUTH_ORGPOSID, CFG_SERVICEAUTH_ORGPOSNAME, CFG_SERVICEAUTH_PASSWORD, CFG_SERVICEAUTH_USERNAME
-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
-
Constructor Summary
Constructors Constructor Description EmbdServContHTTPService(org.apache.commons.configuration2.Configuration configuration, Registry registry)
Registers the HTTP-service-servlet at an embedded servlet container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deregisterReplyHandler(SessionToken session, String sessionID)
Deregisters a reply handler for the activity with the designatedsessionID
.boolean
isActive()
Allows waiting reply handlers to retrieve the state of the HTTP-service.void
registerReplyHandler(SessionToken session, String sessionID, HTTPReplyHandler replayHandler)
Registers a reply handler for the activity with the designatedsessionID
.void
shutdown(boolean emergency)
Removes the HTTP-service-servlet from theServletService
.void
start()
Adds the HTTP-service-servlet to theServletService
.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
_sessionActive, authenticateService, awaitActiveSessions, createChildSession, createSession, getAgent, getSecurityManager, getSessionFactory, getStartupRequired, getTopLevelAgent, getUserCredentials, globalSecurityManagerAvailable, init, isEarlyService, sessionHasAllCapabilities, sessionHasAllTopLevelCapabilities, sessionHasCapability, sessionHasOneCapability, sessionHasOneTopLevelCapability
-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown
-
-
-
-
Field Detail
-
WEB_APP_NAME
protected static final String WEB_APP_NAME
The name used for the publishing the servlet, that is as servlet name.- See Also:
- Constant Field Values
-
WEB_APP_CONTEXT
protected static final String WEB_APP_CONTEXT
The hierarchical context of the servlet.- See Also:
- Constant Field Values
-
httpService
protected final AristaFlowHTTPService httpService
The HTTP service (servlet) handling the requests.
-
-
Constructor Detail
-
EmbdServContHTTPService
public EmbdServContHTTPService(org.apache.commons.configuration2.Configuration configuration, Registry registry) throws ConfigurationException
Registers the HTTP-service-servlet at an embedded servlet container.- Parameters:
configuration
- The configuration providing the user credentials for this service.registry
- The registry for accessing the servlet services.- Throws:
ConfigurationException
- If there are problems parsing the user credentials from the configuration, aConfigurationException
will be thrown.
-
-
Method Detail
-
registerReplyHandler
public void registerReplyHandler(SessionToken session, String sessionID, HTTPReplyHandler replayHandler) throws MalformedURLException
Description copied from interface:HTTPService
Registers a reply handler for the activity with the designatedsessionID
. This creates an own URL for the reply handler. It will be called as soon as a HTTP-request (the reply for the activity) is received by this HTTP-service.- Specified by:
registerReplyHandler
in interfaceHTTPService
- Parameters:
session
- The session which is used to check for access rights on this method.sessionID
- The session ID for the executed activity. It is used to create an appropriate URL.replayHandler
- The handler for the HTTP-replies sent to this service.- Throws:
MalformedURLException
- If the designated sessionID does not allow to create a valid URL, aMalformedURLException
will be thrown.
-
deregisterReplyHandler
public void deregisterReplyHandler(SessionToken session, String sessionID)
Description copied from interface:HTTPService
Deregisters a reply handler for the activity with the designatedsessionID
. A reply handler may be deregistered any time. In case a reply handling is currently running, it will be allowed to finish.- Specified by:
deregisterReplyHandler
in interfaceHTTPService
- Parameters:
session
- The session which is used to check for access rights on this method.sessionID
- The session ID identifying the executed activity and therefore also the handler for the reply sent via HTTP.
-
start
public void start() throws AbortServiceException
Adds the HTTP-service-servlet to theServletService
.- Specified by:
start
in interfaceADEPT2Service
- Overrides:
start
in classAbstractADEPT2Service
- Throws:
AbortServiceException
- If the base URL (servlet URL having the URL-pattern appended) cannot be created, anAbortServiceException
will be thrown.ServiceNotKnownException
- If the servlet container cannot be retrieved from the registry, aServiceNotKnownException
will be thrown.
-
shutdown
public void shutdown(boolean emergency)
Removes the HTTP-service-servlet from theServletService
.- Specified by:
shutdown
in interfaceADEPT2Service
- Overrides:
shutdown
in classAbstractAuthenticatedService
- Parameters:
emergency
- Whether the shutdown will be an emergency shutdown.
-
isActive
public boolean isActive()
Allows waiting reply handlers to retrieve the state of the HTTP-service. Please note that this method blocks when starting until the service is started.- Overrides:
isActive
in classAbstractADEPT2Service
- Returns:
- Whether this service is active, that is started and not shut down.
-
-