|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface IPushService
A push service provides a simple way to install push facility
on a component, and then push events to the component using
a IPushTarget.
Implementations of IPushService must be thread safe,
and thus easily reusable.
Here is a common example of usage:
private static final IPushInstaller PUSH_INSTALLER = new IPushInstaller() {
public void install(Component component, final IPushTarget pushTarget) {
myServerEventService.addListener(new MyListener() {
public void onEvent(Event ev) {
if (pushTarget.isConnected()) {
pushTarget.addComponent(myComponentToUpdate);
pushTarget.appendJavascript("alert('event received from server:"+ev+"');");
pushTarget.trigger();
} else {
myServerEventService.removeListener(this);
}
}
});
}
}
...
pushService.installPush(myComponent, PUSH_INSTALLER);
Using a unique instance of push installer is highly recommended, since it is then referenced
in the Wicket Application (using a different instance each time could thus lead to
a memory leak). If you need to pass different instances each time, you are responsible
for calling uninstallPush on the component to free the reference to the installer.
This service is usually used when you already have a facility for triggering and listening server side events that you want to propagate to the clients.
For a mechanism including an event publish/subscribe mechanism, see IChannelService
IChannelService,
IPushInstaller| Method Summary | |
|---|---|
IPushTarget |
installPush(org.apache.wicket.Component component)
Installs a push facility on the given component. |
void |
uninstallPush(org.apache.wicket.Component component)
Uninstalls a push installer which has previously been installed on a component. |
| Method Detail |
|---|
IPushTarget installPush(org.apache.wicket.Component component)
The component on which the push facility is installed doesn't really matter as soon as it is visible, except that only one push service can be installed by component.
Usually the page is used as component.
component - the component on which the push facility must be installedvoid uninstallPush(org.apache.wicket.Component component)
Calling this method after calling #installPush(Component, IPushInstaller)
is mandatory if you use a different push installer instance for each component
instance.
component - the component on which push service must be uninstalled
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||