Class EmbdServContHTTPService

All Implemented Interfaces:
ADEPT2Service, AuthenticatingService, LogService, ServiceThreadHandling, HTTPService

public class EmbdServContHTTPService extends AbstractAuthenticatedService implements HTTPService
Simple HTTP service based on a ServletService (an embedded servlet container). This delegates to the AristaFlowHTTPService-servlet implementingdoGet and doPost-methods.
Author:
Kevin Goeser, Ulrich Kreher
  • Field Details

    • 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:
    • WEB_APP_CONTEXT

      protected static final String WEB_APP_CONTEXT
      The hierarchical context of the servlet.
      See Also:
    • httpService

      protected final AristaFlowHTTPService httpService
      The HTTP service (servlet) handling the requests.
  • Constructor Details

    • EmbdServContHTTPService

      public EmbdServContHTTPService(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, a ConfigurationException will be thrown.
  • Method Details

    • 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 designated sessionID. 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 interface HTTPService
      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, a MalformedURLException 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 designated sessionID. 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 interface HTTPService
      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 the ServletService.
      Specified by:
      start in interface ADEPT2Service
      Overrides:
      start in class AbstractADEPT2Service
      Throws:
      AbortServiceException - If the base URL (servlet URL having the URL-pattern appended) cannot be created, an AbortServiceException will be thrown.
      ServiceNotKnownException - If the servlet container cannot be retrieved from the registry, a ServiceNotKnownException will be thrown.
    • shutdown

      public void shutdown(boolean emergency)
      Removes the HTTP-service-servlet from the ServletService.
      Specified by:
      shutdown in interface ADEPT2Service
      Overrides:
      shutdown in class AbstractAuthenticatedService
      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 class AbstractADEPT2Service
      Returns:
      Whether this service is active, that is started and not shut down.