org.cometd.server
Class BayeuxServerImpl

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.cometd.server.BayeuxServerImpl
All Implemented Interfaces:
Bayeux, BayeuxServer, org.eclipse.jetty.util.component.LifeCycle

public class BayeuxServerImpl
extends org.eclipse.jetty.util.component.AbstractLifeCycle
implements BayeuxServer

Options to configure the server are:

tickIntervalMsThe time in milliseconds between ticks to check for timeouts etc sweepIntervalMsThe time in milliseconds between sweeps of channels to remove invalid subscribers and non-persistent channels


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer
BayeuxServer.BayeuxServerListener, BayeuxServer.ChannelListener, BayeuxServer.Extension, BayeuxServer.SessionListener, BayeuxServer.SubscriptionListener
 
Nested classes/interfaces inherited from interface org.cometd.bayeux.Bayeux
Bayeux.BayeuxListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener
 
Field Summary
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Fields inherited from interface org.cometd.bayeux.server.BayeuxServer
ATTRIBUTE
 
Constructor Summary
BayeuxServerImpl()
           
BayeuxServerImpl(boolean initializeDefaultTransports)
           
 
Method Summary
 void addExtension(BayeuxServer.Extension extension)
           
 void addListener(BayeuxServer.BayeuxServerListener listener)
           
protected  void addServerSession(ServerSessionImpl session)
           
 void addTransport(Transport transport)
           
 void cancelTimeout(org.eclipse.jetty.util.thread.Timeout.Task task)
           
 boolean createIfAbsent(String channelId, ConfigurableServerChannel.Initializer... initializers)
           
protected  ServerMessage.Mutable createReply(ServerMessage.Mutable message)
           
protected  void doPublish(ServerSessionImpl from, ServerChannelImpl to, ServerMessage.Mutable mutable)
           
protected  void doStart()
           
protected  void doStop()
           
 void doSweep()
           
 String dump()
           
protected  void error(ServerMessage.Mutable reply, String error)
           
protected  boolean extendRecv(ServerSessionImpl from, ServerMessage.Mutable message)
           
 ServerMessage extendReply(ServerSessionImpl from, ServerSessionImpl to, ServerMessage reply)
           
protected  boolean extendSend(ServerSessionImpl from, ServerSessionImpl to, ServerMessage.Mutable message)
           
 List<String> getAllowedTransports()
           
 ServerChannel getChannel(String channelId)
           
 List<ServerChannelImpl> getChannelChildren(ChannelId id)
           
 ServerTransport getCurrentTransport()
           
 Set<String> getKnownTransportNames()
           
 org.eclipse.jetty.util.log.Logger getLogger()
           
protected  long getLongOptions(String name, long dft)
          Get an option value as a long
 Object getOption(String qualifiedName)
           
 Set<String> getOptionNames()
           
 Map<String,Object> getOptions()
           
 SecurityPolicy getSecurityPolicy()
           
 ServerSession getSession(String clientId)
           
 Collection<ServerSessionImpl> getSessions()
           
 Transport getTransport(String transport)
           
 ServerMessage handle(ServerSessionImpl session, ServerMessage.Mutable message)
          Extend and handle in incoming message.
 void initializeDefaultTransports()
          Initialize the default transports.
 ChannelId newChannelId(String id)
           
 LocalSession newLocalSession(String idHint)
           
 ServerMessage.Mutable newMessage()
           
 ServerMessage.Mutable newMessage(ServerMessage tocopy)
           
protected  ServerSessionImpl newServerSession()
           
protected  ServerSessionImpl newServerSession(LocalSessionImpl local, String idHint)
           
 int randomInt()
           
 int randomInt(int n)
           
 long randomLong()
           
 void removeExtension(BayeuxServer.Extension extension)
           
 void removeListener(BayeuxServer.BayeuxServerListener listener)
           
 boolean removeServerSession(ServerSession session, boolean timedout)
           
 void setAllowedTransports(List<String> allowed)
           
 void setAllowedTransports(String... allowed)
           
 void setCurrentTransport(AbstractServerTransport transport)
           
 void setOption(String qualifiedName, Object value)
           
 void setSecurityPolicy(SecurityPolicy securityPolicy)
           
 void startTimeout(org.eclipse.jetty.util.thread.Timeout.Task task, long interval)
           
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BayeuxServerImpl

public BayeuxServerImpl()

BayeuxServerImpl

public BayeuxServerImpl(boolean initializeDefaultTransports)
Method Detail

initializeDefaultTransports

public void initializeDefaultTransports()
Initialize the default transports. This method creates a WebSocketTransport, a JSONTransport and a JSONPTransport and calls setAllowedTransports(String...).


getLogger

public org.eclipse.jetty.util.log.Logger getLogger()

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class org.eclipse.jetty.util.component.AbstractLifeCycle
Throws:
Exception
See Also:
AbstractLifeCycle.doStart()

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
Throws:
Exception
See Also:
AbstractLifeCycle.doStop()

