Modifier and Type | Field and Description |
---|---|
protected java.util.LinkedList<DataFilter> |
filters
A list of the current filters
|
protected java.lang.String |
id
The unique id of this channel
|
protected boolean |
persistent
Is this channel persistent, default value is true
|
protected java.util.LinkedList<Client> |
subscribers
A list of the current subscribers
|
Modifier | Constructor and Description |
---|---|
protected |
ChannelImpl(java.lang.String id)
Creates a new channel
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(DataFilter filter)
Adds a data filter to this channel.
|
java.lang.String |
getId()
returns the id of this channel
|
java.util.List<Client> |
getSubscribers()
returns a non modifiable list of all the subscribers to this
channel.
|
boolean |
isPersistent()
Non persistent channels are removed when the last subscription is
removed.
|
boolean |
matches(java.lang.String pattern)
Returns true if this channel matches the pattern to its id.
|
void |
publish(Message msg)
Publishes a message to all the subscribers of this channel.
|
void |
publish(Message[] msgs)
Publishes more than one message to all the subscribers of this channel.
|
DataFilter |
removeFilter(DataFilter filter)
Removes a filter from this channel.
|
void |
setPersistent(boolean persistent) |
void |
subscribe(Client subscriber)
Subscribes a client to a channel.
|
java.lang.String |
toString() |
Client |
unsubscribe(Client subscriber)
Unsubscribes a client from a channel
|
protected java.lang.String id
protected java.util.LinkedList<Client> subscribers
protected java.util.LinkedList<DataFilter> filters
protected boolean persistent
protected ChannelImpl(java.lang.String id)
id
- String - the id of the channel, can not be nullpublic java.lang.String getId()
public boolean matches(java.lang.String pattern)
/service/mychannel
or it can be a wild card pattern like /service/app2/**
pattern
- String according to the Bayeux specification section 2.2.1 Channel Globbing, can not be null.public java.util.List<Client> getSubscribers()
Channel
getSubscribers
in interface Channel
public boolean isPersistent()
Channel
isPersistent
in interface Channel
public void publish(Message msg)
Channel
from
is contained within the message, by calling
msg.getClient()
public void publish(Message[] msgs)
Channel
from
is contained within the message, by calling
msg[x].getClient()
public void setPersistent(boolean persistent)
setPersistent
in interface Channel
persistent
- true if the Channel will persist without any subscription.isPersistent
public void subscribe(Client subscriber)
Channel
public Client unsubscribe(Client subscriber)
Channel
unsubscribe
in interface Channel
subscriber
- - the client to be subscribed.public void addFilter(DataFilter filter)
Channel
public DataFilter removeFilter(DataFilter filter)
Channel
removeFilter
in interface Channel
filter
- Filterpublic java.lang.String toString()
toString
in class java.lang.Object