Package org.cometd.server
Class BayeuxServerImpl
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.cometd.server.BayeuxServerImpl
-
- All Implemented Interfaces:
org.cometd.bayeux.Bayeux
,org.cometd.bayeux.server.BayeuxServer
,org.eclipse.jetty.util.component.Dumpable
,org.eclipse.jetty.util.component.LifeCycle
@ManagedObject("The CometD server") public class BayeuxServerImpl extends org.eclipse.jetty.util.component.AbstractLifeCycle implements org.cometd.bayeux.server.BayeuxServer, org.eclipse.jetty.util.component.Dumpable
-
-
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.Bayeux
org.cometd.bayeux.Bayeux.BayeuxListener
-
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer
org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener, org.cometd.bayeux.server.BayeuxServer.ChannelListener, org.cometd.bayeux.server.BayeuxServer.Extension, org.cometd.bayeux.server.BayeuxServer.SessionListener, org.cometd.bayeux.server.BayeuxServer.SubscriptionListener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALLOWED_TRANSPORTS_OPTION
static java.lang.String
BROADCAST_TO_PUBLISHER_OPTION
static java.lang.String
SWEEP_PERIOD_OPTION
static java.lang.String
TRANSPORTS_OPTION
static java.lang.String
VALIDATE_MESSAGE_FIELDS_OPTION
-
Constructor Summary
Constructors Constructor Description BayeuxServerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
void
addListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
protected void
addServerSession(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage message)
org.cometd.bayeux.server.ServerTransport
addTransport(org.cometd.bayeux.server.ServerTransport transport)
org.cometd.bayeux.MarkedReference<org.cometd.bayeux.server.ServerChannel>
createChannelIfAbsent(java.lang.String channelName, org.cometd.bayeux.server.ConfigurableServerChannel.Initializer... initializers)
protected org.cometd.bayeux.server.ServerMessage.Mutable
createReply(org.cometd.bayeux.server.ServerMessage.Mutable message)
protected void
doStart()
protected void
doStop()
java.lang.String
dump()
void
dump(java.lang.Appendable out, java.lang.String indent)
protected void
error(org.cometd.bayeux.server.ServerMessage.Mutable reply, java.lang.String error)
protected void
extendOutgoing(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
void
extendReply(ServerSessionImpl sender, ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable reply, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)
protected AbstractHttpTransport
findHttpTransport(javax.servlet.http.HttpServletRequest request)
void
freeze(org.cometd.bayeux.server.ServerMessage.Mutable mutable)
java.util.List<java.lang.String>
getAllowedTransports()
org.cometd.bayeux.server.ServerChannel
getChannel(java.lang.String channelId)
java.util.List<org.cometd.bayeux.server.ServerChannel>
getChannels()
java.util.List<org.cometd.bayeux.server.BayeuxServer.Extension>
getExtensions()
org.cometd.common.JSONContext.Server
getJSONContext()
java.util.Set<java.lang.String>
getKnownTransportNames()
protected java.util.List<org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener>
getListeners()
java.lang.Object
getOption(java.lang.String qualifiedName)
protected boolean
getOption(java.lang.String name, boolean dft)
protected long
getOption(java.lang.String name, long dft)
java.util.Set<java.lang.String>
getOptionNames()
java.util.Map<java.lang.String,java.lang.Object>
getOptions()
org.cometd.bayeux.server.SecurityPolicy
getSecurityPolicy()
org.cometd.bayeux.server.ServerSession
getSession(java.lang.String clientId)
java.util.List<org.cometd.bayeux.server.ServerSession>
getSessions()
org.cometd.bayeux.server.ServerTransport
getTransport(java.lang.String transport)
java.util.List<org.cometd.bayeux.server.ServerTransport>
getTransports()
void
handle(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)
protected void
initializeJSONContext()
protected void
initializeMetaChannels()
protected void
initializeServerTransports()
boolean
isBroadcastToPublisher()
boolean
isDetailedDump()
org.cometd.bayeux.ChannelId
newChannelId(java.lang.String id)
org.cometd.bayeux.server.LocalSession
newLocalSession(java.lang.String idHint)
org.cometd.bayeux.server.ServerMessage.Mutable
newMessage()
org.cometd.bayeux.server.ServerMessage.Mutable
newMessage(org.cometd.bayeux.server.ServerMessage original)
ServerSessionImpl
newServerSession()
protected void
publish(ServerSessionImpl session, ServerChannelImpl channel, org.cometd.bayeux.server.ServerMessage.Mutable message, boolean receiving, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
long
randomLong()
void
removeExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
void
removeListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
protected boolean
removeServerChannel(ServerChannelImpl channel)
boolean
removeServerSession(org.cometd.bayeux.server.ServerSession session, boolean timedOut)
boolean
removeSession(org.cometd.bayeux.server.ServerSession session)
protected org.cometd.bayeux.Promise<java.lang.Boolean>
resolveLoop(org.cometd.common.AsyncFoldLeft.Loop<java.lang.Boolean> loop)
org.eclipse.jetty.util.thread.Scheduler.Task
schedule(java.lang.Runnable task, long delay)
Entry point to schedule tasks in CometD.void
setAllowedTransports(java.lang.String... allowed)
void
setAllowedTransports(java.util.List<java.lang.String> allowed)
void
setDetailedDump(boolean detailedDump)
void
setOption(java.lang.String qualifiedName, java.lang.Object value)
void
setOptions(java.util.Map<java.lang.String,java.lang.Object> options)
void
setSecurityPolicy(org.cometd.bayeux.server.SecurityPolicy securityPolicy)
void
setTransports(java.util.List<org.cometd.bayeux.server.ServerTransport> transports)
void
setTransports(org.cometd.bayeux.server.ServerTransport... transports)
void
sweep()
protected void
unknownSession(org.cometd.bayeux.server.ServerMessage.Mutable reply)
protected java.lang.String
validateMessage(org.cometd.bayeux.server.ServerMessage.Mutable message)
-
-
-
Field Detail
-
ALLOWED_TRANSPORTS_OPTION
public static final java.lang.String ALLOWED_TRANSPORTS_OPTION
- See Also:
- Constant Field Values
-
SWEEP_PERIOD_OPTION
public static final java.lang.String SWEEP_PERIOD_OPTION
- See Also:
- Constant Field Values
-
TRANSPORTS_OPTION
public static final java.lang.String TRANSPORTS_OPTION
- See Also:
- Constant Field Values
-
VALIDATE_MESSAGE_FIELDS_OPTION
public static final java.lang.String VALIDATE_MESSAGE_FIELDS_OPTION
- See Also:
- Constant Field Values
-
BROADCAST_TO_PUBLISHER_OPTION
public static final java.lang.String BROADCAST_TO_PUBLISHER_OPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
doStart
protected void doStart() throws java.lang.Exception
- Overrides:
doStart
in classorg.eclipse.jetty.util.component.AbstractLifeCycle
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
- Overrides:
doStop
in classorg.eclipse.jetty.util.component.AbstractLifeCycle
- Throws:
java.lang.Exception
-
initializeMetaChannels
protected void initializeMetaChannels()
-
initializeJSONContext
protected void initializeJSONContext() throws java.lang.Exception
- Throws:
java.lang.Exception
-
initializeServerTransports
protected void initializeServerTransports()
-
schedule
public org.eclipse.jetty.util.thread.Scheduler.Task schedule(java.lang.Runnable task, long delay)
Entry point to schedule tasks in CometD.
Subclasses may override and run the task in a
Executor
, rather than in the scheduler thread.- Parameters:
task
- the task to scheduledelay
- the delay, in milliseconds, to run the task- Returns:
- the task promise
-
newChannelId
public org.cometd.bayeux.ChannelId newChannelId(java.lang.String id)
-
getOptions
public java.util.Map<java.lang.String,java.lang.Object> getOptions()
-
getOption
@ManagedOperation(value="The value of the given configuration option", impact="INFO") public java.lang.Object getOption(@Name("optionName") java.lang.String qualifiedName)
- Specified by:
getOption
in interfaceorg.cometd.bayeux.Bayeux
-
getOption
protected long getOption(java.lang.String name, long dft)
-
getOption
protected boolean getOption(java.lang.String name, boolean dft)
-
getOptionNames
public java.util.Set<java.lang.String> getOptionNames()
- Specified by:
getOptionNames
in interfaceorg.cometd.bayeux.Bayeux
-
setOption
public void setOption(java.lang.String qualifiedName, java.lang.Object value)
- Specified by:
setOption
in interfaceorg.cometd.bayeux.Bayeux
-
setOptions
public void setOptions(java.util.Map<java.lang.String,java.lang.Object> options)
-
randomLong
public long randomLong()
-
getSecurityPolicy
public org.cometd.bayeux.server.SecurityPolicy getSecurityPolicy()
- Specified by:
getSecurityPolicy
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getJSONContext
public org.cometd.common.JSONContext.Server getJSONContext()
-
createChannelIfAbsent
public org.cometd.bayeux.MarkedReference<org.cometd.bayeux.server.ServerChannel> createChannelIfAbsent(java.lang.String channelName, org.cometd.bayeux.server.ConfigurableServerChannel.Initializer... initializers)
- Specified by:
createChannelIfAbsent
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getSessions
public java.util.List<org.cometd.bayeux.server.ServerSession> getSessions()
- Specified by:
getSessions
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
removeSession
public boolean removeSession(org.cometd.bayeux.server.ServerSession session)
- Specified by:
removeSession
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getSession
public org.cometd.bayeux.server.ServerSession getSession(java.lang.String clientId)
- Specified by:
getSession
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
addServerSession
protected void addServerSession(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage message)
-
removeServerSession
public boolean removeServerSession(org.cometd.bayeux.server.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
public ServerSessionImpl newServerSession()
-
newLocalSession
public org.cometd.bayeux.server.LocalSession newLocalSession(java.lang.String idHint)
- Specified by:
newLocalSession
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
newMessage
public org.cometd.bayeux.server.ServerMessage.Mutable newMessage()
- Specified by:
newMessage
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
newMessage
public org.cometd.bayeux.server.ServerMessage.Mutable newMessage(org.cometd.bayeux.server.ServerMessage original)
-
setSecurityPolicy
public void setSecurityPolicy(org.cometd.bayeux.server.SecurityPolicy securityPolicy)
- Specified by:
setSecurityPolicy
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
addExtension
public void addExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
- Specified by:
addExtension
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
removeExtension
public void removeExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
- Specified by:
removeExtension
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getExtensions
public java.util.List<org.cometd.bayeux.server.BayeuxServer.Extension> getExtensions()
- Specified by:
getExtensions
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
addListener
public void addListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
- Specified by:
addListener
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getChannel
public org.cometd.bayeux.server.ServerChannel getChannel(java.lang.String channelId)
- Specified by:
getChannel
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
getChannels
public java.util.List<org.cometd.bayeux.server.ServerChannel> getChannels()
- Specified by:
getChannels
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
removeListener
public void removeListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
- Specified by:
removeListener
in interfaceorg.cometd.bayeux.server.BayeuxServer
-
handle
public void handle(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)
-
validateMessage
protected java.lang.String validateMessage(org.cometd.bayeux.server.ServerMessage.Mutable message)
-
publish
protected void publish(ServerSessionImpl session, ServerChannelImpl channel, org.cometd.bayeux.server.ServerMessage.Mutable message, boolean receiving, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
-
resolveLoop
protected org.cometd.bayeux.Promise<java.lang.Boolean> resolveLoop(org.cometd.common.AsyncFoldLeft.Loop<java.lang.Boolean> loop)
-
freeze
public void freeze(org.cometd.bayeux.server.ServerMessage.Mutable mutable)
-
extendOutgoing
protected void extendOutgoing(org.cometd.bayeux.server.ServerSession sender, org.cometd.bayeux.server.ServerSession session, org.cometd.bayeux.server.ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
-
extendReply
public void extendReply(ServerSessionImpl sender, ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage.Mutable reply, org.cometd.bayeux.Promise<org.cometd.bayeux.server.ServerMessage.Mutable> promise)
-
removeServerChannel
protected boolean removeServerChannel(ServerChannelImpl channel)
-
getListeners
protected java.util.List<org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener> getListeners()
-
getKnownTransportNames
public java.util.Set<java.lang.String> getKnownTransportNames()
- Specified by:
getKnownTransportNames
in interfaceorg.cometd.bayeux.Bayeux
-
getTransport
public org.cometd.bayeux.server.ServerTransport getTransport(java.lang.String transport)
- Specified by:
getTransport
in interfaceorg.cometd.bayeux.Bayeux
-
addTransport
public org.cometd.bayeux.server.ServerTransport addTransport(org.cometd.bayeux.server.ServerTransport transport)
-
setTransports
public void setTransports(org.cometd.bayeux.server.ServerTransport... transports)
-
setTransports
public void setTransports(java.util.List<org.cometd.bayeux.server.ServerTransport> transports)
-
getTransports
public java.util.List<org.cometd.bayeux.server.ServerTransport> getTransports()
-
findHttpTransport
protected AbstractHttpTransport findHttpTransport(javax.servlet.http.HttpServletRequest request)
-
getAllowedTransports
@ManagedAttribute(value="The transports allowed by this server", readonly=true) public java.util.List<java.lang.String> getAllowedTransports()
- Specified by:
getAllowedTransports
in interfaceorg.cometd.bayeux.Bayeux
-
setAllowedTransports
public void setAllowedTransports(java.lang.String... allowed)
-
setAllowedTransports
public void setAllowedTransports(java.util.List<java.lang.String> allowed)
-
isBroadcastToPublisher
@ManagedAttribute(value="Whether this server broadcast messages to the publisher", readonly=true) public boolean isBroadcastToPublisher()
-
unknownSession
protected void unknownSession(org.cometd.bayeux.server.ServerMessage.Mutable reply)
-
error
protected void error(org.cometd.bayeux.server.ServerMessage.Mutable reply, java.lang.String error)
-
createReply
protected org.cometd.bayeux.server.ServerMessage.Mutable createReply(org.cometd.bayeux.server.ServerMessage.Mutable message)
-
sweep
@ManagedOperation(value="Sweeps channels and sessions of this BayeuxServer", impact="ACTION") public void sweep()
-
isDetailedDump
@ManagedAttribute("Reports additional details in the dump") public boolean isDetailedDump()
-
setDetailedDump
public void setDetailedDump(boolean detailedDump)
-
dump
@ManagedOperation(value="Dumps the BayeuxServer state", impact="INFO") public java.lang.String dump()
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
java.io.IOException
-
-