@ManagedObject(value="The CometD server") public class BayeuxServerImpl extends org.eclipse.jetty.util.component.ContainerLifeCycle implements BayeuxServer, org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
BayeuxServer.BayeuxServerListener, BayeuxServer.ChannelListener, BayeuxServer.Extension, BayeuxServer.SessionListener, BayeuxServer.SubscriptionListener
Bayeux.BayeuxListener, Bayeux.Validator
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
Modifier and Type | Field and Description |
---|---|
static String |
ALLOWED_TRANSPORTS_OPTION |
static String |
BROADCAST_TO_PUBLISHER_OPTION |
static String |
EXECUTOR_MAX_THREADS |
static String |
SCHEDULER_THREADS |
static String |
SWEEP_PERIOD_OPTION |
static String |
SWEEP_THREADS_OPTION |
static String |
TRANSPORTS_OPTION |
static String |
VALIDATE_MESSAGE_FIELDS_OPTION |
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
ATTRIBUTE
Constructor and Description |
---|
BayeuxServerImpl() |
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, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dump, dump, dumpContainer, dumpIterable, dumpMapEntries, dumpObject, dumpObjects, dumpSelf, named
public static final String ALLOWED_TRANSPORTS_OPTION
public static final String SWEEP_PERIOD_OPTION
public static final String SWEEP_THREADS_OPTION
public static final String TRANSPORTS_OPTION
public static final String VALIDATE_MESSAGE_FIELDS_OPTION
public static final String BROADCAST_TO_PUBLISHER_OPTION
public static final String SCHEDULER_THREADS
public static final String EXECUTOR_MAX_THREADS
public String getName()
protected void doStart() throws Exception
doStart
in class org.eclipse.jetty.util.component.ContainerLifeCycle
Exception
protected void doStop() throws Exception
doStop
in class org.eclipse.jetty.util.component.ContainerLifeCycle
Exception
protected void initializeMetaChannels()
protected void initializeServerTransports()
public void setExecutor(Executor executor)
public Executor getExecutor()
public void execute(Runnable job)
public void setScheduler(org.eclipse.jetty.util.thread.Scheduler scheduler)
public org.eclipse.jetty.util.thread.Scheduler getScheduler()
public org.eclipse.jetty.util.thread.Scheduler.Task schedule(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.
task
- the task to scheduledelay
- the delay, in milliseconds, to run the task@ManagedOperation(value="The value of the given configuration option", impact="INFO") public Object getOption(@Name(value="optionName") String qualifiedName)
getOption
in interface Bayeux
qualifiedName
- the configuration option namequalifiedName
Bayeux.setOption(String, Object)
,
Bayeux.getOptionNames()
protected long getOption(String name, long dft)
protected boolean getOption(String name, boolean dft)
public Set<String> getOptionNames()
getOptionNames
in interface Bayeux
Bayeux.getOption(String)
public void setOption(String qualifiedName, Object value)
setOption
in interface Bayeux
qualifiedName
- the configuration option namevalue
- the configuration option valueBayeux.getOption(String)
public long randomLong()
public SecurityPolicy getSecurityPolicy()
getSecurityPolicy
in interface BayeuxServer
SecurityPolicy
associated with this sessionBayeuxServer.setSecurityPolicy(SecurityPolicy)
public JSONContextServer getJSONContext()
public MarkedReference<ServerChannel> createChannelIfAbsent(String channelName, ConfigurableServerChannel.Initializer... initializers)
BayeuxServer
Creates a ServerChannel
and 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.ChannelListener
to atomically initialize a channel. The initializers
will 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.
createChannelIfAbsent
in interface BayeuxServer
channelName
- the channel nameinitializers
- the initializers invoked to configure the channelMarkedReference
whose reference is the channel, and
the mark signals whether the channel has been created because it
did not exist before.public List<ServerSession> getSessions()
getSessions
in interface BayeuxServer
ServerSession
s known to this BayeuxServer objectpublic ServerSession getSession(String clientId)
getSession
in interface BayeuxServer
clientId
- the ServerSession
identifierServerSession
with the given clientId
or null if no such valid session exists.protected void addServerSession(ServerSessionImpl session, ServerMessage message)
public boolean removeSession(ServerSession session)
BayeuxServer
Removes the given session
from 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.
removeSession
in interface BayeuxServer
session
- the session to removepublic boolean removeServerSession(ServerSession session, boolean timeout)
session
- the session to removetimeout
- whether the session has been removed due to a timeoutpublic ServerSessionImpl newServerSession()
public LocalSession newLocalSession(String idHint)
BayeuxServer
Creates a new LocalSession
.
A LocalSession
is 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.
newLocalSession
in interface BayeuxServer
idHint
- a hint to be included in the unique clientId of the session.LocalSession
public ServerMessage.Mutable newMessage()
newMessage
in interface BayeuxServer
public ServerMessage.Mutable newMessage(ServerMessage original)
public void setSecurityPolicy(SecurityPolicy securityPolicy)
setSecurityPolicy
in interface BayeuxServer
securityPolicy
- the SecurityPolicy
associated with this sessionBayeuxServer.getSecurityPolicy()
public void addExtension(BayeuxServer.Extension extension)
BayeuxServer
Adds the given extension to this Bayeux object.
addExtension
in interface BayeuxServer
extension
- the extension to addBayeuxServer.removeExtension(Extension)
public void removeExtension(BayeuxServer.Extension extension)
BayeuxServer
Removes the given extension from this Bayeux object.
removeExtension
in interface BayeuxServer
extension
- the extension to removeBayeuxServer.addExtension(Extension)
public List<BayeuxServer.Extension> getExtensions()
getExtensions
in interface BayeuxServer
BayeuxServer.addExtension(Extension)
public void addListener(BayeuxServer.BayeuxServerListener listener)
BayeuxServer
Adds a listener to this Bayeux object.
addListener
in interface BayeuxServer
listener
- the listener to addBayeuxServer.removeListener(BayeuxServerListener)
public ServerChannel getChannel(String channelId)
getChannel
in interface BayeuxServer
channelId
- the channel identifierServerChannel
with the given channelId
,
or null if no such channel existsBayeuxServer.createChannelIfAbsent(String, ConfigurableServerChannel.Initializer...)
public List<ServerChannel> getChannels()
getChannels
in interface BayeuxServer
public void removeListener(BayeuxServer.BayeuxServerListener listener)
BayeuxServer
Removes a listener from this Bayeux object.
removeListener
in interface BayeuxServer
listener
- the listener to removeBayeuxServer.addListener(BayeuxServerListener)
public void handle(ServerSessionImpl session, ServerMessage.Mutable message, Promise<ServerMessage.Mutable> promise)
protected String validateMessage(ServerMessage.Mutable message)
protected void publish(ServerSessionImpl session, ServerChannelImpl channel, ServerMessage.Mutable message, boolean receiving, Promise<Boolean> promise)
protected Promise<Boolean> resolveLoop(AsyncFoldLeft.Loop<Boolean> loop)
public void freeze(ServerMessage.Mutable mutable)
protected void extendOutgoing(ServerSession sender, ServerSession session, ServerMessage.Mutable message, Promise<Boolean> promise)
public void extendReply(ServerSessionImpl sender, ServerSessionImpl session, ServerMessage.Mutable reply, Promise<ServerMessage.Mutable> promise)
protected boolean removeServerChannel(ServerChannelImpl channel)
protected List<BayeuxServer.BayeuxServerListener> getListeners()
public Set<String> getKnownTransportNames()
getKnownTransportNames
in interface Bayeux
Bayeux.getAllowedTransports()
public ServerTransport getTransport(String transport)
getTransport
in interface Bayeux
transport
- the transport namepublic ServerTransport addTransport(ServerTransport transport)
public void setTransports(ServerTransport... transports)
public void setTransports(List<ServerTransport> transports)
public List<ServerTransport> getTransports()
protected AbstractHttpTransport findHttpTransport(javax.servlet.http.HttpServletRequest request)
@ManagedAttribute(value="The transports allowed by this CoemtD server", readonly=true) public List<String> getAllowedTransports()
getAllowedTransports
in interface Bayeux
Bayeux.getKnownTransportNames()
public void setAllowedTransports(String... allowed)
@ManagedAttribute(value="Whether this CometD server broadcast messages to the publisher", readonly=true) public boolean isBroadcastToPublisher()
protected void unknownSession(ServerMessage.Mutable reply)
protected void error(ServerMessage.Mutable reply, String error)
protected ServerMessage.Mutable createReply(ServerMessage.Mutable message)
@ManagedOperation(value="Sweeps channels and sessions of this CometD server", impact="ACTION") public void sweep()
@ManagedAttribute(value="Reports additional details in the dump() operation") public boolean isDetailedDump()
public void setDetailedDump(boolean detailedDump)
@ManagedAttribute(value="The period, in milliseconds, of the sweeping activity performed by the server") public long getSweepPeriod()
public void setSweepPeriod(long sweepPeriod)
@ManagedAttribute(value="The maximum number of threads that can be used by the sweeping activity performed by the server") public int getSweepThreads()
public void setSweepThreads(int sweepThreads)
public void dump(Appendable out, String indent) throws IOException
dump
in interface org.eclipse.jetty.util.component.Dumpable
dump
in class org.eclipse.jetty.util.component.ContainerLifeCycle
IOException
Copyright © 2008–2024 The CometD Project. All rights reserved.