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, org.cometd.bayeux.server.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 org.cometd.bayeux.server.BayeuxServer, org.eclipse.jetty.util.component.Dumpable
  • Field Details

  • Constructor Details

    • BayeuxServerImpl

      public BayeuxServerImpl()
  • Method Details

    • getName

      public String getName()
    • doStart

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

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

      protected void initializeMetaChannels()
    • initializeJSONContext

      protected void initializeJSONContext() throws Exception
      Throws:
      Exception
    • initializeServerTransports

      protected void initializeServerTransports()
    • setExecutor

      public void setExecutor(Executor executor)
    • getExecutor

      public Executor getExecutor()
    • execute

      public void execute(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(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(String id)
    • getOptions

      public Map<String,Object> getOptions()
    • getOption

      @ManagedOperation(value="The value of the given configuration option", impact="INFO") public Object getOption(@Name("optionName") String qualifiedName)
      Specified by:
      getOption in interface org.cometd.bayeux.Bayeux
    • getOption

      protected long getOption(String name, long dft)
    • getOption

      protected boolean getOption(String name, boolean dft)
    • getOptionNames

      public Set<String> getOptionNames()
      Specified by:
      getOptionNames in interface org.cometd.bayeux.Bayeux
    • setOption

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

      public void setOptions(Map<String,Object> options)
    • randomLong

      public long randomLong()
    • getSecurityPolicy

      public org.cometd.bayeux.server.SecurityPolicy getSecurityPolicy()
      Specified by:
      getSecurityPolicy in interface org.cometd.bayeux.server.BayeuxServer
    • getJSONContext

      public JSONContextServer getJSONContext()
    • createChannelIfAbsent

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

      public List<org.cometd.bayeux.server.ServerSession> getSessions()
      Specified by:
      getSessions in interface org.cometd.bayeux.server.BayeuxServer
    • getSession

      public org.cometd.bayeux.server.ServerSession getSession(String clientId)
      Specified by:
      getSession in interface org.cometd.bayeux.server.BayeuxServer
    • addServerSession

      public void addServerSession(ServerSessionImpl session, org.cometd.bayeux.server.ServerMessage message)
    • removeSession

      public boolean removeSession(org.cometd.bayeux.server.ServerSession session)
      Specified by:
      removeSession in interface org.cometd.bayeux.server.BayeuxServer
    • removeServerSession

      public boolean removeServerSession(org.cometd.bayeux.server.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 org.cometd.bayeux.server.LocalSession newLocalSession(String idHint)
      Specified by:
      newLocalSession in interface org.cometd.bayeux.server.BayeuxServer
    • newMessage

      public org.cometd.bayeux.server.ServerMessage.Mutable newMessage()
      Specified by:
      newMessage in interface org.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 interface org.cometd.bayeux.server.BayeuxServer
    • addExtension

      public void addExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
      Specified by:
      addExtension in interface org.cometd.bayeux.server.BayeuxServer
    • removeExtension

      public void removeExtension(org.cometd.bayeux.server.BayeuxServer.Extension extension)
      Specified by:
      removeExtension in interface org.cometd.bayeux.server.BayeuxServer
    • getExtensions

      public List<org.cometd.bayeux.server.BayeuxServer.Extension> getExtensions()
      Specified by:
      getExtensions in interface org.cometd.bayeux.server.BayeuxServer
    • addListener

      public void addListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
      Specified by:
      addListener in interface org.cometd.bayeux.server.BayeuxServer
    • getChannel

      public org.cometd.bayeux.server.ServerChannel getChannel(String channelId)
      Specified by:
      getChannel in interface org.cometd.bayeux.server.BayeuxServer
    • getChannels

      public List<org.cometd.bayeux.server.ServerChannel> getChannels()
      Specified by:
      getChannels in interface org.cometd.bayeux.server.BayeuxServer
    • removeListener

      public void removeListener(org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener listener)
      Specified by:
      removeListener in interface org.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 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<Boolean> promise)
    • resolveLoop

      protected org.cometd.bayeux.Promise<Boolean> resolveLoop(org.cometd.common.AsyncFoldLeft.Loop<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<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 List<org.cometd.bayeux.server.BayeuxServer.BayeuxServerListener> getListeners()
    • getKnownTransportNames

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

      public org.cometd.bayeux.server.ServerTransport getTransport(String transport)
      Specified by:
      getTransport in interface org.cometd.bayeux.Bayeux
      Specified by:
      getTransport in interface org.cometd.bayeux.server.BayeuxServer
    • 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(List<org.cometd.bayeux.server.ServerTransport> transports)
    • getTransports

      public List<org.cometd.bayeux.server.ServerTransport> getTransports()
    • getAllowedTransports

      @ManagedAttribute(value="The transports allowed by this CometD server", readonly=true) public List<String> getAllowedTransports()
      Specified by:
      getAllowedTransports in interface org.cometd.bayeux.Bayeux
    • setAllowedTransports

      public void setAllowedTransports(String... allowed)
    • setAllowedTransports

      public void setAllowedTransports(List<String> allowed)
    • isBroadcastToPublisher

      @ManagedAttribute(value="Whether this CometD 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, 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 CometD server", impact="ACTION") public void sweep()
    • asyncSweep

      public CompletableFuture<Void> asyncSweep()
    • 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

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

      public Map<String,Object> getLastSweepInfo()
    • getLongestSweepInfo

      public Map<String,Object> getLongestSweepInfo()