Class WebSocketMappings
- All Implemented Interfaces:
EventListener
,Dumpable
,LifeCycle.Listener
WebSocketCreator
, FrameHandlerFactory
and
Configuration.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 a FrameHandler
and the customizer is used to configure the resulting
CoreSession
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapping
(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) Manually add a WebSocket mapping.void
addMapping
(PathSpec pathSpec, WebSocketNegotiator negotiator) Manually add a WebSocket mapping.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.static WebSocketMappings
ensureMappings
(jakarta.servlet.ServletContext servletContext) static WebSocketMappings
getMappings
(jakarta.servlet.ServletContext servletContext) getMatchedNegotiator
(String target, Consumer<PathSpec> pathSpecConsumer) Get the matchingMappedResource
for the provided target.getWebSocketCreator
(PathSpec pathSpec) getWebSocketNegotiator
(PathSpec pathSpec) void
lifeCycleStopping
(LifeCycle context) static PathSpec
parsePathSpec
(String rawSpec) Parse a PathSpec string into a PathSpec instance.boolean
removeMapping
(PathSpec pathSpec) boolean
upgrade
(jakarta.servlet.http.HttpServletRequest request, jakarta.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 Details
-
WEBSOCKET_MAPPING_ATTRIBUTE
-
-
Constructor Details
-
WebSocketMappings
public WebSocketMappings() -
WebSocketMappings
-
-
Method Details
-
getMappings
-
ensureMappings
-
parsePathSpec
Parse a PathSpec string into a PathSpec instance.Recognized Path Spec syntaxes:
/path/to
or/
or*.ext
orservlet|{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
PathSpec
implementation for the rawSpec
-
getHandshaker
-
lifeCycleStopping
- Specified by:
lifeCycleStopping
in interfaceLifeCycle.Listener
-
dump
Description copied from interface:Dumpable
Dump 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.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
getWebSocketNegotiator
-
getWebSocketCreator
-
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 websocket.customizer
- the customizer to use to customize the WebSocket session.- Throws:
WebSocketException
-
addMapping
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 onnegotiator
- the WebSocketNegotiator to use to create a FrameHandler for the websocket.- Throws:
WebSocketException
-
removeMapping
-
getMatchedNegotiator
Get the matchingMappedResource
for the provided target.- Parameters:
target
- the target pathpathSpecConsumer
- the path- Returns:
- the matching resource, or null if no match.
-
upgrade
public boolean upgrade(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException - Throws:
IOException
-