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.ServerChannelListenerNested 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 protectedServerChannelImpl(BayeuxServerImpl bayeux, ChannelId id) -
Method Summary
Modifier and Type Method Description voidaddAuthorizer(Authorizer authorizer)Adds the givenAuthorizerthat grants or denies operations on this channel.voidaddListener(ConfigurableServerChannel.ServerChannelListener listener)protected List<Authorizer>authorizers()Stringdump()voiddump(Appendable out, String indent)ObjectgetAttribute(String name)Retrieves the value of named channel attribute.Set<String>getAttributeNames()List<Authorizer>getAuthorizers()ChannelIdgetChannelId()StringgetId()longgetLazyTimeout()List<ConfigurableServerChannel.ServerChannelListener>getListeners()Set<ServerSession>getSubscribers()booleanisBroadcast()A broadcasting channel is a channel that is neither ameta channelnor aservice channel.booleanisDeepWild()Tells whether a channel contains the deep wild characters '**', for example/foo/**booleanisLazy()booleanisMeta()Tells whether the channel is a meta channel, that is if itsidstarts with"/meta/".booleanisPersistent()booleanisService()Tells whether the channel is a service channel, that is if itsidstarts with"/service/".booleanisWild()Tells whether a channel contains the wild character '*', for example/foo/*or if it isChannel.isDeepWild().protected List<ConfigurableServerChannel.ServerChannelListener>listeners()voidpublish(Session from, Object data)Publishes the given information to this channel.voidpublish(Session from, ServerMessage.Mutable mutable)Publishes the given message to this channel, delivering the message to all theServerSessions subscribed to this channel.voidremove()Removes this channel, and all the children channels.ObjectremoveAttribute(String name)Removes a named channel attribute.voidremoveAuthorizer(Authorizer authorizer)Removes the givenAuthorizer.voidremoveListener(ConfigurableServerChannel.ServerChannelListener listener)voidsetAttribute(String name, Object value)Sets a named channel attribute value.voidsetLazy(boolean lazy)A lazy channel marks all messages published to it as lazy.voidsetLazyTimeout(long lazyTimeout)Sets the lazy timeout for this channel.voidsetPersistent(boolean persistent)A persistent channel is not removed when the last subscription is removedbooleansubscribe(ServerSession session)Subscribes the given session to this channel.protected booleansubscribe(ServerSessionImpl session, ServerMessage message)Set<ServerSession>subscribers()protected voidsweep()StringtoString()booleanunsubscribe(ServerSession session)Unsubscribes the given session from this channel.protected booleanunsubscribe(ServerSessionImpl session, ServerMessage message)
-
Constructor Details
-
Method Details
-
subscribe
Description copied from interface:ServerChannelSubscribes the given session to this channel.
Subscriptions are effective for
broadcast channelsand 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:
subscribein interfaceServerChannel- Parameters:
session- the session to subscribe- Returns:
- whether the subscription succeeded
- See Also:
ServerChannel.unsubscribe(ServerSession)
-
subscribe
-
unsubscribe
Description copied from interface:ServerChannelUnsubscribes the given session from this channel.
Unsubscriptions are effective for
broadcast channelsand 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:
unsubscribein interfaceServerChannel- Parameters:
session- the session to unsubscribe- Returns:
- whether the unsubscription succeeded
-
unsubscribe
-
getSubscribers
- Specified by:
getSubscribersin interfaceServerChannel- Returns:
- a snapshot of the set of subscribers of this channel
-
subscribers
-
isBroadcast
public boolean isBroadcast()Description copied from interface:ChannelA broadcasting channel is a channel that is neither a
meta channelnor aservice channel.- Specified by:
isBroadcastin interfaceChannel- Returns:
- whether the channel is a broadcasting channel
-
isDeepWild
public boolean isDeepWild()Description copied from interface:ChannelTells whether a channel contains the deep wild characters '**', for example
/foo/**- Specified by:
isDeepWildin interfaceChannel- Returns:
- true if the channel contains the '**' characters
-
isLazy
public boolean isLazy()- Specified by:
isLazyin interfaceConfigurableServerChannel- Returns:
- whether the channel is lazy
- See Also:
ConfigurableServerChannel.setLazy(boolean)
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistentin interfaceConfigurableServerChannel- Returns:
- whether the channel is persistent
- See Also:
ConfigurableServerChannel.setPersistent(boolean)
-
isWild
public boolean isWild()Description copied from interface:ChannelTells 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:ConfigurableServerChannelA lazy channel marks all messages published to it as lazy.- Specified by:
setLazyin interfaceConfigurableServerChannel- Parameters:
lazy- whether the channel is lazy- See Also:
ConfigurableServerChannel.isLazy()
-
getLazyTimeout
public long getLazyTimeout()- Specified by:
getLazyTimeoutin interfaceConfigurableServerChannel- Returns:
- the lazy timeout for this channel
- See Also:
ConfigurableServerChannel.setLazyTimeout(long)
-
setLazyTimeout
public void setLazyTimeout(long lazyTimeout)Description copied from interface:ConfigurableServerChannelSets the lazy timeout for this channel. A positive value makes the channel lazy, a negative value makes the channel non-lazy.- Specified by:
setLazyTimeoutin interfaceConfigurableServerChannel- Parameters:
lazyTimeout- the lazy timeout for this channel- See Also:
ConfigurableServerChannel.setLazy(boolean)
-
setPersistent
public void setPersistent(boolean persistent)Description copied from interface:ConfigurableServerChannelA persistent channel is not removed when the last subscription is removed- Specified by:
setPersistentin interfaceConfigurableServerChannel- Parameters:
persistent- whether the channel is persistent- See Also:
ConfigurableServerChannel.isPersistent()
-
addListener
- Specified by:
addListenerin interfaceConfigurableServerChannel- Parameters:
listener- the listener to add- See Also:
ConfigurableServerChannel.removeListener(ServerChannelListener)
-
removeListener
- Specified by:
removeListenerin interfaceConfigurableServerChannel- Parameters:
listener- the listener to remove- See Also:
ConfigurableServerChannel.addListener(ServerChannelListener)
-
getListeners
- Specified by:
getListenersin interfaceConfigurableServerChannel- Returns:
- an immutable list of listeners
- See Also:
ConfigurableServerChannel.addListener(ServerChannelListener)
-
listeners
-
getChannelId
- Specified by:
getChannelIdin interfaceChannel- Returns:
- The channel ID as a
ChannelId
-
getId
-
isMeta
public boolean isMeta()Description copied from interface:ChannelTells whether the channel is a meta channel, that is if its
idstarts with"/meta/". -
isService
public boolean isService()Description copied from interface:ChannelTells whether the channel is a service channel, that is if its
idstarts with"/service/". -
publish
Description copied from interface:ServerChannelPublishes the given message to this channel, delivering the message to all the
ServerSessions subscribed to this channel.- Specified by:
publishin 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:ServerChannelPublishes the given information to this channel.
- Specified by:
publishin 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:ServerChannelRemoves 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.ChannelListenerlisteners.- Specified by:
removein interfaceServerChannel
-
setAttribute
Description copied from interface:ChannelSets a named channel attribute value.
Channel attributes are convenience data that allows arbitrary application data to be associated with a channel.
- Specified by:
setAttributein interfaceChannel- Parameters:
name- the attribute namevalue- the attribute value
-
getAttribute
Description copied from interface:ChannelRetrieves the value of named channel attribute.
- Specified by:
getAttributein interfaceChannel- Parameters:
name- the name of the attribute- Returns:
- the attribute value or null if the attribute is not present
-
getAttributeNames
- Specified by:
getAttributeNamesin interfaceChannel- Returns:
- the list of channel attribute names.
-
removeAttribute
Description copied from interface:ChannelRemoves a named channel attribute.
- Specified by:
removeAttributein interfaceChannel- Parameters:
name- the name of the attribute- Returns:
- the value of the attribute
-
addAuthorizer
Description copied from interface:ConfigurableServerChannelAdds the given
Authorizerthat 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:
addAuthorizerin interfaceConfigurableServerChannel- Parameters:
authorizer- the Authorizer to add- See Also:
ConfigurableServerChannel.removeAuthorizer(Authorizer),Authorizer
-
removeAuthorizer
Description copied from interface:ConfigurableServerChannelRemoves the given
Authorizer.- Specified by:
removeAuthorizerin interfaceConfigurableServerChannel- Parameters:
authorizer- the Authorizer to remove- See Also:
ConfigurableServerChannel.addAuthorizer(Authorizer)
-
getAuthorizers
- Specified by:
getAuthorizersin interfaceConfigurableServerChannel- Returns:
- an immutable list of authorizers for this channel
-
authorizers
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
toString
-