Class NativeWebSocketConfiguration

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration
All Implemented Interfaces:
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, MappedWebSocketCreator

public class NativeWebSocketConfiguration extends org.eclipse.jetty.util.component.ContainerLifeCycle implements MappedWebSocketCreator
Interface for Configuring Jetty Server Native WebSockets

Only applicable if using WebSocketUpgradeFilter

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
     

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private final org.eclipse.jetty.http.pathmap.PathMappings<WebSocketCreator>
     

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeWebSocketConfiguration(javax.servlet.ServletContext context)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addMapping(String rawspec, Class<?> endpointClass)
    Manually add a WebSocket mapping.
    void
    addMapping(String rawspec, WebSocketCreator creator)
    Add a mapping, of a pathspec to a WebSocketCreator.
    void
    addMapping(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, Class<?> endpointClass)
    Manually add a WebSocket mapping.
    void
    addMapping(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, WebSocketCreator creator)
    Manually add a WebSocket mapping.
    void
    Deprecated.
    void
     
    Get WebSocketServerFactory being used.
    getMapping(String rawspec)
    /** Returns the creator for the given path spec.
    org.eclipse.jetty.http.pathmap.MappedResource<WebSocketCreator>
    getMatch(String target)
    Deprecated.
    use getMatched(String) instead.
    org.eclipse.jetty.http.pathmap.MatchedResource<WebSocketCreator>
    Get the matching MatchedResource for the provided target.
    Used to configure the Default WebSocketPolicy used by all endpoints that don't redeclare the values.
    boolean
    Removes the mapping based on the given path spec.
    private org.eclipse.jetty.http.pathmap.PathSpec
    toPathSpec(String rawspec)
     

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, dump, 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

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable
  • Field Details

  • Constructor Details

    • NativeWebSocketConfiguration

      public NativeWebSocketConfiguration(javax.servlet.ServletContext context)
    • NativeWebSocketConfiguration

      public NativeWebSocketConfiguration(WebSocketServerFactory webSocketServerFactory)
  • Method Details

    • doStop

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

      public WebSocketServerFactory getFactory()
      Get WebSocketServerFactory being used.
      Returns:
      the WebSocketServerFactory being used.
    • getMatched

      public org.eclipse.jetty.http.pathmap.MatchedResource<WebSocketCreator> getMatched(String target)
      Get the matching MatchedResource for the provided target.
      Parameters:
      target - the target path
      Returns:
      the matching resource, or null if no match.
    • getMatch

      @Deprecated public org.eclipse.jetty.http.pathmap.MappedResource<WebSocketCreator> getMatch(String target)
      Deprecated.
      use getMatched(String) instead.
      Get the matching MappedResource for the provided target.
      Parameters:
      target - the target path
      Returns:
      the matching resource, or null if no match.
    • getPolicy

      public WebSocketPolicy getPolicy()
      Used to configure the Default WebSocketPolicy used by all endpoints that don't redeclare the values.
      Returns:
      the default policy for all WebSockets
    • addMapping

      public void addMapping(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, WebSocketCreator creator)
      Manually add a WebSocket mapping.

      If mapping is added before this configuration is started, then it is persisted through stop/start of this configuration's lifecycle. Otherwise it will be removed when this configuration is stopped.

      Specified by:
      addMapping in interface MappedWebSocketCreator
      Parameters:
      pathSpec - the pathspec to respond on
      creator - the websocket creator to activate on the provided mapping.
    • addMapping

      @Deprecated public void addMapping(PathSpec spec, WebSocketCreator creator)
      Deprecated.
      Manually add a WebSocket mapping.
      Specified by:
      addMapping in interface MappedWebSocketCreator
      Parameters:
      spec - the pathspec to respond on
      creator - the websocket creator to activate on the provided mapping
    • addMapping

      public void addMapping(org.eclipse.jetty.http.pathmap.PathSpec pathSpec, Class<?> endpointClass)
      Manually add a WebSocket mapping.
      Parameters:
      pathSpec - the pathspec to respond on
      endpointClass - the endpoint class to use for new upgrade requests on the provided pathspec (can be an WebSocket annotated POJO, or implementing WebSocketListener)
    • addMapping

      public void addMapping(String rawspec, WebSocketCreator creator)
      Description copied from interface: MappedWebSocketCreator
      Add a mapping, of a pathspec to a WebSocketCreator.

      Recognized Path Spec syntaxes

      /path/to or / or *.ext or servlet|{spec}
      Servlet Syntax
      ^{spec} or regex|{spec}
      Regex Syntax
      uri-template|{spec}
      URI Template (see JSR356 and RFC6570 level 1)
      Specified by:
      addMapping in interface MappedWebSocketCreator
      Parameters:
      rawspec - the path spec to use.
      creator - the websocket creator for this specific mapping
    • toPathSpec

      private org.eclipse.jetty.http.pathmap.PathSpec toPathSpec(String rawspec)
    • getMapping

      public WebSocketCreator getMapping(String rawspec)
      Description copied from interface: MappedWebSocketCreator
      /** Returns the creator for the given path spec.
      Specified by:
      getMapping in interface MappedWebSocketCreator
      Parameters:
      rawspec - the spec to test for (using the same spec syntax as seen in MappedWebSocketCreator.addMapping(String, WebSocketCreator))
      Returns:
      the websocket creator if path spec exists, or null
    • removeMapping

      public boolean removeMapping(String rawspec)
      Description copied from interface: MappedWebSocketCreator
      Removes the mapping based on the given path spec.
      Specified by:
      removeMapping in interface MappedWebSocketCreator
      Parameters:
      rawspec - the path spec to remove (using the same spec syntax as seen in MappedWebSocketCreator.addMapping(String, WebSocketCreator))
      Returns:
      true if underlying mapping were altered, false otherwise
    • addMapping

      public void addMapping(String rawspec, Class<?> endpointClass)
      Manually add a WebSocket mapping.
      Parameters:
      rawspec - the pathspec to map to (see MappedWebSocketCreator.addMapping(String, WebSocketCreator) for syntax details)
      endpointClass - the endpoint class to use for new upgrade requests on the provided pathspec (can be an WebSocket annotated POJO, or implementing WebSocketListener)