Class BayeuxServerImpl

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.cometd.server.BayeuxServerImpl
All Implemented Interfaces:
org.cometd.bayeux.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

@ManagedObject("The CometD server")
public class BayeuxServerImpl
extends org.eclipse.jetty.util.component.ContainerLifeCycle
implements BayeuxServer, org.eclipse.jetty.util.component.Dumpable
  • Field Details

    • 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
    • SCHEDULER_THREADS

      public static final java.lang.String SCHEDULER_THREADS
      See Also:
      Constant Field Values
    • EXECUTOR_MAX_THREADS

      public static final java.lang.String EXECUTOR_MAX_THREADS
      See Also:
      Constant Field Values
  • Constructor Details

    • BayeuxServerImpl

      public BayeuxServerImpl()
  • Method Details

    • getName

      public java.lang.String getName()
    • doStart

      protected void doStart() throws java.lang.Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      java.lang.Exception
    • doStop

      protected void doStop() throws java.lang.Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      java.lang.Exception
    • initializeMetaChannels

      protected void initializeMetaChannels()
    • initializeJSONContext

      protected void initializeJSONContext() throws java.lang.Exception
      Throws:
      java.lang.Exception
    • initializeServerTransports

      protected void initializeServerTransports()
    • setExecutor

      public void setExecutor​(java.util.concurrent.Executor executor)
    • getExecutor

      public java.util.concurrent.Executor getExecutor()
    • execute

      public void execute​(java.lang.Runnable job)
    • setScheduler

      public void setScheduler​(org.eclipse.jetty.util.thread.Scheduler scheduler)
    • getScheduler

      public org.eclipse.jetty.util.thread.Scheduler getScheduler()
    • 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 schedule
      delay - 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 interface org.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 interface org.cometd.bayeux.Bayeux
    • setOption

      public void setOption​(java.lang.String qualifiedName, java.lang.Object value)
      Specified by:
      setOption in interface org.cometd.bayeux.Bayeux
    • setOptions

      public void setOptions​(java.util.Map<java.lang.String,​java.lang.Object> options)
    • randomLong

      public long randomLong()
    • getSecurityPolicy

      public SecurityPolicy getSecurityPolicy()
      Specified by:
      getSecurityPolicy in interface BayeuxServer
    • getJSONContext

      public JSONContextServer getJSONContext()
    • createChannelIfAbsent

      public org.cometd.bayeux.MarkedReference<ServerChannel> createChannelIfAbsent​(java.lang.String channelName, ConfigurableServerChannel.Initializer... initializers)
      Specified by:
      createChannelIfAbsent in interface BayeuxServer
    • getSessions

      public java.util.List<ServerSession> getSessions()
      Specified by:
      getSessions in interface BayeuxServer
    • getSession

      public ServerSession getSession​(java.lang.String clientId)
      Specified by:
      getSession in interface BayeuxServer
    • addServerSession

      protected void addServerSession​(ServerSessionImpl session, ServerMessage message)
    • removeSession

      public boolean removeSession​(ServerSession session)
      Specified by:
      removeSession in interface BayeuxServer
    • removeServerSession

      public boolean removeServerSession​(ServerSession session, boolean timeout)
      Parameters:
      session - the session to remove
      timeout - whether the session has been removed due to a timeout
      Returns:
      true if the session was removed and was connected
    • newServerSession

      public ServerSessionImpl newServerSession()
    • newLocalSession

      public LocalSession newLocalSession​(java.lang.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 original)
    • 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
    • getExtensions

      public java.util.List<BayeuxServer.Extension> getExtensions()
      Specified by:
      getExtensions in interface BayeuxServer
    • addListener

      public void addListener​(BayeuxServer.BayeuxServerListener listener)
      Specified by:
      addListener in interface BayeuxServer
    • getChannel

      public ServerChannel getChannel​(java.lang.String channelId)
      Specified by:
      getChannel in interface BayeuxServer
    • getChannels

      public java.util.List<ServerChannel> getChannels()
      Specified by:
      getChannels in interface BayeuxServer
    • removeListener

      public void removeListener​(BayeuxServer.BayeuxServerListener listener)
      Specified by:
      removeListener in interface BayeuxServer
    • handle

      public void handle​(ServerSessionImpl session, ServerMessage.Mutable message, org.cometd.bayeux.Promise<ServerMessage.Mutable> promise)
    • validateMessage

      protected java.lang.String validateMessage​(ServerMessage.Mutable message)
    • publish

      protected void publish​(ServerSessionImpl session, ServerChannelImpl channel, ServerMessage.Mutable message, boolean receiving, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • resolveLoop

      protected org.cometd.bayeux.Promise<java.lang.Boolean> resolveLoop​(AsyncFoldLeft.Loop<java.lang.Boolean> loop)
    • freeze

      public void freeze​(ServerMessage.Mutable mutable)
    • extendOutgoing

      protected void extendOutgoing​(ServerSession sender, ServerSession session, ServerMessage.Mutable message, org.cometd.bayeux.Promise<java.lang.Boolean> promise)
    • extendReply

      public void extendReply​(ServerSessionImpl sender, ServerSessionImpl session, ServerMessage.Mutable reply, org.cometd.bayeux.Promise<ServerMessage.Mutable> promise)
    • removeServerChannel

      protected boolean removeServerChannel​(ServerChannelImpl channel)
    • getListeners

      protected java.util.List<BayeuxServer.BayeuxServerListener> getListeners()
    • getKnownTransportNames

      public java.util.Set<java.lang.String> getKnownTransportNames()
      Specified by:
      getKnownTransportNames in interface org.cometd.bayeux.Bayeux
    • getTransport

      public ServerTransport getTransport​(java.lang.String transport)
      Specified by:
      getTransport in interface org.cometd.bayeux.Bayeux
    • addTransport

      public ServerTransport addTransport​(ServerTransport transport)
    • setTransports

      public void setTransports​(ServerTransport... transports)
    • setTransports

      public void setTransports​(java.util.List<ServerTransport> transports)
    • getTransports

      public java.util.List<ServerTransport> getTransports()
    • findHttpTransport

      protected AbstractHttpTransport findHttpTransport​(javax.servlet.http.HttpServletRequest request)
    • getAllowedTransports

      @ManagedAttribute(value="The transports allowed by this CoemtD server", readonly=true) public java.util.List<java.lang.String> getAllowedTransports()
      Specified by:
      getAllowedTransports in interface org.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 CometD server broadcast messages to the publisher", readonly=true) public boolean isBroadcastToPublisher()
    • unknownSession

      protected void unknownSession​(ServerMessage.Mutable reply)
    • error

      protected void error​(ServerMessage.Mutable reply, java.lang.String error)
    • createReply

      protected ServerMessage.Mutable createReply​(ServerMessage.Mutable message)
    • 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)
    • dump

      public void dump​(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Overrides:
      dump in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      java.io.IOException