Interface BayeuxServer
-
- All Superinterfaces:
Bayeux
- All Known Implementing Classes:
BayeuxServerImpl
public interface BayeuxServer extends Bayeux
The server-side Bayeux interface.
An instance of the
BayeuxServerinterface is available to web applications via the ""org.cometd.bayeux"" attribute of thejavax.servlet.ServletContext.The
BayeuxServerAPIs give access to theServerSessions via thegetSession(String)method. It also allows newLocalSessionto be created within the server using thenewLocalSession(String)method.ServerChannelinstances may be accessed via thegetChannel(String)method, but the server has no direct relationship withClientSessionChannels orClientSession.If subscription semantics is required, then the
newLocalSession(String)method should be used to create aLocalSessionthat can subscribe and publish like a client-side Bayeux session.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBayeuxServer.BayeuxServerListenerCommon base interface for all server-side Bayeux listeners.static interfaceBayeuxServer.ChannelListenerSpecialized listener forServerChannelevents.static interfaceBayeuxServer.ExtensionExtension API forBayeuxServer.static interfaceBayeuxServer.SessionListenerSpecialized listener forServerSessionevents.static interfaceBayeuxServer.SubscriptionListenerSpecialized listener forServerChannelsubscription events.-
Nested classes/interfaces inherited from interface org.cometd.bayeux.Bayeux
Bayeux.BayeuxListener, Bayeux.Validator
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTRIBUTEServletContext attribute name used to obtain the Bayeux object
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddExtension(BayeuxServer.Extension extension)Adds the given extension to this Bayeux object.voidaddListener(BayeuxServer.BayeuxServerListener listener)Adds a listener to this Bayeux object.MarkedReference<ServerChannel>createChannelIfAbsent(java.lang.String channelName, ConfigurableServerChannel.Initializer... initializers)Creates aServerChanneland initializes it atomically if the channel does not exist, or returns it if it already exists.ServerChannelgetChannel(java.lang.String channelId)java.util.List<ServerChannel>getChannels()java.util.List<BayeuxServer.Extension>getExtensions()SecurityPolicygetSecurityPolicy()ServerSessiongetSession(java.lang.String clientId)java.util.List<ServerSession>getSessions()LocalSessionnewLocalSession(java.lang.String idHint)Creates a newLocalSession.ServerMessage.MutablenewMessage()voidremoveExtension(BayeuxServer.Extension extension)Removes the given extension from this Bayeux object.voidremoveListener(BayeuxServer.BayeuxServerListener listener)Removes a listener from this Bayeux object.booleanremoveSession(ServerSession session)Removes the givensessionfrom this BayeuxServer.voidsetSecurityPolicy(SecurityPolicy securityPolicy)-
Methods inherited from interface org.cometd.bayeux.Bayeux
getAllowedTransports, getKnownTransportNames, getOption, getOptionNames, getTransport, setOption
-
-
-
-
Field Detail
-
ATTRIBUTE
static final java.lang.String ATTRIBUTE
ServletContext attribute name used to obtain the Bayeux object- See Also:
- Constant Field Values
-
-
Method Detail
-
addExtension
void addExtension(BayeuxServer.Extension extension)
Adds the given extension to this Bayeux object.
- Parameters:
extension- the extension to add- See Also:
removeExtension(Extension)
-
removeExtension
void removeExtension(BayeuxServer.Extension extension)
Removes the given extension from this Bayeux object.
- Parameters:
extension- the extension to remove- See Also:
addExtension(Extension)
-
getExtensions
java.util.List<BayeuxServer.Extension> getExtensions()
- Returns:
- an immutable list of extensions present in this BayeuxServer instance
- See Also:
addExtension(Extension)
-
addListener
void addListener(BayeuxServer.BayeuxServerListener listener)
Adds a listener to this Bayeux object.
- Parameters:
listener- the listener to add- See Also:
removeListener(BayeuxServerListener)
-
removeListener
void removeListener(BayeuxServer.BayeuxServerListener listener)
Removes a listener from this Bayeux object.
- Parameters:
listener- the listener to remove- See Also:
addListener(BayeuxServerListener)
-
getChannel
ServerChannel getChannel(java.lang.String channelId)
- Parameters:
channelId- the channel identifier- Returns:
- a
ServerChannelwith the givenchannelId, or null if no such channel exists - See Also:
createChannelIfAbsent(String, ConfigurableServerChannel.Initializer...)
-
getChannels
java.util.List<ServerChannel> getChannels()
- Returns:
- the list of channels known to this BayeuxServer object
-
createChannelIfAbsent
MarkedReference<ServerChannel> createChannelIfAbsent(java.lang.String channelName, ConfigurableServerChannel.Initializer... initializers)
Creates a
ServerChanneland initializes it atomically if the channel does not exist, or returns it if it already exists.This method can be used instead of adding a
BayeuxServer.ChannelListenerto atomically initialize a channel. Theinitializerswill be called before any other thread can access the new channel instance.This method should be used when a channel needs to be initialized (e.g. by adding listeners) before any publish or subscribes can occur on the channel, or before any other thread may concurrently create the same channel.
- Parameters:
channelName- the channel nameinitializers- the initializers invoked to configure the channel- Returns:
- a
MarkedReferencewhose reference is the channel, and the mark signals whether the channel has been created because it did not exist before.
-
getSession
ServerSession getSession(java.lang.String clientId)
- Parameters:
clientId- theServerSessionidentifier- Returns:
- the
ServerSessionwith the givenclientIdor null if no such valid session exists.
-
getSessions
java.util.List<ServerSession> getSessions()
- Returns:
- the list of
ServerSessions known to this BayeuxServer object
-
removeSession
boolean removeSession(ServerSession session)
Removes the given
sessionfrom this BayeuxServer.This method triggers the invocation of all listeners that would be called if the session was disconnected or if the session timed out.
- Parameters:
session- the session to remove- Returns:
- true if the session was known to this BayeuxServer and was removed
-
newLocalSession
LocalSession newLocalSession(java.lang.String idHint)
Creates a new
LocalSession.A
LocalSessionis a server-side ClientSession that allows server-side code to have special clients (resident within the same JVM) that can be used to publish and subscribe like a client-side session would do.- Parameters:
idHint- a hint to be included in the unique clientId of the session.- Returns:
- a new
LocalSession
-
newMessage
ServerMessage.Mutable newMessage()
- Returns:
- a new or recycled mutable message instance.
-
getSecurityPolicy
SecurityPolicy getSecurityPolicy()
- Returns:
- the
SecurityPolicyassociated with this session - See Also:
setSecurityPolicy(SecurityPolicy)
-
setSecurityPolicy
void setSecurityPolicy(SecurityPolicy securityPolicy)
- Parameters:
securityPolicy- theSecurityPolicyassociated with this session- See Also:
getSecurityPolicy()
-
-