Class AristaFlowHTTPService

    • Field Detail

      • logger

        protected final transient Logger logger
        My logger.
      • replyHandlers

        protected final Map<String,​HTTPReplyHandler> replyHandlers
        The reply handlers to which HTTP-requests are forwarded after the decoding. This maps the session ID to the corresponding reply handler-instance.
      • sessions

        protected final Map<UUID,​String> sessions
        Own session IDs.
      • servletName

        protected String servletName
        The name of the servlet if dynamically deployed, null otherwise.
    • Constructor Detail

      • AristaFlowHTTPService

        public AristaFlowHTTPService()
        Constructor for initialisation via Extension Point (must not have any parameters).
      • AristaFlowHTTPService

        public AristaFlowHTTPService​(String servletName)
        Constructor providing a servlet name for dynamic servlet deployment.
        Parameters:
        servletName - The name of the servlet if dynamically deployed, null otherwise.
    • Method Detail

      • setURL

        public void setURL​(URL myURL)
        Set the URL to be used for the HTML contexts.
        Parameters:
        myURL -
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              IOException
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • 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.
      • registerReplyHandler

        public void registerReplyHandler​(SessionToken session,
                                         String sessionID,
                                         HTTPReplyHandler replyHandler)
                                  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.
        replyHandler - 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.
      • getParameters

        protected Map<String,​String> getParameters​(javax.servlet.http.HttpServletRequest request)
        Retrieves all non-list-valued and non-attachment parameters from the request and returns them as map.
        Parameters:
        request -
        Returns:
        The parameters as map from name to parameter value.
      • getParameterLists

        protected Map<String,​List<String>> getParameterLists​(javax.servlet.http.HttpServletRequest request)
        Retrieves all list-valued parameters from the request and returns them as map.
        Parameters:
        request -
        Returns:
        The parameters as map from name to list of parameter values.
      • getParameters

        protected Map<String,​String> getParameters​(List<org.apache.commons.fileupload.FileItem> items)
        Returns all non-list-valued string parameters.
        Parameters:
        items -
        Returns:
        All string parameters.
      • getParameterLists

        protected Map<String,​List<String>> getParameterLists​(List<org.apache.commons.fileupload.FileItem> items)
        Returns all list valued string parameters.
        Parameters:
        items -
        Returns:
        All list valued string parameters.
      • getParameterAttachments

        protected Pair<Map<String,​HTMLContext.Attachment>,​Map<String,​List<HTMLContext.Attachment>>> getParameterAttachments​(List<org.apache.commons.fileupload.FileItem> items)
        Gets new maps for the designated items being transformed to Attachments. If a file name exists several times in the designated items, all files will be added to the second element of the pair. File names occurring just once will be part of the first element of the pair.
        Parameters:
        items - The file items being provided by a servlet request.
        Returns:
        The designated files transformed to Attachments indexed by file names. If a file name occurs once, the corresponding attachment will be in the first element of the pair, otherwise it will be in the second element and part of a list of attachments.
      • getParameterAttachments

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        protected void getParameterAttachments​(List<org.apache.commons.fileupload.FileItem> items,
                                               Map<String,​HTMLContext.Attachment> attachments,
                                               Map<String,​List<HTMLContext.Attachment>> attachmentLists)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use the more efficient getParameterAttachments(List) instead. That does not need to consider attachments possibly already being part of the designated maps.
        Fills attachments and attachmentLists with the attachment parameters and the list-valued attachment parameters.
        Parameters:
        items -
        attachments - The attachments to which to add the ones from the designated items. Existing ones which have no corresponding item will be removed and closed.
        attachmentLists - The attachment lists to which to add the ones from the designated items. Existing ones which have no corresponding item will be removed and closed.
      • getStringValue

        protected String getStringValue​(Object o)
        Returns the string value for the given object, or null if the object is not a representation of a (non-list-valued) string value.
        Parameters:
        o -
        Returns:
        The string for the given object, or null if not applicable
      • getListValue

        protected List<String> getListValue​(Object o)
        Returns the string list value for the given object, or null if the object is not a representation of a list-valued string value.
        Parameters:
        o -
        Returns:
        The string list for the given object, or null if not applicable
      • ping

        public long ping()
        Description copied from interface: ADEPT2Service
        Gets whether the service is running and accepts requests or not and since when. This allows, for instance, to check remotely whether this service is available. Additionally, restarts of the service can be detected by comparing the returned start time with the previous one.
        Specified by:
        ping in interface ADEPT2Service
        Returns:
        The start time of the service, 0 for a service that has not been started, -1 for a service that has been shut down.
        If you need the old boolean logic use 0 < ping().
      • getRelease

        public SerialisablePair<String,​String> getRelease()
        This service is started outside of the platform and therefore does not support the methods of ADEPT2Service.
        Specified by:
        getRelease in interface ADEPT2Service
        Returns:
        <unknown> for all elements of the triple.
      • getServiceInstanceName

        public SerialisableTriple<String,​String,​String> getServiceInstanceName()
        This service is started outside of the platform and therefore does not support the methods of ADEPT2Service.
        Specified by:
        getServiceInstanceName in interface ADEPT2Service
        Returns:
        null for the cluster name, <unknown> for the other elements of the triple.
      • getStartupRequiredServices

        public String[] getStartupRequiredServices()
        Description copied from interface: ADEPT2Service
        Returns a list of service types, which are required for executing the service. The service is allowed for querying the Registry for implementations of this type during ADEPT2Service.init(URI[], URI[]) or to ADEPT2Service.start() the service.
        It is assured that ADEPT2Service.init(URI[], URI[]) is not called before the required services are started. The order in the array is not relevant since the dependencies of the required services are also inspected and respected.
        These services may also be accessed when shutting down the service.
        Specified by:
        getStartupRequiredServices in interface ADEPT2Service
        Returns:
        A list of service types which are required by this service.
      • getRuntimeRequiredServices

        public String[] getRuntimeRequiredServices()
        Description copied from interface: ADEPT2Service
        Returns a list of service types, which are requested when needed at runtime. This has to be after the component is initialised and started and before the shutdown. This means before requesting a runtime required service ADEPT2Service.init(URI[], URI[]) as well as ADEPT2Service.start() have to be returned. When starting another thread, this has to be synchronised correctly.
        Since these services are not necessarily started before this service, they may be shutdown before shutting down this service. This has to be considered when calling a runtime required service. If a service is absolutely necessary when shutting down, it will have to be declared as startup-required.

        All services required at startup should not be returned again here.

        Specified by:
        getRuntimeRequiredServices in interface ADEPT2Service
        Returns:
        A list of services which are required during runtime and requested lazily.
      • getLocalUris

        public URI[] getLocalUris()
        Description copied from interface: ADEPT2Service
        Returns the URIs under which the service is locally exported. If this service is only locally available, there will be only one URI and this is a local one. The request for the corresponding component will fail if it is not a local service.
        Internal services may return an empty array.
        Specified by:
        getLocalUris in interface ADEPT2Service
        Returns:
        The URIs with which this service is exported locally - this may also be one local URI or an empty array for internal services, that should not be reached at all, for instance communication services.
      • init

        public void init​(URI[] localExportedUris,
                         URI[] globalExportedUris)
                  throws AbortServiceException
        Not forwarded since no client component should control the service. Initialise the service. Startup-required services may already be used here.
        After returning form ADEPT2Service.init(URI[], URI[]), the service must be ready for ADEPT2Service.start().
        Specified by:
        init in interface ADEPT2Service
        Parameters:
        localExportedUris - The URIs with which this service is exported locally or a local URI or an empty array for internal services.
        globalExportedUris - The URIs with which this service is published globally or null in case the service is not published.
        Throws:
        AbortServiceException - If this service cannot be initialised due to a severe problem, an AbortServiceException will be thrown. ADEPT2Service.shutdown(boolean) will not be called when aborting; the service has to shut down itself/clean up before throwing the exception.
      • start

        public void start()
        Not forwarded since no client component should control the service. Starts the service. This method is executed exactly once by the registry and it must return to start further services. For a stand-alone-service own threads or processes have to be started here.
        This method is executed exactly once by the registry.

        After returning from ADEPT2Service.start(), the service must be ready to receive any API call. This implicates for instance, that the thread calling this method may not leave the method before a server thread is actually ready to receive requests.

        Specified by:
        start in interface ADEPT2Service
      • preShutdown

        public void preShutdown​(boolean emergency)
        Not forwarded since no client component should control the service. Signals this service that it is about to be shut down. While this method is called, the service is normally available, that is, it can be reached remotely and it should not refuse connections without reason.
        This method can be used to perform some cleanup or to start cleaning up and continuing until ADEPT2Service.shutdown(boolean). All startup required services are available in pre shutdown, runtime services may already be shut down.
        In case of an emergency shutdown, even startup required services may not be available. Additionally, shutting down should be rather fast, so cleanup should concentrate on the really important things. An emergency pre-shutdown usually should not do anything.
        Specified by:
        preShutdown in interface ADEPT2Service
        Parameters:
        emergency - Whether the shutdown will be an emergency shutdown. Normally a service should not do anything in pre-shutdown in case of an emergency.
      • shutdown

        public void shutdown​(boolean emergency)
        Not forwarded since no client component should control the service. Signals this service that it is being shut down. While this method is called, the service is no longer (remotely) available. It should terminate and close all activities and connections. Since the service is in an inconsistent state while shutting down, access should be restricted to the threads relevant for shutting down. All other requests should be blocked (see ServiceThreadHandling.
        All startup required services are available in shutdown, runtime services may already be shut down.
        In case of an emergency shutdown, even startup required services may not be available. Additionally, shutting down should be rather fast, so cleanup should concentrate on the really important things and use brief timeouts when waiting.
        Specified by:
        shutdown in interface ADEPT2Service
        Parameters:
        emergency - Whether the shutdown will be an emergency shutdown.
      • getServletName

        public String getServletName()
        Description copied from interface: DynamicServlet
        Gets the name of the servlet. Note that usually the servlet implementations rely on the servlet configuration to provide a name. However, when using a DynamicServlet, the servlet name has to be provided explicitly.
        Specified by:
        getServletName in interface DynamicServlet
        Specified by:
        getServletName in interface javax.servlet.ServletConfig
        Overrides:
        getServletName in class javax.servlet.GenericServlet
        Returns:
        The name of the servlet.
      • servletDeployed

        public void servletDeployed​(javax.servlet.ServletContext context,
                                    String urlPattern)
        Description copied from interface: DynamicServlet
        Notifies the servlet that it has been deployed with the designated context and the designated pattern. Note that the servlet usually will not have been initialised yet.
        Specified by:
        servletDeployed in interface DynamicServlet
        Parameters:
        context - The servlet context of this servlet.
        urlPattern - The URL pattern (mapping) this servlet has been deployed with.
      • servletUndeployed

        public void servletUndeployed​(javax.servlet.ServletContext context)
        Description copied from interface: DynamicServlet
        Notifies the servlet that it has been undeployed.
        Specified by:
        servletUndeployed in interface DynamicServlet
        Parameters:
        context - The servlet context of this servlet.