org.cometd.server
Class ChannelImpl

java.lang.Object
  extended by org.cometd.server.ChannelImpl
All Implemented Interfaces:
Channel
Direct Known Subclasses:
AbstractBayeux.ServiceChannel

public class ChannelImpl
extends java.lang.Object
implements Channel

A Bayuex Channel

Author:
gregw

Constructor Summary
protected ChannelImpl(java.lang.String id, AbstractBayeux bayeux)
           
 
Method Summary
 ChannelImpl addChild(ChannelImpl channel)
          Add a channel
 void addDataFilter(DataFilter filter)
          Adds the given DataFilter to this channel.
 void addListener(ChannelListener listener)
          Adds a channel listener to this channel.
 void deliver(Client from, java.lang.Iterable<Client> to, java.lang.Object data, java.lang.String id)
           
protected  void doDelivery(ChannelId to, Client from, Message msg)
           
 boolean doRemove(ChannelImpl channel, java.util.List<ChannelBayeuxListener> listeners)
           
 int getChannelCount()
           
 ChannelId getChannelId()
           
 void getChannels(java.util.List<Channel> list)
           
 ChannelImpl getChild(ChannelId id)
           
 java.util.Collection<DataFilter> getDataFilters()
          Returns a collection copy of the data filters for this channel.
 java.lang.String getId()
           
 int getSubscriberCount()
           
 java.util.Collection<Client> getSubscribers()
          Returns a collection that is a copy of clients subscribed to this channel.
 boolean isLazy()
          A Lazy channel marks published messages as lazy.
 boolean isPersistent()
          Indicates whether the channel is persistent or not.
 void publish(Client fromClient, java.lang.Object data, java.lang.String msgId)
          Publishes a message.
 void publishLazy(Client fromClient, java.lang.Object data, java.lang.String msgId)
           
 boolean remove()
           
 DataFilter removeDataFilter(DataFilter filter)
          Removes the given DataFilter from this channel.
 void removeListener(ChannelListener listener)
          Removes the channel listener from this channel.
 void setLazy(boolean lazy)
          A Lazy channel marks published messages as lazy.
 void setPersistent(boolean persistent)
          Sets the persistency of this channel.
 void subscribe(Client client)
          Subscribes the given Client to this channel.
 java.lang.String toString()
           
 void unsubscribe(Client client)
          Unsubscribes the given Client from this channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChannelImpl

protected ChannelImpl(java.lang.String id,
                      AbstractBayeux bayeux)
Method Detail

isLazy

public boolean isLazy()
A Lazy channel marks published messages as lazy. Lazy messages are queued but do not wake up waiting clients.

Specified by:
isLazy in interface Channel
Returns:
true if message is lazy
See Also:
Channel.setLazy(boolean)

setLazy

public void setLazy(boolean lazy)
A Lazy channel marks published messages as lazy. Lazy messages are queued but do not wake up waiting clients.

Specified by:
setLazy in interface Channel
Parameters:
lazy - true if message is lazy

addChild

public ChannelImpl addChild(ChannelImpl channel)
Add a channel

Parameters:
channel -
Returns:
The added channel, or the existing channel if another thread already added the channel

addDataFilter

public void addDataFilter(DataFilter filter)
Description copied from interface: Channel
Adds the given DataFilter to this channel.

Specified by:
addDataFilter in interface Channel
Parameters:
filter -
See Also:
Channel.removeDataFilter(DataFilter)

getChannelId

public ChannelId getChannelId()
Returns:

getChild

public ChannelImpl getChild(ChannelId id)

getChannels

public void getChannels(java.util.List<Channel> list)

getChannelCount

public int getChannelCount()

getId

public java.lang.String getId()
Specified by:
getId in interface Channel
Returns:

isPersistent

public boolean isPersistent()
Description copied from interface: Channel
Indicates whether the channel is persistent or not. Non persistent channels are removed when the last subscription is removed.

Specified by:
isPersistent in interface Channel
Returns:
true if the Channel will persist even when all subscriptions are gone.
See Also:
Channel.setPersistent(boolean)

deliver

public void deliver(Client from,
                    java.lang.Iterable<Client> to,
                    java.lang.Object data,
                    java.lang.String id)

publish

public void publish(Client fromClient,
                    java.lang.Object data,
                    java.lang.String msgId)
Description copied from interface: Channel
Publishes a message.

Specified by:
publish in interface Channel
Parameters:
fromClient - the client source of the message, or null
data - the message data
msgId - the message ID or null

publishLazy

public void publishLazy(Client fromClient,
                        java.lang.Object data,
                        java.lang.String msgId)

remove

public boolean remove()
Specified by:
remove in interface Channel
Returns:
true if the channel has been removed, false if it was not possible to remove the channel

doRemove

public boolean doRemove(ChannelImpl channel,
                        java.util.List<ChannelBayeuxListener> listeners)

removeDataFilter

public DataFilter removeDataFilter(DataFilter filter)
Description copied from interface: Channel
Removes the given DataFilter from this channel.

Specified by:
removeDataFilter in interface Channel
Parameters:
filter -
Returns:
the removed data filter
See Also:
Channel.addDataFilter(DataFilter)

setPersistent

public void setPersistent(boolean persistent)
Description copied from interface: Channel
Sets the persistency of this channel.

Specified by:
setPersistent in interface Channel
Parameters:
persistent - true if the channel is persistent, false otherwise

subscribe

public void subscribe(Client client)
Description copied from interface: Channel
Subscribes the given Client to this channel.

Specified by:
subscribe in interface Channel
Parameters:
client -
See Also:
Channel.unsubscribe(Client)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unsubscribe

public void unsubscribe(Client client)
Description copied from interface: Channel
Unsubscribes the given Client from this channel.

Specified by:
unsubscribe in interface Channel
Parameters:
client -
See Also:
Channel.subscribe(Client)

doDelivery

protected void doDelivery(ChannelId to,
                          Client from,
                          Message msg)

getSubscribers

public java.util.Collection<Client> getSubscribers()
Description copied from interface: Channel
Returns a collection that is a copy of clients subscribed to this channel.

Specified by:
getSubscribers in interface Channel
Returns:
the clients subscribed to this channel

getSubscriberCount

public int getSubscriberCount()
Specified by:
getSubscriberCount in interface Channel
Returns:
the number of clients subscribed to this channel

getDataFilters

public java.util.Collection<DataFilter> getDataFilters()
Description copied from interface: Channel
Returns a collection copy of the data filters for this channel.

Specified by:
getDataFilters in interface Channel
Returns:
the data filters for this channel

addListener

public void addListener(ChannelListener listener)
Description copied from interface: Channel
Adds a channel listener to this channel.

Specified by:
addListener in interface Channel
Parameters:
listener - the listener to add
See Also:
Channel.removeListener(ChannelListener)

removeListener

public void removeListener(ChannelListener listener)
Description copied from interface: Channel
Removes the channel listener from this channel.

Specified by:
removeListener in interface Channel
Parameters:
listener - the listener to remove
See Also:
Channel.addListener(ChannelListener)


Copyright © 2011 Dojo Foundation. All Rights Reserved.