startTimeout

public void startTimeout(org.eclipse.jetty.util.thread.Timeout.Task task,
                         long interval)

cancelTimeout

public void cancelTimeout(org.eclipse.jetty.util.thread.Timeout.Task task)

newChannelId

public ChannelId newChannelId(String id)

getOptions

public Map<String,Object> getOptions()

getOption

public Object getOption(String qualifiedName)
Specified by:
getOption in interface Bayeux
See Also:
Bayeux.getOption(java.lang.String)

getLongOptions

protected long getLongOptions(String name,
                              long dft)
Get an option value as a long

Parameters:
name -
dft - The default value
Returns:
long value

getOptionNames

public Set<String> getOptionNames()
Specified by:
getOptionNames in interface Bayeux
See Also:
Bayeux.getOptionNames()

setOption

public void setOption(String qualifiedName,
                      Object value)
Specified by:
setOption in interface Bayeux
See Also:
Bayeux.setOption(java.lang.String, java.lang.Object)

randomInt

public int randomInt()

randomInt

public int randomInt(int n)

randomLong

public long randomLong()

setCurrentTransport

public void setCurrentTransport(AbstractServerTransport transport)

getCurrentTransport

public ServerTransport getCurrentTransport()
Specified by:
getCurrentTransport in interface BayeuxServer

getSecurityPolicy

public SecurityPolicy getSecurityPolicy()
Specified by:
getSecurityPolicy in interface BayeuxServer

createIfAbsent

public boolean createIfAbsent(String channelId,
                              ConfigurableServerChannel.Initializer... initializers)
Specified by:
createIfAbsent in interface BayeuxServer

getSessions

public Collection<ServerSessionImpl> getSessions()

getSession

public ServerSession getSession(String clientId)
Specified by:
getSession in interface BayeuxServer

addServerSession

protected void addServerSession(ServerSessionImpl session)

removeServerSession

public boolean removeServerSession(ServerSession session,
                                   boolean timedout)
Parameters:
session -
timedout -
Returns:
true if the session was removed and was connected

newServerSession

protected ServerSessionImpl newServerSession()

newServerSession

protected ServerSessionImpl newServerSession(LocalSessionImpl local,
                                             String idHint)

newLocalSession

public LocalSession newLocalSession(String idHint)
Specified by:
newLocalSession in interface BayeuxServer

newMessage

public ServerMessage.Mutable newMessage()
Specified by:
newMessage in interface BayeuxServer

newMessage

public ServerMessage.Mutable newMessage(ServerMessage tocopy)

setSecurityPolicy

public void setSecurityPolicy(SecurityPolicy securityPolicy)
Specified by:
setSecurityPolicy in interface BayeuxServer

addExtension

public void addExtension(BayeuxServer.Extension extension)
Specified by:
addExtension in interface BayeuxServer

removeExtension

public void removeExtension(BayeuxServer.Extension extension)
Specified by:
removeExtension in interface BayeuxServer

addListener

public void addListener(BayeuxServer.BayeuxServerListener listener)
Specified by:
addListener in interface BayeuxServer

getChannel

public ServerChannel getChannel(String channelId)
Specified by:
getChannel in interface BayeuxServer

getChannelChildren

public List<ServerChannelImpl> getChannelChildren(ChannelId id)

removeListener

public void removeListener(BayeuxServer.BayeuxServerListener listener)
Specified by:
removeListener in interface BayeuxServer

handle

public ServerMessage handle(ServerSessionImpl session,
                            ServerMessage.Mutable message)
Extend and handle in incoming message.

Parameters:
session - The session if known
message - The message.
Returns:
An unextended reply message

doPublish

protected void doPublish(ServerSessionImpl from,
                         ServerChannelImpl to,
                         ServerMessage.Mutable mutable)

extendReply

public ServerMessage extendReply(ServerSessionImpl from,
                                 ServerSessionImpl to,
                                 ServerMessage reply)

extendRecv

protected boolean extendRecv(ServerSessionImpl from,
                             ServerMessage.Mutable message)

extendSend

protected boolean extendSend(ServerSessionImpl from,
                             ServerSessionImpl to,
                             ServerMessage.Mutable message)

getAllowedTransports

public List<String> getAllowedTransports()
Specified by:
getAllowedTransports in interface Bayeux

getKnownTransportNames

public Set<String> getKnownTransportNames()
Specified by:
getKnownTransportNames in interface Bayeux

getTransport

public Transport getTransport(String transport)
Specified by:
getTransport in interface Bayeux

addTransport

public void addTransport(Transport transport)

setAllowedTransports

public void setAllowedTransports(String... allowed)

setAllowedTransports

public void setAllowedTransports(List<String> allowed)

error

protected void error(ServerMessage.Mutable reply,
                     String error)

createReply

protected ServerMessage.Mutable createReply(ServerMessage.Mutable message)

doSweep

public void doSweep()

dump

public String dump()


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