public class PushComponent<T extends PushController> extends Span implements DesktopRemovalAwareComponent
PushController it enables server push in a Cockpit application. A push component is responsible for
handling the execution of its PushController and sending CockpitEvents in an asynchronous fashion. It does not
allow any child components to be added and should not be used for visually displaying content.
Each push component typically has (or creates) its own PushController instance, typically implemented as a Java thread.
The PushController (thread) is started as soon as the push component has been rendered by the browser using ZK's timer
events.
Note: Each thread is gently stopped (within the duration of the specified update interval) once the desktop to which
this push component belongs has been removed. However, in order to avoid excessive creation of threads a push component should
typically be added to a relatively "long-lived" component e.g. the ZK application's root component.| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_DELAY |
| Constructor and Description |
|---|
PushComponent(Class<T> controllerClass)
Creates a new push component instance with the default update interval and a
PushController of the class specified
by controllerClass. |
PushComponent(Class<T> controllerClass,
int updateInterval)
Creates a new push component instance with the specified update interval and a
PushController of the class specified
by controllerClass. |
PushComponent(T controller)
Creates a new push component instance with the specified
PushController controller with an update
interval set to the value of controller's update interval. |
PushComponent(T controller,
int updateInterval)
Creates a new push component instance with the specified
PushController controller and an update
interval of updateInterval milliseconds. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(CockpitEvent event)
Adds an event to this push components internal event queue.
|
protected void |
appendChildInternal(Component child) |
void |
clearEvents()
Clears the event queue i.e.
|
void |
desktopRemoved(Desktop desktop) |
void |
detach() |
void |
dispatchEvents()
Dispatches the queued events.
|
List<CockpitEvent> |
getEvents()
Returns the events in the internal event queue.
|
boolean |
insertBefore(Component newChild,
Component refChild) |
void |
setParent(Component parent) |
protected static final int DEFAULT_DELAY
public PushComponent(Class<T> controllerClass) throws IllegalArgumentException, InstantiationException, IllegalAccessException
PushController of the class specified
by controllerClass.controllerClass - the class of the push controller to be usedIllegalArgumentException - if the push controller could not be createdInstantiationException - if the push controller could not be createdIllegalAccessException - if the push controller could not be createdPushComponent(Class, int),
PushComponent(PushController),
PushComponent(PushController, int)public PushComponent(Class<T> controllerClass, int updateInterval) throws IllegalArgumentException, InstantiationException, IllegalAccessException
PushController of the class specified
by controllerClass.controllerClass - the class of the push controller to be usedupdateInterval - the update interval in millisecondsIllegalArgumentException - if the push controller could not be createdInstantiationException - if the push controller could not be createdIllegalAccessException - if the push controller could not be createdPushComponent(Class),
PushComponent(PushController),
PushComponent(PushController, int)public PushComponent(T controller)
PushController controller with an update
interval set to the value of controller's update interval.controller - the push controllerPushComponent(PushController, int),
PushComponent(Class),
PushComponent(Class, int)public PushComponent(T controller, int updateInterval)
PushController controller and an update
interval of updateInterval milliseconds.controller - the push controllerupdateInterval - the update interval in millisecondspublic boolean insertBefore(Component newChild,
Component refChild)
protected void appendChildInternal(Component child)
public void clearEvents()
public void addEvent(CockpitEvent event)
event - the event to be dispatchedpublic List<CockpitEvent> getEvents()
public void dispatchEvents()
public void desktopRemoved(Desktop desktop)
desktopRemoved in interface DesktopRemovalAwareComponentpublic void detach()
public void setParent(Component parent)
Copyright © 2017 SAP SE. All Rights Reserved.