Package de.aristaflow.adept2.ui.htmlgui
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 simpleHTMLContextthat does not create any browsers or alike but just provides the interaction between webserver andExecutableComponent. Additionally, this context can be serialised to allow for accessing the GUI (HTML) remotely. Since the event handling of a normalHTMLContextprevents serialisation, only theURLis serialised (by replacing this context with aURLContext). ThisURLcan then be called remotely while the interaction between webserver andExecutableComponentis further handled by this context (instance).Note that as stated above this context is not really serialisable. When serialising it is replaced by a
URLContextwhich implies that only aURLContextcan be deserialised.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
AbstractHTMLContext.HtmlContextCleanupTask
-
Nested classes/interfaces inherited from interface de.aristaflow.adept2.ui.htmlgui.HTMLContext
HTMLContext.Attachment, HTMLContext.CloseIgnoringAttachment, HTMLContext.HTTPReply, HTMLContext.Response
-
-
Field Summary
Fields Modifier and Type Field Description protected Cleanup<RuntimeException>contextCleanupThe clean-up for closing the context and all related resources.protected SessionTokensessionThe session token for deregistering at theHTTPService.protected TransferredURLContexturlContextThe context for transferring thisHTMLContextfor remote usage.-
Fields inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
baseURL, cleanup, DEFAULT_FINAL_RESPONSE, finalResponse, httpService, initialContentString, logger, relRes, replies, replyHandlerTerminated, responses, sessionID, thread
-
-
Constructor Summary
Constructors Constructor Description RemoteHTMLContext(Thread thread, SessionToken session, HTTPService httpService, String sessionId, ActivityInstance activityInstance, EBPInstanceReference activity, ExecutionContext executionContext)Creates a newHTMLContextfor handling the interaction between webserver andExecutableComponentand also to provide theURLto a client allowing to call theURLremotely.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the GUI for this context.voidsetBaseURL(URL baseURL)Sets the base URL on which the reply handler is reachable via HTTP.voidsetBaseURL(URL baseURL, String resName)Sets the base URL on which the reply handler is reachable via HTTP and the corresponding resource name, i.protected ObjectwriteReplace()Creates a newURLContextto replace thisRemoteHTMLContextwhen transferring to a client.-
Methods inherited from class de.aristaflow.adept2.ui.htmlgui.AbstractHTMLContext
checkForValidExecutorThread, close, getRelativeLink, getRelativeLink, getResponse, getURL, getURL, setFinalResponse, setFinalResponse, setInitialContent, setResponse, waitForHTTPReply
-
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.ui.htmlgui.URLContext
getURL
-
-
-
-
Field Detail
-
session
protected final SessionToken session
The session token for deregistering at theHTTPService. This should be retrieved from the client service instead of reusing the registering token.
-
urlContext
protected TransferredURLContext urlContext
The context for transferring thisHTMLContextfor remote usage. Note that this will not have a URL untilsetBaseURL(URL)has been called.
-
contextCleanup
protected final Cleanup<RuntimeException> contextCleanup
The clean-up for closing the context and all related resources.
-
-
Constructor Detail
-
RemoteHTMLContext
public RemoteHTMLContext(Thread thread, SessionToken session, HTTPService httpService, String sessionId, ActivityInstance activityInstance, EBPInstanceReference activity, ExecutionContext executionContext)
Creates a newHTMLContextfor handling the interaction between webserver andExecutableComponentand also to provide theURLto a client allowing to call theURLremotely.- 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 theHTTPService.httpService- TheHTTPServiceto deregister this context.sessionId- The session ID used for deregistering at theHTTPService.activityInstance- The activity instance this GUI context has been created for.activity- TheEBPInstanceReferenceidentifying 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 Detail
-
close
public void close()
Description copied from interface:GUIContextCloses 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceGUIContext- Specified by:
closein interfaceHTMLContext
-
setBaseURL
public void setBaseURL(URL baseURL)
Description copied from interface:HTTPReplyHandlerSets the base URL on which the reply handler is reachable via HTTP. Further parameters can be arbitrarily added by the activity, as long as the resulting URL is valid.- Specified by:
setBaseURLin interfaceHTTPReplyHandler- Overrides:
setBaseURLin classAbstractHTMLContext- Parameters:
baseURL- The URL on which this reply handler is reachable via HTTP.
-
setBaseURL
public void setBaseURL(URL baseURL, String resName)
Description copied from interface:HTTPReplyHandlerSets 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:
setBaseURLin interfaceHTTPReplyHandler- Overrides:
setBaseURLin classAbstractHTMLContext- 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 newURLContextto replace thisRemoteHTMLContextwhen transferring to a client. A client only requires theURLbut not the logic for handling HTTP-requests this context provides.- Returns:
- A new
URLContextto replace thisRemoteHTMLContextwhen transferring to a client.
-
-