Class ServerChannelImpl
- All Implemented Interfaces:
Channel
,ConfigurableServerChannel
,ServerChannel
,org.eclipse.jetty.util.component.Dumpable
public class ServerChannelImpl extends Object implements ServerChannel, org.eclipse.jetty.util.component.Dumpable
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ConfigurableServerChannel
ConfigurableServerChannel.Initializer, ConfigurableServerChannel.ServerChannelListener
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ServerChannel
ServerChannel.MessageListener, ServerChannel.SubscriptionListener
-
Field Summary
Fields inherited from interface org.cometd.bayeux.Channel
META, META_CONNECT, META_DISCONNECT, META_HANDSHAKE, META_SUBSCRIBE, META_UNSUBSCRIBE, SERVICE
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServerChannelImpl(BayeuxServerImpl bayeux, ChannelId id)
-
Method Summary
Modifier and Type Method Description void
addAuthorizer(Authorizer authorizer)
Adds the givenAuthorizer
that grants or denies operations on this channel.void
addListener(ConfigurableServerChannel.ServerChannelListener listener)
protected List<Authorizer>
authorizers()
String
dump()
void
dump(Appendable out, String indent)
Object
getAttribute(String name)
Retrieves the value of named channel attribute.Set<String>
getAttributeNames()
List<Authorizer>
getAuthorizers()
ChannelId
getChannelId()
String
getId()
long
getLazyTimeout()
List<ConfigurableServerChannel.ServerChannelListener>
getListeners()
Set<ServerSession>
getSubscribers()
boolean
isBroadcast()
A broadcasting channel is a channel that is neither ameta channel
nor aservice channel
.boolean
isDeepWild()
Tells whether a channel contains the deep wild characters '**', for example/foo/**
boolean
isLazy()
boolean
isMeta()
Tells whether the channel is a meta channel, that is if itsid
starts with"/meta/"
.boolean
isPersistent()
boolean
isService()
Tells whether the channel is a service channel, that is if itsid
starts with"/service/"
.boolean
isWild()
Tells whether a channel contains the wild character '*', for example/foo/*
or if it isChannel.isDeepWild()
.protected List<ConfigurableServerChannel.ServerChannelListener>
listeners()
void
publish(Session from, Object data)
Publishes the given information to this channel.void
publish(Session from, ServerMessage.Mutable mutable)
Publishes the given message to this channel, delivering the message to all theServerSession
s subscribed to this channel.void
remove()
Removes this channel, and all the children channels.Object
removeAttribute(String name)
Removes a named channel attribute.void
removeAuthorizer(Authorizer authorizer)
Removes the givenAuthorizer
.void
removeListener(ConfigurableServerChannel.ServerChannelListener listener)
void
setAttribute(String name, Object value)
Sets a named channel attribute value.void
setLazy(boolean lazy)
A lazy channel marks all messages published to it as lazy.void
setLazyTimeout(long lazyTimeout)
Sets the lazy timeout for this channel.void
setPersistent(boolean persistent)
A persistent channel is not removed when the last subscription is removedboolean
subscribe(ServerSession session)
Subscribes the given session to this channel.protected boolean
subscribe(ServerSessionImpl session, ServerMessage message)
Set<ServerSession>
subscribers()
protected void
sweep()
String
toString()
boolean
unsubscribe(ServerSession session)
Unsubscribes the given session from this channel.protected boolean
unsubscribe(ServerSessionImpl session, ServerMessage message)
-
Constructor Details
-
Method Details
-
subscribe
Description copied from interface:ServerChannel
Subscribes the given session to this channel.
Subscriptions are effective for
broadcast channels
and are successful no-operations forservice channels
.The subscription may fail if the session is already subscribed to the channel or if the session is expired or if the channel is a meta channel.
- Specified by:
subscribe
in interfaceServerChannel
- Parameters:
session
- the session to subscribe- Returns:
- whether the subscription succeeded
- See Also:
ServerChannel.unsubscribe(ServerSession)
-
subscribe
-
unsubscribe
Description copied from interface:ServerChannel
Unsubscribes the given session from this channel.
Unsubscriptions are effective for
broadcast channels
and are successful no-operations forservice channels
.The unsubscription may fail if the session is already unsubscribed from the channel or if the session is expired or if the channel is a meta channel.
- Specified by:
unsubscribe
in interfaceServerChannel
- Parameters:
session
- the session to unsubscribe- Returns:
- whether the unsubscription succeeded
-
unsubscribe
-
getSubscribers
- Specified by:
getSubscribers
in interfaceServerChannel
- Returns:
- a snapshot of the set of subscribers of this channel
-
subscribers
-
isBroadcast
public boolean isBroadcast()Description copied from interface:Channel
A broadcasting channel is a channel that is neither a
meta channel
nor aservice channel
.- Specified by:
isBroadcast
in interfaceChannel
- Returns:
- whether the channel is a broadcasting channel
-
isDeepWild
public boolean isDeepWild()Description copied from interface:Channel
Tells whether a channel contains the deep wild characters '**', for example
/foo/**
- Specified by:
isDeepWild
in interfaceChannel
- Returns:
- true if the channel contains the '**' characters
-
isLazy
public boolean isLazy()- Specified by:
isLazy
in interfaceConfigurableServerChannel
- Returns:
- whether the channel is lazy
- See Also:
ConfigurableServerChannel.setLazy(boolean)
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistent
in interfaceConfigurableServerChannel
- Returns:
- whether the channel is persistent
- See Also:
ConfigurableServerChannel.setPersistent(boolean)
-
isWild
public boolean isWild()Description copied from interface:Channel
Tells whether a channel contains the wild character '*', for example
/foo/*
or if it isChannel.isDeepWild()
. -
setLazy
public void setLazy(boolean lazy)Description copied from interface:ConfigurableServerChannel
A lazy channel marks all messages published to it as lazy.- Specified by:
setLazy
in interfaceConfigurableServerChannel
- Parameters:
lazy
- whether the channel is lazy- See Also:
ConfigurableServerChannel.isLazy()
-
getLazyTimeout
public long getLazyTimeout()- Specified by:
getLazyTimeout
in interfaceConfigurableServerChannel
- Returns:
- the lazy timeout for this channel
- See Also:
ConfigurableServerChannel.setLazyTimeout(long)
-
setLazyTimeout
public void setLazyTimeout(long lazyTimeout)Description copied from interface:ConfigurableServerChannel
Sets the lazy timeout for this channel. A positive value makes the channel lazy, a negative value makes the channel non-lazy.- Specified by:
setLazyTimeout
in interfaceConfigurableServerChannel
- Parameters:
lazyTimeout
- the lazy timeout for this channel- See Also:
ConfigurableServerChannel.setLazy(boolean)
-
setPersistent
public void setPersistent(boolean persistent)Description copied from interface:ConfigurableServerChannel
A persistent channel is not removed when the last subscription is removed- Specified by:
setPersistent
in interfaceConfigurableServerChannel
- Parameters:
persistent
- whether the channel is persistent- See Also:
ConfigurableServerChannel.isPersistent()
-
addListener
- Specified by:
addListener
in interfaceConfigurableServerChannel
- Parameters:
listener
- the listener to add- See Also:
ConfigurableServerChannel.removeListener(ServerChannelListener)
-
removeListener
- Specified by:
removeListener
in interfaceConfigurableServerChannel
- Parameters:
listener
- the listener to remove- See Also:
ConfigurableServerChannel.addListener(ServerChannelListener)
-
getListeners
- Specified by:
getListeners
in interfaceConfigurableServerChannel
- Returns:
- an immutable list of listeners
- See Also:
ConfigurableServerChannel.addListener(ServerChannelListener)
-
listeners
-
getChannelId
- Specified by:
getChannelId
in interfaceChannel
- Returns:
- The channel ID as a
ChannelId
-
getId
-
isMeta
public boolean isMeta()Description copied from interface:Channel
Tells whether the channel is a meta channel, that is if its
id
starts with"/meta/"
. -
isService
public boolean isService()Description copied from interface:Channel
Tells whether the channel is a service channel, that is if its
id
starts with"/service/"
. -
publish
Description copied from interface:ServerChannel
Publishes the given message to this channel, delivering the message to all the
ServerSession
s subscribed to this channel.- Specified by:
publish
in interfaceServerChannel
- Parameters:
from
- the session from which the message originatesmutable
- the message to publish- See Also:
ServerChannel.publish(Session, Object)
-
publish
Description copied from interface:ServerChannel
Publishes the given information to this channel.
- Specified by:
publish
in interfaceServerChannel
- Parameters:
from
- the session from which the message originatesdata
- the data of the message- See Also:
ServerChannel.publish(Session, ServerMessage.Mutable)
-
sweep
protected void sweep() -
remove
public void remove()Description copied from interface:ServerChannel
Removes this channel, and all the children channels.
If channel "/foo", "/foo/bar" and "/foo/blip" exist, removing channel "/foo" will remove also "/foo/bar" and "/foo/blip".
The removal will notify
BayeuxServer.ChannelListener
listeners.- Specified by:
remove
in interfaceServerChannel
-
setAttribute
Description copied from interface:Channel
Sets a named channel attribute value.
Channel attributes are convenience data that allows arbitrary application data to be associated with a channel.
- Specified by:
setAttribute
in interfaceChannel
- Parameters:
name
- the attribute namevalue
- the attribute value
-
getAttribute
Description copied from interface:Channel
Retrieves the value of named channel attribute.
- Specified by:
getAttribute
in interfaceChannel
- Parameters:
name
- the name of the attribute- Returns:
- the attribute value or null if the attribute is not present
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceChannel
- Returns:
- the list of channel attribute names.
-
removeAttribute
Description copied from interface:Channel
Removes a named channel attribute.
- Specified by:
removeAttribute
in interfaceChannel
- Parameters:
name
- the name of the attribute- Returns:
- the value of the attribute
-
addAuthorizer
Description copied from interface:ConfigurableServerChannel
Adds the given
Authorizer
that grants or denies operations on this channel.Operations must be granted by at least one Authorizer and must not be denied by any.
- Specified by:
addAuthorizer
in interfaceConfigurableServerChannel
- Parameters:
authorizer
- the Authorizer to add- See Also:
ConfigurableServerChannel.removeAuthorizer(Authorizer)
,Authorizer
-
removeAuthorizer
Description copied from interface:ConfigurableServerChannel
Removes the given
Authorizer
.- Specified by:
removeAuthorizer
in interfaceConfigurableServerChannel
- Parameters:
authorizer
- the Authorizer to remove- See Also:
ConfigurableServerChannel.addAuthorizer(Authorizer)
-
getAuthorizers
- Specified by:
getAuthorizers
in interfaceConfigurableServerChannel
- Returns:
- an immutable list of authorizers for this channel
-
authorizers
-
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
IOException
-
toString
-