org.wicketstuff.push.cometd
Class CometdService

java.lang.Object
  extended by org.wicketstuff.push.cometd.CometdService
All Implemented Interfaces:
IChannelService

public class CometdService
extends java.lang.Object
implements IChannelService

Cometd based implementation of IChannelService.

This service is based on cometd client implemented by the dojo toolkit, which must be embedded in your application.

This implementation relies on cometd for updating the page, but actually uses regular cometd events, which, if a channel listener is properly installed on a component of the page using addChannelListener(Component, String, IChannelListener), will trigger a wicket ajax call to get the page actually refreshed using regular wicket ajax mechanisms.

This mean that each time an event is published, a new connection is made to the server to get the actual page update required by the IChannelListener.

Author:
Xavier Hanin, Rodolfo Hansen
See Also:
IChannelService

Field Summary
static java.lang.String BAYEUX_CLIENT_PREFIX
           
 
Constructor Summary
CometdService(org.apache.wicket.protocol.http.WebApplication application)
           
 
Method Summary
 void addChannelListener(org.apache.wicket.Component component, java.lang.String channel, IChannelListener listener)
          Adds a behavior to the given component so that it will be notified of ChannelEvents.
 void addChannelRemoveListener(java.lang.String chnl, org.cometd.RemoveListener listener)
           
 void addChannelRemoveListener(java.lang.String chnl, org.cometd.RemoveListener listener, org.apache.wicket.Session sess)
          Cometd Specific method to Listen for client removals
 org.apache.wicket.Application getApplication()
           
 void publish(ChannelEvent event)
          Implementation of IChannelService.publish(ChannelEvent), which actually sends a cometd event to the client with a "proxy" attribute set to "true", which in turn triggers a wicket ajax call to get the listener notified and update the page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BAYEUX_CLIENT_PREFIX

public static final java.lang.String BAYEUX_CLIENT_PREFIX
See Also:
Constant Field Values
Constructor Detail

CometdService

public CometdService(org.apache.wicket.protocol.http.WebApplication application)
Method Detail

addChannelListener

public void addChannelListener(org.apache.wicket.Component component,
                               java.lang.String channel,
                               IChannelListener listener)
Description copied from interface: IChannelService
Adds a behavior to the given component so that it will be notified of ChannelEvents.

Usually the component if a Page, even if it's not mandatory. Indeed the components reacting to the event are defined in the IChannelListener, by calling IChannelTarget methods. Hence any component on the page can serve as the host of the behavior, as soon as it is visible.

Specified by:
addChannelListener in interface IChannelService
Parameters:
component - the component to which the behavior should be added
channel - the channel for which the listener should be notified
listener - the IChannelListener which should be notified of ChannelEvents

addChannelRemoveListener

public void addChannelRemoveListener(java.lang.String chnl,
                                     org.cometd.RemoveListener listener,
                                     org.apache.wicket.Session sess)
Cometd Specific method to Listen for client removals

Parameters:
channel -
listener -
sess - Wicket Session you wish to associate with the listener.

addChannelRemoveListener

public void addChannelRemoveListener(java.lang.String chnl,
                                     org.cometd.RemoveListener listener)
See Also:
addChannelRemoveListener(String, RemoveListener, Session)

publish

public void publish(ChannelEvent event)
Implementation of IChannelService.publish(ChannelEvent), which actually sends a cometd event to the client with a "proxy" attribute set to "true", which in turn triggers a wicket ajax call to get the listener notified and update the page.

Specified by:
publish in interface IChannelService
Parameters:
event - the event to publish to the listeners

getApplication

public org.apache.wicket.Application getApplication()


Copyright © 2010. All Rights Reserved.