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 interface org.cometd.bayeux.server.BayeuxServer
BayeuxServer.BayeuxServerListener, BayeuxServer.ChannelListener, BayeuxServer.Extension, BayeuxServer.SessionListener, BayeuxServer.SubscriptionListener
 
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
protected BayeuxServerImpl()
           
 
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)
           
protected  ServerMessage.Mutable createReply(ServerMessage.Mutable message)
           
protected  void doStart()
           
protected  void doStop()
           
 java.lang.String dump()
           
protected  void error(ServerMessage.Mutable reply, java.lang.String error)
           
protected  boolean extendRecv(ServerSessionImpl from, ServerMessage.Mutable message)
           
 ServerMessage extendReply(ServerSessionImpl session, ServerMessage reply)
           
protected  boolean extendSend(ServerSessionImpl to, ServerMessage.Mutable message)
           
 java.util.List<java.lang.String> getAllowedTransports()
           
 ServerChannel getChannel(java.lang.String channelId)
           
 ServerChannel getChannel(java.lang.String channelId, boolean create)
           
 ServerTransport getCurrentTransport()
           
 java.util.Set<java.lang.String> getKnownTransportNames()
           
 org.eclipse.jetty.util.log.Logger getLogger()
           
protected  long getLongOptions(java.lang.String name, long dft)
          Get an option value as a long
 java.lang.Object getOption(java.lang.String qualifiedName)
           
 java.util.Set<java.lang.String> getOptionNames()
           
 java.util.Map<java.lang.String,java.lang.Object> getOptions()
           
protected  ServerChannelImpl getRootChannel()
           
 SecurityPolicy getSecurityPolicy()
           
 ServerMessagePool getServerMessagePool()
           
 ServerSession getSession(java.lang.String clientId)
           
 java.util.Collection<ServerSessionImpl> getSessions()
           
 Transport getTransport(java.lang.String transport)
           
 ServerMessage handle(ServerSessionImpl session, ServerMessage.Mutable message)
          Extend and handle in incoming message.
 ChannelId newChannelId(java.lang.String id)
           
 LocalSession newLocalSession(java.lang.String idHint)
           
 ServerMessage.Mutable newMessage()
           
 ServerMessage.Mutable newMessage(ServerMessage tocopy)
           
protected  ServerSessionImpl newServerSession()
           
protected  ServerSessionImpl newServerSession(LocalSessionImpl local, java.lang.String idHint)
           
 int randomInt()
           
 int randomInt(int n)
           
 long randomLong()
           
 void removeListener(BayeuxServer.BayeuxServerListener listener)
           
 boolean removeServerSession(ServerSession session, boolean timedout)
           
 ServerChannelImpl root()
           
 void setAllowedTransports(java.util.List<java.lang.String> allowed)
           
 void setAllowedTransports(java.lang.String... allowed)
           
 void setCurrentTransport(ServerTransport transport)
           
 void setOption(java.lang.String qualifiedName, java.lang.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

protected BayeuxServerImpl()
Method Detail

getLogger

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

doStart

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

doStop

protected void doStop()
               throws java.lang.Exception
Overrides:
doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
Throws:
java.lang.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(java.lang.String id)

getOptions

public java.util.Map<java.lang.String,java.lang.Object> getOptions()

getOption

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

getLongOptions

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

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

getOptionNames

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

setOption

public void setOption(java.lang.String qualifiedName,
                      java.lang.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()

root

public ServerChannelImpl root()

getServerMessagePool

public ServerMessagePool getServerMessagePool()

setCurrentTransport

public void setCurrentTransport(ServerTransport transport)

getCurrentTransport

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

getSecurityPolicy

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

getChannel

public ServerChannel getChannel(java.lang.String channelId,
                                boolean create)
Specified by:
getChannel in interface BayeuxServer

getSessions

public java.util.Collection<ServerSessionImpl> getSessions()

getSession

public ServerSession getSession(java.lang.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,
                                             java.lang.String idHint)

newLocalSession

public LocalSession newLocalSession(java.lang.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

addListener

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

getChannel

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

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

extendReply

public ServerMessage extendReply(ServerSessionImpl session,
                                 ServerMessage reply)

extendRecv

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

extendSend

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

getAllowedTransports

public java.util.List<java.lang.String> getAllowedTransports()
Specified by:
getAllowedTransports in interface Bayeux

getKnownTransportNames

public java.util.Set<java.lang.String> getKnownTransportNames()
Specified by:
getKnownTransportNames in interface Bayeux

getTransport

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

addTransport

public void addTransport(Transport transport)

setAllowedTransports

public void setAllowedTransports(java.lang.String... allowed)

setAllowedTransports

public void setAllowedTransports(java.util.List<java.lang.String> allowed)

error

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

createReply

protected ServerMessage.Mutable createReply(ServerMessage.Mutable message)

getRootChannel

protected ServerChannelImpl getRootChannel()

dump

public java.lang.String dump()


Copyright © 2010 Dojo Foundation. All Rights Reserved.