Class RemoteHTMLContext

java.lang.Object
de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
de.aristaflow.adept2.ui.htmlgui.RemoteHTMLContext
All Implemented Interfaces:
GUIContext, HTMLContext, HTTPReplyHandler, URLContext, Closeable, Serializable, AutoCloseable

public class RemoteHTMLContext extends AbstractHTMLContext implements URLContext, Serializable
A simple HTMLContext that does not create any browsers or alike but just provides the interaction between webserver and ExecutableComponent. Additionally, this context can be serialised to allow for accessing the GUI (HTML) remotely. Since the event handling of a normal HTMLContext prevents serialisation, only the URL is serialised (by replacing this context with a URLContext). This URL can then be called remotely while the interaction between webserver and ExecutableComponent is further handled by this context (instance).

Note that as stated above this context is not really serialisable. When serialising it is replaced by a URLContext which implies that only a URLContext can be deserialised.

See Also:
  • Field Details

    • session

      protected final SessionToken session
      The session token for deregistering at the HTTPService. This should be retrieved from the client service instead of reusing the registering token.
    • urlContext

      protected TransferredURLContext urlContext
      The context for transferring this HTMLContext for remote usage. Note that this will not have a URL until setBaseURL(URL, String) has been called.
    • contextCleanup

      protected final Cleanup<RuntimeException> contextCleanup
      The clean-up for closing the context and all related resources.
  • Constructor Details

    • RemoteHTMLContext

      public RemoteHTMLContext(Thread thread, SessionToken session, HTTPService httpService, String sessionId, ActivityInstance activityInstance, EBPInstanceReference activity, ExecutionContext executionContext)
      Creates a new HTMLContext for handling the interaction between webserver and ExecutableComponent and also to provide the URL to a client allowing to call the URL remotely.
      Parameters:
      thread - The thread which executes the component using this context (locally).
      We must not keep a strong reference to this thread! Otherwise memory leaks may occur.
      session - The session token used for deregistering at the HTTPService.
      httpService - The HTTPService to deregister this context.
      sessionId - The session ID used for deregistering at the HTTPService.
      activityInstance - The activity instance this GUI context has been created for.
      activity - The EBPInstanceReference identifying the process instance node this GUI context has been created for.
      executionContext - The execution context of the activity for which this GUI context has been created for.
  • Method Details

    • close

      public void close()
      Description copied from interface: GUIContext
      Closes the GUI for this context. This method has to be called by the runtime manager whenever an application has terminated (finished, failed, aborted, killed,...).
      It must be possible to call this method more than once, even if the GUIContext has already shut down. This especially applies to the disposal of SWT-widgets, that is, it is allowed to call this method after the disposal of the corresponding widgets.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface GUIContext
      Specified by:
      close in interface HTMLContext
    • getURL

      public URL getURL()
      Description copied from interface: URLContext
      Gets the URL of the (remote) HTMLContext which provides the GUI.
      Specified by:
      getURL in interface URLContext
      Returns:
      The URL of the (remote) HTMLContext which provides the GUI.
    • setBaseURL

      public void setBaseURL(URL baseURL, String resName)
      Description copied from interface: HTTPReplyHandler
      Sets the base URL on which the reply handler is reachable via HTTP and the corresponding resource name, i. e. the last element of the URL path (before query parameters). Further parameters can be arbitrarily added by the activity, as long as the resulting URL is valid.
      Specified by:
      setBaseURL in interface HTTPReplyHandler
      Overrides:
      setBaseURL in class AbstractHTMLContext
      Parameters:
      baseURL - The URL on which this reply handler is reachable via HTTP.
      resName - The resource name from the URL, i. e. the last element of its path (before query parameters), e. g. index.html (without leading slash).
    • writeReplace

      protected Object writeReplace()
      Creates a new URLContext to replace this RemoteHTMLContext when transferring to a client. A client only requires the URL but not the logic for handling HTTP-requests this context provides.
      Returns:
      A new URLContext to replace this RemoteHTMLContext when transferring to a client.