Class BayeuxServerImpl
- All Implemented Interfaces:
Bayeux,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 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.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.cometd.bayeux.server.BayeuxServer
BayeuxServer.BayeuxServerListener, BayeuxServer.ChannelListener, BayeuxServer.Extension, BayeuxServer.SessionListener, BayeuxServer.SubscriptionListener -
Field Summary
Fields Modifier and Type Field Description static StringALLOWED_TRANSPORTS_OPTIONstatic StringBROADCAST_TO_PUBLISHER_OPTIONstatic StringSWEEP_PERIOD_OPTIONstatic StringTRANSPORTS_OPTIONstatic StringVALIDATE_MESSAGE_FIELDS_OPTION -
Constructor Summary
Constructors Constructor Description BayeuxServerImpl() -
Method Summary
-
Field Details
-
ALLOWED_TRANSPORTS_OPTION
- See Also:
- Constant Field Values
-
SWEEP_PERIOD_OPTION
- See Also:
- Constant Field Values
-
TRANSPORTS_OPTION
- See Also:
- Constant Field Values
-
VALIDATE_MESSAGE_FIELDS_OPTION
- See Also:
- Constant Field Values
-
BROADCAST_TO_PUBLISHER_OPTION
- See Also:
- Constant Field Values
-
-
Constructor Details
-
BayeuxServerImpl
public BayeuxServerImpl()
-
-
Method Details
-
doStart
- Overrides:
doStartin classorg.eclipse.jetty.util.component.AbstractLifeCycle- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.eclipse.jetty.util.component.AbstractLifeCycle- Throws:
Exception
-
initializeMetaChannels
protected void initializeMetaChannels() -
initializeJSONContext
- Throws:
Exception
-
initializeServerTransports
protected void initializeServerTransports() -
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
@ManagedOperation(value="The value of the given configuration option", impact="INFO") public Object getOption(@Name("optionName") String qualifiedName)- Specified by:
getOptionin interfaceBayeux- Parameters:
qualifiedName- the configuration option name- Returns:
- the configuration option with the given
qualifiedName - See Also:
Bayeux.setOption(String, Object),Bayeux.getOptionNames()
-
getOption
-
getOption
-
getOptionNames
- Specified by:
getOptionNamesin interfaceBayeux- Returns:
- the set of configuration options
- See Also:
Bayeux.getOption(String)
-
setOption
- Specified by:
setOptionin interfaceBayeux- Parameters:
qualifiedName- the configuration option namevalue- the configuration option value- See Also:
Bayeux.getOption(String)
-
setOptions
-
randomLong
public long randomLong() -
setCurrentTransport
-
getCurrentTransport
- Specified by:
getCurrentTransportin interfaceBayeuxServer- Returns:
- the current transport instance of the current thread
-
getContext
- Specified by:
getContextin interfaceBayeuxServer- Returns:
- the current Context, is equivalent to ((ServerTransport)
BayeuxServer.getCurrentTransport()).ServerTransport.getContext()
-
getSecurityPolicy
- Specified by:
getSecurityPolicyin interfaceBayeuxServer- Returns:
- the
SecurityPolicyassociated with this session - See Also:
BayeuxServer.setSecurityPolicy(SecurityPolicy)
-
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
-
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
-
getSession
- Specified by:
getSessionin interfaceBayeuxServer- Parameters:
clientId- theServerSessionidentifier- Returns:
- the
ServerSessionwith the givenclientIdor null if no such valid session exists.
-
addServerSession
-
removeServerSession
- 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
-
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:
BayeuxServer.getSecurityPolicy()
-
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:
BayeuxServer.removeExtension(Extension)
-
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:
BayeuxServer.addExtension(Extension)
-
getExtensions
- Specified by:
getExtensionsin interfaceBayeuxServer- Returns:
- an immutable list of extensions present in this BayeuxServer instance
- See Also:
BayeuxServer.addExtension(Extension)
-
addListener
Description copied from interface:BayeuxServerAdds a listener to this Bayeux object.
- Specified by:
addListenerin interfaceBayeuxServer- Parameters:
listener- the listener to add- See Also:
BayeuxServer.removeListener(BayeuxServerListener)
-
getChannel
- Specified by:
getChannelin interfaceBayeuxServer- Parameters:
channelId- the channel identifier- Returns:
- a
ServerChannelwith the givenchannelId, or null if no such channel exists - See Also:
BayeuxServer.createChannelIfAbsent(String, ConfigurableServerChannel.Initializer...)
-
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:
BayeuxServer.addListener(BayeuxServerListener)
-
handle
-
validateMessage
-
doPublish
protected void doPublish(ServerSessionImpl from, ServerChannelImpl to, ServerMessage.Mutable mutable, boolean receiving) -
freeze
-
extendReply
public ServerMessage.Mutable extendReply(ServerSessionImpl from, ServerSessionImpl to, ServerMessage.Mutable reply) -
extendRecv
-
extendSend
-
removeServerChannel
-
getListeners
-
getKnownTransportNames
- Specified by:
getKnownTransportNamesin interfaceBayeux- Returns:
- the set of known transport names of this
Bayeuxobject. - See Also:
Bayeux.getAllowedTransports()
-
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 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:
Bayeux.getKnownTransportNames()
-
setAllowedTransports
-
setAllowedTransports
-
isBroadcastToPublisher
@ManagedAttribute(value="Whether this server broadcast messages to the publisher", readonly=true) public boolean isBroadcastToPublisher() -
unknownSession
-
error
-
createReply
-
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
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-