org.cometd.server
Class BayeuxServerImpl
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
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:
tickIntervalMs| The 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 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.eclipse.jetty.util.component.LifeCycle |
org.eclipse.jetty.util.component.LifeCycle.Listener |
| Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING |
|
Method Summary |
void |
addExtension(BayeuxServer.Extension extension)
|
void |
addListener(BayeuxServer.BayeuxServerListener listener)
|
protected void |
addServerSession(ServerSessionImpl session)
|
void |
addTransport(ServerTransport 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(ServerSession from,
ServerMessage.Mutable message)
|
ServerMessage.Mutable |
extendReply(ServerSessionImpl from,
ServerSessionImpl to,
ServerMessage.Mutable reply)
|
protected boolean |
extendSend(ServerSession from,
ServerSession to,
ServerMessage.Mutable message)
|
List<String> |
getAllowedTransports()
|
ServerChannel |
getChannel(String channelId)
|
List<ServerChannelImpl> |
getChannelChildren(ChannelId id)
|
List<ServerChannel> |
getChannels()
|
BayeuxContext |
getContext()
|
ServerTransport |
getCurrentTransport()
|
Set<String> |
getKnownTransportNames()
|
protected List<BayeuxServer.BayeuxServerListener> |
getListeners()
|
org.eclipse.jetty.util.log.Logger |
getLogger()
|
Object |
getOption(String qualifiedName)
|
protected long |
getOption(String name,
long dft)
Get an option value as a long |
Set<String> |
getOptionNames()
|
Map<String,Object> |
getOptions()
|
SecurityPolicy |
getSecurityPolicy()
|
ServerSession |
getSession(String clientId)
|
List<ServerSession> |
getSessions()
|
ServerTransport |
getTransport(String transport)
|
ServerMessage.Mutable |
handle(ServerSessionImpl session,
ServerMessage.Mutable message)
Extend and handle in incoming message. |
protected void |
initializeDefaultTransports()
Initialize the default transports. |
protected void |
initializeMetaChannels()
|
ChannelId |
newChannelId(String id)
|
LocalSession |
newLocalSession(String idHint)
|
ServerMessage.Mutable |
newMessage()
|
ServerMessage.Mutable |
newMessage(ServerMessage tocopy)
|
protected ServerSessionImpl |
newServerSession()
|
long |
randomLong()
|
void |
removeExtension(BayeuxServer.Extension extension)
|
void |
removeListener(BayeuxServer.BayeuxServerListener listener)
|
protected boolean |
removeServerChannel(ServerChannelImpl channel)
|
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 |
setOptions(Map<String,Object> options)
|
void |
setSecurityPolicy(SecurityPolicy securityPolicy)
|
void |
setTransports(List<ServerTransport> transports)
|
void |
setTransports(ServerTransport... transports)
|
void |
startTimeout(org.eclipse.jetty.util.thread.Timeout.Task task,
long interval)
|
protected void |
unknownSession(ServerMessage.Mutable reply)
|
| Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle |
addLifeCycleListener, getState, 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 |
LOG_LEVEL
public static final String LOG_LEVEL
- See Also:
- Constant Field Values
OFF_LOG_LEVEL
public static final int OFF_LOG_LEVEL
- See Also:
- Constant Field Values
CONFIG_LOG_LEVEL
public static final int CONFIG_LOG_LEVEL
- See Also:
- Constant Field Values
INFO_LOG_LEVEL
public static final int INFO_LOG_LEVEL
- See Also:
- Constant Field Values
DEBUG_LOG_LEVEL
public static final int DEBUG_LOG_LEVEL
- See Also:
- Constant Field Values
BayeuxServerImpl
public BayeuxServerImpl()
BayeuxServerImpl
public BayeuxServerImpl(List<ServerTransport> transports)
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()
initializeMetaChannels
protected void initializeMetaChannels()
initializeDefaultTransports
protected void initializeDefaultTransports()
- Initialize the default transports.
This method creates a JSONTransport and a JSONPTransport.
If no allowed transport have been set then adds all known transports as allowed transports.
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)
getOption
protected long getOption(String name,
long dft)
- Get an option value as a long
- Parameters:
name - The option namedft - 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)
setOptions
public void setOptions(Map<String,Object> options)
randomLong
public long randomLong()
setCurrentTransport
public void setCurrentTransport(AbstractServerTransport transport)
getCurrentTransport
public ServerTransport getCurrentTransport()
- Specified by:
getCurrentTransport in interface BayeuxServer
getContext
public BayeuxContext getContext()
- Specified by:
getContext 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 List<ServerSession> getSessions()
- Specified by:
getSessions in interface BayeuxServer
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 - the session to removetimedout - whether the remove reason is server-side expiration
- Returns:
- true if the session was removed and was connected
newServerSession
protected ServerSessionImpl newServerSession()
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
getChannels
public List<ServerChannel> getChannels()
- Specified by:
getChannels 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.Mutable handle(ServerSessionImpl session,
ServerMessage.Mutable message)
- Extend and handle in incoming message.
- Parameters:
session - The session if knownmessage - The message.
- Returns:
- An unextended reply message
doPublish
protected void doPublish(ServerSessionImpl from,
ServerChannelImpl to,
ServerMessage.Mutable mutable)
extendReply
public ServerMessage.Mutable extendReply(ServerSessionImpl from,
ServerSessionImpl to,
ServerMessage.Mutable reply)
extendRecv
protected boolean extendRecv(ServerSession from,
ServerMessage.Mutable message)
extendSend
protected boolean extendSend(ServerSession from,
ServerSession to,
ServerMessage.Mutable message)
removeServerChannel
protected boolean removeServerChannel(ServerChannelImpl channel)
getListeners
protected List<BayeuxServer.BayeuxServerListener> getListeners()
getKnownTransportNames
public Set<String> getKnownTransportNames()
- Specified by:
getKnownTransportNames in interface Bayeux
getTransport
public ServerTransport getTransport(String transport)
- Specified by:
getTransport in interface Bayeux
addTransport
public void addTransport(ServerTransport transport)
setTransports
public void setTransports(ServerTransport... transports)
setTransports
public void setTransports(List<ServerTransport> transports)
getAllowedTransports
public List<String> getAllowedTransports()
- Specified by:
getAllowedTransports in interface Bayeux
setAllowedTransports
public void setAllowedTransports(String... allowed)
setAllowedTransports
public void setAllowedTransports(List<String> allowed)
unknownSession
protected void unknownSession(ServerMessage.Mutable reply)
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-2011 Dojo Foundation. All Rights Reserved.