Class WebSocketMapping
- java.lang.Object
-
- org.eclipse.jetty.websocket.servlet.WebSocketMapping
-
- All Implemented Interfaces:
java.util.EventListener,Dumpable,LifeCycle.Listener
public class WebSocketMapping extends java.lang.Object implements Dumpable, LifeCycle.Listener
Mapping of pathSpec to a tupple ofWebSocketCreator,FrameHandlerFactoryandConfiguration.Customizer.When the
upgrade(HttpServletRequest, HttpServletResponse, Configuration.Customizer)method is called, a match for the pathSpec is looked for. If one is found then the creator is used to create a POJO for the WebSocket endpoint, the factory is used to wrap that POJO with aFrameHandlerand the customizer is used to configure the resultingCoreSession.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_KEY
-
Constructor Summary
Constructors Constructor Description WebSocketMapping()WebSocketMapping(WebSocketComponents components)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer)Manually add a WebSocket mapping.java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)Dump this object (and children) into an Appendable using the provided indent after any new lines.static WebSocketMappingensureMapping(javax.servlet.ServletContext servletContext, java.lang.String mappingKey)static WebSocketMappinggetMapping(javax.servlet.ServletContext servletContext, java.lang.String mappingKey)WebSocketCreatorgetMapping(PathSpec pathSpec)WebSocketNegotiatorgetMatchedNegotiator(java.lang.String target, java.util.function.Consumer<PathSpec> pathSpecConsumer)Get the matchingMappedResourcefor the provided target.voidlifeCycleStopping(LifeCycle context)static PathSpecparsePathSpec(java.lang.String rawSpec)Parse a PathSpec string into a PathSpec instance.booleanremoveMapping(PathSpec pathSpec)booleanupgrade(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Configuration.Customizer defaultCustomizer)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle.Listener
lifeCycleFailure, lifeCycleStarted, lifeCycleStarting, lifeCycleStopped
-
-
-
-
Field Detail
-
DEFAULT_KEY
public static final java.lang.String DEFAULT_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebSocketMapping
public WebSocketMapping()
-
WebSocketMapping
public WebSocketMapping(WebSocketComponents components)
-
-
Method Detail
-
getMapping
public static WebSocketMapping getMapping(javax.servlet.ServletContext servletContext, java.lang.String mappingKey)
-
getMapping
public WebSocketCreator getMapping(PathSpec pathSpec)
-
ensureMapping
public static WebSocketMapping ensureMapping(javax.servlet.ServletContext servletContext, java.lang.String mappingKey)
-
parsePathSpec
public static PathSpec parsePathSpec(java.lang.String rawSpec)
Parse a PathSpec string into a PathSpec instance.Recognized Path Spec syntaxes:
/path/toor/or*.extorservlet|{spec}- Servlet Syntax
^{spec}orregex|{spec}- Regex Syntax
uri-template|{spec}- URI Template (see JSR356 and RFC6570 level 1)
- Parameters:
rawSpec- the raw path spec as String to parse.- Returns:
- the
PathSpecimplementation for the rawSpec
-
lifeCycleStopping
public void lifeCycleStopping(LifeCycle context)
- Specified by:
lifeCycleStoppingin interfaceLifeCycle.Listener
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOExceptionDescription copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
-
addMapping
public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) throws WebSocketException
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.
- Parameters:
pathSpec- the pathspec to respond oncreator- the websocket creator to activate on the provided mapping.factory- the factory to use to create a FrameHandler for the websocketcustomizer- the customizer to use to customize the WebSocket session.- Throws:
WebSocketException
-
removeMapping
public boolean removeMapping(PathSpec pathSpec)
-
getMatchedNegotiator
public WebSocketNegotiator getMatchedNegotiator(java.lang.String target, java.util.function.Consumer<PathSpec> pathSpecConsumer)
Get the matchingMappedResourcefor the provided target.- Parameters:
target- the target pathpathSpecConsumer- the path- Returns:
- the matching resource, or null if no match.
-
upgrade
public boolean upgrade(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws java.io.IOException- Throws:
java.io.IOException
-
-