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 simpleHTMLContext
that 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 normalHTMLContext
prevents serialisation, only theURL
is serialised (by replacing this context with aURLContext
). ThisURL
can then be called remotely while the interaction between webserver andExecutableComponent
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 aURLContext
can 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>
contextCleanup
The clean-up for closing the context and all related resources.protected SessionToken
session
The session token for deregistering at theHTTPService
.protected TransferredURLContext
urlContext
The context for transferring thisHTMLContext
for 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 newHTMLContext
for handling the interaction between webserver andExecutableComponent
and also to provide theURL
to a client allowing to call theURL
remotely.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the GUI for this context.void
setBaseURL(URL baseURL)
Sets the base URL on which the reply handler is reachable via HTTP.void
setBaseURL(URL baseURL, String resName)
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).protected Object
writeReplace()
Creates a newURLContext
to replace thisRemoteHTMLContext
when 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 thisHTMLContext
for 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 newHTMLContext
for handling the interaction between webserver andExecutableComponent
and also to provide theURL
to a client allowing to call theURL
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 theHTTPService
.httpService
- TheHTTPService
to deregister this context.sessionId
- The session ID used for deregistering at theHTTPService
.activityInstance
- The activity instance this GUI context has been created for.activity
- TheEBPInstanceReference
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 Detail
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceGUIContext
- Specified by:
close
in interfaceHTMLContext
-
setBaseURL
public void setBaseURL(URL baseURL)
Description copied from interface:HTTPReplyHandler
Sets 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:
setBaseURL
in interfaceHTTPReplyHandler
- Overrides:
setBaseURL
in 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: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 interfaceHTTPReplyHandler
- Overrides:
setBaseURL
in 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 newURLContext
to replace thisRemoteHTMLContext
when transferring to a client. A client only requires theURL
but not the logic for handling HTTP-requests this context provides.- Returns:
- A new
URLContext
to replace thisRemoteHTMLContext
when transferring to a client.
-
-