Class AbstractWebComponent
- All Implemented Interfaces:
ExecutableComponent
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
ExecutableComponent.Signals -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe component should be directly suspended, that is do not wait for the user timeout.protected booleanWhether the execution of this component has been resumed.protected StringThe savepoint in case this component has been resumed ornullin case of normal execution.Fields inherited from class de.aristaflow.adept2.ui.htmlgui.executionenvironments.AbstractWebResourceComponent
CONF_EXT_RESOURCE_DIR, extCssFiles, extScripts, GLOBAL_EXT_RESOURCE_DIR, htmlContext, url, USER_SIGNAL_EXT_FILE, USER_SIGNAL_FILEFields inherited from class de.aristaflow.adept2.core.runtimemanager.executionenvironments.ExecutionEnvironment
actData, activityInstance, cleanup, localisedActInst, logger, sessionContext, SUSPEND_SAVEPOINTFields inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
CONF_DATA_DIRECTORY, CONF_LIB_DIRECTORY, CONF_LOG_DIRECTORY, UNLOADING_CLASS_METHOD -
Constructor Summary
ConstructorsConstructorDescriptionAbstractWebComponent(String ecName, ActivityInstance activityInstance, String internalResourcePath) -
Method Summary
Modifier and TypeMethodDescriptionbooleanclose()Returns false - overwrite this method to support closing.protected abstract StringCreate a string with HTML content to be displayed as final message to the user, e.g.protected abstract HTMLContext.ResponseCreate the response for telling the browser side that the data is not consistent, after the user sent the "send" user signal.protected abstract HTMLContext.ResponsecreateResponseForInvalidSend(HTMLContext.HTTPReply httpReply, Throwable handlingException) Create the response for telling the browser that data submitted with the "send" user signal was invalid, e. g.protected abstract voiddeserialiseState(byte[] serialisedState) Deserialise the component's state from the given byte array.getAgent()Returns the agent executing this activity.protected abstract HTMLContext.ResponsehandleCustomResourceSignal(HTMLContext.HTTPReply httpReply) A "resource" user signal was sent, but the resource type was none of the default ones and needs to be handled by the implementing sub-class.protected abstract voidhandleKeepAliveParameters(HTMLContext.HTTPReply httpReply) Handle additional parameters which were sent along the "keep alive" signal.protected abstract HTMLContext.ResponsehandleReload(HTMLContext.HTTPReply httpReply) Handle the reload request having the given parameters and create an appropriate response to be sent to the browser.protected abstract voidhandleSendParameters(HTMLContext.HTTPReply httpReply) Handle the parameters sent along with the "Send" user signal.protected abstract voidhandleSuspendParameters(HTMLContext.HTTPReply httpReply) Handle the parameters which were sent along the "suspend" user signal.protected abstract HTMLContext.ResponsehandleUnknownUserSignal(HTMLContext.HTTPReply httpReply) protected booleanhandleUserSuspend(int actualSignal) Handles an existing suspend signal properly and sets the designated signal if no suspend signal is pending.voidinitResume(String savepointId, SessionContext sc) Does nothing - overwrite this method to support resuming.protected abstract booleanCheck if the current state of the form is consistent, the data is valid and all required parameters have been set.protected abstract booleanisDirty()Returns true if any data was already send, so the component has unsaved data which should be stored during suspend.booleankill()Returns false - overwrite this method to support killing.booleanreset()Returns false - overwrite this method to support reset.voidrun()Resemblesexcept that this method is expected to throw exceptions indicating that the environment was unexpected or an internal failure occurred.Runnable.run()protected abstract byte[]serialiseState(boolean closing) Serialise and return the current state of the component for suspension.booleansignal(int signal) Returns false - overwrite this method to support signalling.booleansuspend()Returns false - overwrite this method to support suspending.protected abstract voidWrite the output parameters.Methods inherited from class de.aristaflow.adept2.ui.htmlgui.executionenvironments.AbstractWebResourceComponent
getMimeType, getResourceAsStream, getResourceAsString, getResourceLink, init, initialiseAndGetInitialContentMethods inherited from class de.aristaflow.adept2.core.runtimemanager.executionenvironments.ExecutionEnvironment
cleanup, commit, createActivityData, getApplicationState, getApplicationState, getRawApplicationState, getRawApplicationState, prepareCommit, requireGUIContext, rollback, setApplicationState, setApplicationState, setRawApplicationState, setRawApplicationState
-
Field Details
-
DIRECT_SUSPEND
public static final int DIRECT_SUSPENDThe component should be directly suspended, that is do not wait for the user timeout. Value isExecutableComponent.Signals.SUSPEND+ 1.- See Also:
-
resumed
protected boolean resumedWhether the execution of this component has been resumed. -
savepoint
The savepoint in case this component has been resumed ornullin case of normal execution.
-
-
Constructor Details
-
AbstractWebComponent
public AbstractWebComponent(String ecName, ActivityInstance activityInstance, String internalResourcePath) - Parameters:
ecName- The executable component name.activityInstance- The activity instance.internalResourcePath- The path for internal resources, to be used with getClass().getRessourceAsStream(...).
-
-
Method Details
-
initResume
Description copied from class:ExecutionEnvironmentDoes nothing - overwrite this method to support resuming.
Note that this does neither set the session context nor the logger.Initialises and prepares the resuming of the application and provides all necessary data which maybe necessary for this. This method or
ExecutableComponent.init(SessionContext)is only called once in the lifetime of an executable component. One of these methods is guaranteed to be called before calling any other method.When leaving this method the execution has to be completely prepared for resuming. That is, the state of the application has to be restored. This includes the GUI.
Usually this method will delegate also call
ExecutableComponent.init(SessionContext).- Specified by:
initResumein interfaceExecutableComponent- Overrides:
initResumein classExecutionEnvironment- Parameters:
savepointId- The identifier of the savepoint at which the application should resume. This must not benull, but it may be the empty string.sc- The session context in which the component is to be executed.
-
run
public void run()Description copied from interface:ExecutableComponentResemblesexcept that this method is expected to throw exceptions indicating that the environment was unexpected or an internal failure occurred. Both exceptions as well asRunnable.run()will set the corresponding process activity toRuntimeExceptionFAILED.- Specified by:
runin interfaceExecutableComponent- Specified by:
runin classExecutionEnvironment
-
createResponseForInconsistentSend
protected abstract HTMLContext.Response createResponseForInconsistentSend(HTMLContext.HTTPReply httpReply) Create the response for telling the browser side that the data is not consistent, after the user sent the "send" user signal. The method will be called afterhandleSendParameters(HTTPReply), and afterwards callingisConsistent()returned false. -
createResponseForInvalidSend
protected abstract HTMLContext.Response createResponseForInvalidSend(HTMLContext.HTTPReply httpReply, Throwable handlingException) Create the response for telling the browser that data submitted with the "send" user signal was invalid, e. g. failed to parse. The method will be called if handling the sent parameters failed. This does not set the parameter values.- Parameters:
httpReply- The reply which sent the invalid data. The caller is responsible for closing.handlingException- The exception that occurred leading to the sent data being invalid.- Returns:
- The response to send to the browser that submitted invalid data. The caller is responsible for closing.
-
handleUnknownUserSignal
-
isDirty
protected abstract boolean isDirty()Returns true if any data was already send, so the component has unsaved data which should be stored during suspend.- Returns:
- True, if unsaved data needs to be stored for suspend.
-
isConsistent
protected abstract boolean isConsistent()Check if the current state of the form is consistent, the data is valid and all required parameters have been set.- Returns:
- True, if the current state of the form is consistent, the data is valid and all required parameters have been set.
-
handleReload
Handle the reload request having the given parameters and create an appropriate response to be sent to the browser. -
handleKeepAliveParameters
Handle additional parameters which were sent along the "keep alive" signal. This method allows to save intermediate results the user entered and the browser side sent along with the "keep alive" signal.The method will only be called if there is not yet an environment signal for suspending the form pending and there are actually additional parameters or an additional request body.
Note: Do not use the
httpReplyto send a response, this will be done by theAbstractWebComponent.- Parameters:
httpReply- The parameters sent with "keep alive". The caller is responsible for closing.
-
handleSuspendParameters
Handle the parameters which were sent along the "suspend" user signal.Note: Do not use the
httpReplyto send a response, this will be done by theAbstractWebComponent.- Parameters:
httpReply- The HTTP reply sent by the browser to the environment with the suspend signal. The caller is responsible for closing.
-
handleSendParameters
Handle the parameters sent along with the "Send" user signal.Note: Do not use the
httpReplyto send a response, this will be done by theAbstractWebComponent.- Parameters:
httpReply- The HTTP reply sent by the browser to the environment with the Send user signal. The caller is responsible for closing.
-
handleCustomResourceSignal
A "resource" user signal was sent, but the resource type was none of the default ones and needs to be handled by the implementing sub-class. -
serialiseState
protected abstract byte[] serialiseState(boolean closing) Serialise and return the current state of the component for suspension.- Parameters:
closing- Whether this state serialisation takes place while closing. In this case implementations need not serialise state by writing output parameter values since this has already been done inwriteOutput()beforehand.- Returns:
-
deserialiseState
protected abstract void deserialiseState(byte[] serialisedState) Deserialise the component's state from the given byte array.- Parameters:
serialisedState-
-
writeOutput
protected abstract void writeOutput()Write the output parameters. -
createCloseMessage
Create a string with HTML content to be displayed as final message to the user, e.g. telling him to close the browser window, for the case the activity was opened in a pop-up which wasn't closed by the client application.- Returns:
- The HTML code with the final message to the user.
-
signal
public boolean signal(int signal) Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support signalling.Signals an event to the application.
- Specified by:
signalin interfaceExecutableComponent- Overrides:
signalin classExecutionEnvironment- Parameters:
signal- Ignored.- Returns:
false- See Also:
-
suspend
public boolean suspend()Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support suspending.Instructs the component to store its internal state to the data context and to terminate at once. The application should be able to continue its job later when resuming.
- Specified by:
suspendin interfaceExecutableComponent- Overrides:
suspendin classExecutionEnvironment- Returns:
false
-
close
public boolean close()Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support closing.Instructs the component to terminate. Within this method the component should deallocate all allocated resources.
- Specified by:
closein interfaceExecutableComponent- Overrides:
closein classExecutionEnvironment- Returns:
false
-
reset
public boolean reset()Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support reset.Instructs the component to reset. This is quite similar to
ExecutableComponent.kill()but the application does not fail but terminate normally (by callingRuntimeEnvironment.applicationReset(). The component will be re-initialised and executed again later.- Specified by:
resetin interfaceExecutableComponent- Overrides:
resetin classExecutionEnvironment- Returns:
false
-
kill
public boolean kill()Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support killing.Enforces the application to abort its execution at once. In the case of running a internal transaction application should abort the transaction and should rollback. Within this method the component should deallocate all allocated resources.
- Specified by:
killin interfaceExecutableComponent- Overrides:
killin classExecutionEnvironment- Returns:
false
-
handleUserSuspend
protected boolean handleUserSuspend(int actualSignal) Handles an existing suspend signal properly and sets the designated signal if no suspend signal is pending. In case of an enquiry or aDIRECT_SUSPEND, immediate suspending will take place instead of the designated signal.- Parameters:
actualSignal- The actual signal which to set unless a suspend signal is pending.- Returns:
- Whether we respond to the designated signal, otherwise a suspend signal is pending.
-
getAgent
Returns the agent executing this activity.- Returns:
- The agent executing this activity.
-