Interface PushController
- All Known Implementing Classes:
AbstractPushController,CommentPushController,WorkflowPushController
public interface PushController
A push controller is one of the fundamental building blocks of Cockpit's server push mechanism. It is typically executed in its
own Thread and allows actions to be performed and components to be updated asynchronously using reverse Ajax.
The push controller itself contains the logic for testing if an update is required (see
isUpdateNeeded()
) and if so notifying the appropriate Cockpit components by the use of CockpitEvents (see update()).
When used with a PushComponent, it provides the means necessary to update ZK view components asynchronously.
Normally there is no need to implement a push controller from scratch and extending the abstract class
AbstractPushController is usually the right way to go.-
Method Summary
Modifier and TypeMethodDescriptionReturns this push controller'sPushComponent.intReturns the update interval in milliseconds for this push controller.booleanReturns whether an update is required or not.voidsetComponent(PushComponent component) Sets thePushComponentto be used by this push controller tocomponent.voidsetDone()Tells this push controller to stop processing server push events.voidsetParameters(Map<String, Object> params) voidsetUpdateInterval(int milliseconds) Sets the update interval in milliseconds for this push controller.voidStarts this push controller.voidupdate()Called whenever an update is needed i.e.
-
Method Details
-
update
void update()Called whenever an update is needed i.e. whenisUpdateNeeded()has returnedtrue. Typically createsCockpitEvents and adds them to a special event queue by calling thePushComponent.addEvent(CockpitEvent)method on thePushComponentreturned bygetComponent(). -
isUpdateNeeded
boolean isUpdateNeeded()Returns whether an update is required or not.- Returns:
trueif an update is needed,falseotherwise- See Also:
-
setDone
void setDone()Tells this push controller to stop processing server push events. Typically stops the thread gently within one polling cycle (seegetUpdateInterval()).- See Also:
-
setComponent
Sets thePushComponentto be used by this push controller tocomponent.- Parameters:
component- the push component used by this push controller- See Also:
-
getComponent
PushComponent getComponent()Returns this push controller'sPushComponent.- Returns:
- the push component used by this push controller
-
setUpdateInterval
void setUpdateInterval(int milliseconds) Sets the update interval in milliseconds for this push controller.- Parameters:
milliseconds- the delay between updates (or update requests) in milliseconds
-
getUpdateInterval
int getUpdateInterval()Returns the update interval in milliseconds for this push controller.- Returns:
- the delay between updates (or update requests) in milliseconds
-
startController
void startController()Starts this push controller. Typically starts the push controller thread.- See Also:
-
setParameters
-
getParameters
-