org.cometd.bayeux.server
Interface BayeuxServer

All Superinterfaces:
Bayeux

public interface BayeuxServer
extends Bayeux

The server-side Bayeux interface.

An instance of the BayeuxServer interface is available to web applications via the ""org.cometd.bayeux"" attribute of the servlet context.

The BayeuxServer APIs give access to the ServerSessions via the getSession(String) method. It also allows new LocalSession to be created within the server using the newLocalSession(String) method.

ServerChannel instances may be accessed via the getChannel(String) method, but the server has no direct relationship with ClientSessionChannels or ClientSession.

If subscription semantics is required, then the newLocalSession(String) method should be used to create a LocalSession that can subscribe and publish like a client-side Bayeux session.

Version:
$Revision: 1483 $ $Date: 2009-03-04 14:56:47 +0100 (Wed, 04 Mar 2009) $

Nested Class Summary
static interface BayeuxServer.BayeuxServerListener
          Common base interface for all server-side Bayeux listeners
static interface BayeuxServer.ChannelListener
          Specialized listener for ServerChannel events.
static interface BayeuxServer.Extension
          Extension API for BayeuxServer.
static interface BayeuxServer.SessionListener
          Specialized listener for ServerSession events.
static interface BayeuxServer.SubscriptionListener
          Specialized listener for ServerChannel subscription events.
 
Nested classes/interfaces inherited from interface org.cometd.bayeux.Bayeux
Bayeux.BayeuxListener
 
Field Summary
static String ATTRIBUTE
          ServletContext attribute name used to obtain the Bayeux object
 
Method Summary
 void addExtension(BayeuxServer.Extension extension)
          Adds the given extension to this Bayeux object.
 void addListener(BayeuxServer.BayeuxServerListener listener)
          Adds a listener to this Bayeux object.
 boolean createIfAbsent(String channelId, ConfigurableServerChannel.Initializer... initializers)
          Creates a ServerChannel and initializes it atomically.
 ServerChannel getChannel(String channelId)
           
 List<ServerChannel> getChannels()
           
 BayeuxContext getContext()
           
 Transport getCurrentTransport()
           
 SecurityPolicy getSecurityPolicy()
           
 ServerSession getSession(String clientId)
           
 List<ServerSession> getSessions()
           
 LocalSession newLocalSession(String idHint)
          Creates a new LocalSession.
 ServerMessage.Mutable newMessage()
           
 void removeExtension(BayeuxServer.Extension extension)
          Removes the given extension from this Bayeux object
 void removeListener(BayeuxServer.BayeuxServerListener listener)
          Removes a listener from this Bayeux object.
 void setSecurityPolicy(SecurityPolicy securityPolicy)
           
 
Methods inherited from interface org.cometd.bayeux.Bayeux
getAllowedTransports, getKnownTransportNames, getOption, getOptionNames, getTransport, setOption
 

Field Detail

ATTRIBUTE

static final 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)

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(String channelId)
Parameters:
channelId - the channel identifier
Returns:
a ServerChannel with the given channelId, or null if no such channel exists
See Also:
createIfAbsent(String, org.cometd.bayeux.server.ConfigurableServerChannel.Initializer...)

getChannels

List<ServerChannel> getChannels()
Returns:
the list of channels known to this BayeuxServer object

createIfAbsent

boolean createIfAbsent(String channelId,
                       ConfigurableServerChannel.Initializer... initializers)

Creates a ServerChannel and initializes it atomically.

This method can be used instead of adding a BayeuxServer.ChannelListener to atomically initialize a channel. The initializer will be called before any other thread can access the new channel instance.

The createIfAbsent method should be used when a channel needs to be intialized (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:
channelId - the channel identifier
initializers - the initializers invoked to configure the channel
Returns:
true if the channel was initialized, false otherwise

getSession

ServerSession getSession(String clientId)
Parameters:
clientId - the ServerSession identifier
Returns:
the ServerSession with the given clientId or null if no such valid session exists.

getSessions

List<ServerSession> getSessions()
Returns:
the list of ServerSessions known to this BayeuxServer object

newLocalSession

LocalSession newLocalSession(String idHint)

Creates a new LocalSession.

A LocalSession is 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 SecurityPolicy associated with this session
See Also:
setSecurityPolicy(SecurityPolicy)

setSecurityPolicy

void setSecurityPolicy(SecurityPolicy securityPolicy)
Parameters:
securityPolicy - the SecurityPolicy associated with this session
See Also:
getSecurityPolicy()

getCurrentTransport

Transport getCurrentTransport()
Returns:
the current transport instance of the current thread

getContext

BayeuxContext getContext()
Returns:
the current Context, is equivalent to ((ServerTransport)getCurrentTransport()).ServerTransport.getContext()


Copyright © 2008-2010 Dojo Foundation. All Rights Reserved.