Class BayeuxServerImpl
- All Implemented Interfaces:
Bayeux,BayeuxServer,org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.Dumpable.DumpableContainer,org.eclipse.jetty.util.component.LifeCycle
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.cometd.bayeux.Bayeux
Bayeux.BayeuxListener, Bayeux.ValidatorNested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer
BayeuxServer.BayeuxServerListener, BayeuxServer.ChannelListener, BayeuxServer.Extension, BayeuxServer.SessionListener, BayeuxServer.SubscriptionListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.cometd.bayeux.server.BayeuxServer
ATTRIBUTEFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtension(BayeuxServer.Extension extension) Adds the given extension to this Bayeux object.voidaddListener(BayeuxServer.BayeuxServerListener listener) Adds a listener to this Bayeux object.protected voidaddServerSession(ServerSessionImpl session, ServerMessage message) addTransport(ServerTransport transport) createChannelIfAbsent(String channelName, ConfigurableServerChannel.Initializer... initializers) Creates aServerChanneland initializes it atomically if the channel does not exist, or returns it if it already exists.protected ServerMessage.MutablecreateReply(ServerMessage.Mutable message) protected voiddoStart()protected voiddoStop()voiddump(Appendable out, String indent) protected voiderror(ServerMessage.Mutable reply, String error) voidprotected voidextendOutgoing(ServerSession sender, ServerSession session, ServerMessage.Mutable message, Promise<Boolean> promise) voidextendReply(ServerSessionImpl sender, ServerSessionImpl session, ServerMessage.Mutable reply, Promise<ServerMessage.Mutable> promise) protected AbstractHttpTransportfindHttpTransport(javax.servlet.http.HttpServletRequest request) voidfreeze(ServerMessage.Mutable mutable) getChannel(String channelId) protected List<BayeuxServer.BayeuxServerListener> getName()protected booleanprotected longorg.eclipse.jetty.util.thread.SchedulergetSession(String clientId) longintgetTransport(String transport) voidhandle(ServerSessionImpl session, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise) protected voidprotected voidprotected voidbooleanbooleannewChannelId(String id) newLocalSession(String idHint) Creates a newLocalSession.newMessage(ServerMessage original) protected voidpublish(ServerSessionImpl session, ServerChannelImpl channel, ServerMessage.Mutable message, boolean receiving, Promise<Boolean> promise) longvoidremoveExtension(BayeuxServer.Extension extension) Removes the given extension from this Bayeux object.voidRemoves a listener from this Bayeux object.protected booleanremoveServerChannel(ServerChannelImpl channel) booleanremoveServerSession(ServerSession session, boolean timeout) booleanremoveSession(ServerSession session) Removes the givensessionfrom this BayeuxServer.resolveLoop(AsyncFoldLeft.Loop<Boolean> loop) org.eclipse.jetty.util.thread.Scheduler.TaskEntry point to schedule tasks in CometD.voidsetAllowedTransports(String... allowed) voidsetAllowedTransports(List<String> allowed) voidsetDetailedDump(boolean detailedDump) voidsetExecutor(Executor executor) voidvoidsetOptions(Map<String, Object> options) voidsetScheduler(org.eclipse.jetty.util.thread.Scheduler scheduler) voidsetSecurityPolicy(SecurityPolicy securityPolicy) voidsetSweepPeriod(long sweepPeriod) voidsetSweepThreads(int sweepThreads) voidsetTransports(List<ServerTransport> transports) voidsetTransports(ServerTransport... transports) voidsweep()protected voidprotected StringvalidateMessage(ServerMessage.Mutable message) Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dump, dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
ALLOWED_TRANSPORTS_OPTION
- See Also:
-
SWEEP_PERIOD_OPTION
- See Also:
-
SWEEP_THREADS_OPTION
- See Also:
-
TRANSPORTS_OPTION
- See Also:
-
VALIDATE_MESSAGE_FIELDS_OPTION
- See Also:
-
BROADCAST_TO_PUBLISHER_OPTION
- See Also:
-
SCHEDULER_THREADS
- See Also:
-
EXECUTOR_MAX_THREADS
- See Also:
-
-
Constructor Details
-
BayeuxServerImpl
public BayeuxServerImpl()
-
-
Method Details
-
getName
-
doStart
-
doStop
-
initializeMetaChannels
protected void initializeMetaChannels() -
initializeJSONContext
-
initializeServerTransports
protected void initializeServerTransports() -
setExecutor
-
getExecutor
-
execute
-
setScheduler
public void setScheduler(org.eclipse.jetty.util.thread.Scheduler scheduler) -
getScheduler
public org.eclipse.jetty.util.thread.Scheduler getScheduler() -
schedule
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
-
getOptions
-
getOption
-
getOption
-
getOption
-
getOptionNames
- Specified by:
getOptionNamesin interfaceBayeux- Returns:
- the set of configuration options
- See Also:
-
setOption
-
setOptions
-
randomLong
public long randomLong() -
getSecurityPolicy
- Specified by:
getSecurityPolicyin interfaceBayeuxServer- Returns:
- the
SecurityPolicyassociated with this session - See Also:
-
getJSONContext
-
createChannelIfAbsent
public MarkedReference<ServerChannel> createChannelIfAbsent(String channelName, ConfigurableServerChannel.Initializer... initializers) Description copied from interface:BayeuxServerCreates a
ServerChanneland initializes it atomically if the channel does not exist, or returns it if it already exists.This method can be used instead of adding a
BayeuxServer.ChannelListenerto atomically initialize a channel. Theinitializerswill be called before any other thread can access the new channel instance.This method should be used when a channel needs to be initialized (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.
- Specified by:
createChannelIfAbsentin interfaceBayeuxServer- Parameters:
channelName- the channel nameinitializers- the initializers invoked to configure the channel- Returns:
- a
MarkedReferencewhose reference is the channel, and the mark signals whether the channel has been created because it did not exist before.
-
getSessions
- Specified by:
getSessionsin interfaceBayeuxServer- Returns:
- the list of
ServerSessions known to this BayeuxServer object
-
getSession
- Specified by:
getSessionin interfaceBayeuxServer- Parameters:
clientId- theServerSessionidentifier- Returns:
- the
ServerSessionwith the givenclientIdor null if no such valid session exists.
-
addServerSession
-
removeSession
Description copied from interface:BayeuxServerRemoves the given
sessionfrom this BayeuxServer.This method triggers the invocation of all listeners that would be called if the session was disconnected or if the session timed out.
- Specified by:
removeSessionin interfaceBayeuxServer- Parameters:
session- the session to remove- Returns:
- true if the session was known to this BayeuxServer and was removed
-
removeServerSession
- Parameters:
session- the session to removetimeout- whether the session has been removed due to a timeout- Returns:
- true if the session was removed and was connected
-
newServerSession
-
newLocalSession
Description copied from interface:BayeuxServerCreates a new
LocalSession.A
LocalSessionis 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.- Specified by:
newLocalSessionin interfaceBayeuxServer- Parameters:
idHint- a hint to be included in the unique clientId of the session.- Returns:
- a new
LocalSession
-
newMessage
- Specified by:
newMessagein interfaceBayeuxServer- Returns:
- a new or recycled mutable message instance.
-
newMessage
-
setSecurityPolicy
- Specified by:
setSecurityPolicyin interfaceBayeuxServer- Parameters:
securityPolicy- theSecurityPolicyassociated with this session- See Also:
-
addExtension
Description copied from interface:BayeuxServerAdds the given extension to this Bayeux object.
- Specified by:
addExtensionin interfaceBayeuxServer- Parameters:
extension- the extension to add- See Also:
-
removeExtension
Description copied from interface:BayeuxServerRemoves the given extension from this Bayeux object.
- Specified by:
removeExtensionin interfaceBayeuxServer- Parameters:
extension- the extension to remove- See Also:
-
getExtensions
- Specified by:
getExtensionsin interfaceBayeuxServer- Returns:
- an immutable list of extensions present in this BayeuxServer instance
- See Also:
-
addListener
Description copied from interface:BayeuxServerAdds a listener to this Bayeux object.
- Specified by:
addListenerin interfaceBayeuxServer- Parameters:
listener- the listener to add- See Also:
-
getChannel
- Specified by:
getChannelin interfaceBayeuxServer- Parameters:
channelId- the channel identifier- Returns:
- a
ServerChannelwith the givenchannelId, or null if no such channel exists - See Also:
-
getChannels
- Specified by:
getChannelsin interfaceBayeuxServer- Returns:
- the list of channels known to this BayeuxServer object
-
removeListener
Description copied from interface:BayeuxServerRemoves a listener from this Bayeux object.
- Specified by:
removeListenerin interfaceBayeuxServer- Parameters:
listener- the listener to remove- See Also:
-
handle
public void handle(ServerSessionImpl session, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise) -
validateMessage
-
publish
protected void publish(ServerSessionImpl session, ServerChannelImpl channel, ServerMessage.Mutable message, boolean receiving, Promise<Boolean> promise) -
resolveLoop
-
freeze
-
extendOutgoing
protected void extendOutgoing(ServerSession sender, ServerSession session, ServerMessage.Mutable message, Promise<Boolean> promise) -
extendReply
public void extendReply(ServerSessionImpl sender, ServerSessionImpl session, ServerMessage.Mutable reply, Promise<ServerMessage.Mutable> promise) -
removeServerChannel
-
getListeners
-
getKnownTransportNames
- Specified by:
getKnownTransportNamesin interfaceBayeux- Returns:
- the set of known transport names of this Bayeux object.
- See Also:
-
getTransport
- Specified by:
getTransportin interfaceBayeux- Parameters:
transport- the transport name- Returns:
- the transport with the given name or null if no such transport exist
-
addTransport
-
setTransports
-
setTransports
-
getTransports
-
findHttpTransport
-
getAllowedTransports
@ManagedAttribute(value="The transports allowed by this CoemtD server", readonly=true) public List<String> getAllowedTransports()- Specified by:
getAllowedTransportsin interfaceBayeux- Returns:
- the ordered list of transport names that will be used in the negotiation of transports with the other peer.
- See Also:
-
setAllowedTransports
-
setAllowedTransports
-
isBroadcastToPublisher
@ManagedAttribute(value="Whether this CometD server broadcast messages to the publisher", readonly=true) public boolean isBroadcastToPublisher() -
unknownSession
-
error
-
createReply
-
sweep
@ManagedOperation(value="Sweeps channels and sessions of this CometD server", impact="ACTION") public void sweep() -
isDetailedDump
@ManagedAttribute("Reports additional details in the dump() operation") public boolean isDetailedDump() -
setDetailedDump
public void setDetailedDump(boolean detailedDump) -
getSweepPeriod
@ManagedAttribute("The period, in milliseconds, of the sweeping activity performed by the server") public long getSweepPeriod() -
setSweepPeriod
public void setSweepPeriod(long sweepPeriod) -
getSweepThreads
@ManagedAttribute("The maximum number of threads that can be used by the sweeping activity performed by the server") public int getSweepThreads() -
setSweepThreads
public void setSweepThreads(int sweepThreads) -
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Overrides:
dumpin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
IOException
-
getLastSweepInfo
-
getLongestSweepInfo
-