Class WebSocketUpgradeFilter
- java.lang.Object
-
- org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter
-
- All Implemented Interfaces:
Filter
,Dumpable
,MappedWebSocketCreator
@ManagedObject("WebSocket Upgrade Filter") @Deprecated(since="2021-05-27") public class WebSocketUpgradeFilter extends Object implements Filter, MappedWebSocketCreator, Dumpable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.Inline Servlet Filter to capture WebSocket upgrade requests and perform path mappings toWebSocketCreator
objects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
-
Field Summary
Fields Modifier and Type Field Description static String
ATTR_KEY
Deprecated.static String
CONFIG_ATTRIBUTE_KEY
Deprecated.static String
CONTEXT_ATTRIBUTE_KEY
Deprecated.
-
Constructor Summary
Constructors Constructor Description WebSocketUpgradeFilter()
Deprecated.WebSocketUpgradeFilter(NativeWebSocketConfiguration configuration)
Deprecated.WebSocketUpgradeFilter(WebSocketServerFactory factory)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMapping(String spec, WebSocketCreator creator)
Deprecated.Add a mapping, of a pathspec to a WebSocketCreator.void
addMapping(PathSpec spec, WebSocketCreator creator)
Deprecated.Add a mapping.void
addMapping(PathSpec spec, WebSocketCreator creator)
Deprecated.static WebSocketUpgradeFilter
configure(ServletContextHandler context)
Deprecated.Configure the default WebSocketUpgradeFilter.static WebSocketUpgradeFilter
configureContext(ServletContext context)
Deprecated.useconfigureContext(ServletContextHandler)
insteadstatic WebSocketUpgradeFilter
configureContext(ServletContextHandler context)
Deprecated.useconfigure(ServletContextHandler)
insteadvoid
destroy()
Deprecated.Called by the web container to indicate to a filter that it is being taken out of service.void
doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
Deprecated.ThedoFilter
method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.String
dump()
Deprecated.void
dump(Appendable out, String indent)
Deprecated.Dump this object (and children) into an Appendable using the provided indent after any new lines.NativeWebSocketConfiguration
getConfiguration()
Deprecated.WebSocketServletFactory
getFactory()
Deprecated.WebSocketCreator
getMapping(String target)
Deprecated./** Returns the creator for the given path spec.void
init(FilterConfig config)
Deprecated.Called by the web container to indicate to a filter that it is being placed into service.boolean
removeMapping(String spec)
Deprecated.Removes the mapping based on the given path spec.void
setToAttribute(ServletContext context, String key)
Deprecated.String
toString()
Deprecated.
-
-
-
Field Detail
-
CONTEXT_ATTRIBUTE_KEY
public static final String CONTEXT_ATTRIBUTE_KEY
Deprecated.- See Also:
- Constant Field Values
-
CONFIG_ATTRIBUTE_KEY
public static final String CONFIG_ATTRIBUTE_KEY
Deprecated.- See Also:
- Constant Field Values
-
ATTR_KEY
public static final String ATTR_KEY
Deprecated.
-
-
Constructor Detail
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter()
Deprecated.
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter(WebSocketServerFactory factory)
Deprecated.
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter(NativeWebSocketConfiguration configuration)
Deprecated.
-
-
Method Detail
-
configure
public static WebSocketUpgradeFilter configure(ServletContextHandler context) throws ServletException
Deprecated.Configure the default WebSocketUpgradeFilter.This will return the default
WebSocketUpgradeFilter
on the providedServletContextHandler
, creating the filter if necessary.The default
WebSocketUpgradeFilter
is also available via theServletContext
attribute namedorg.eclipse.jetty.websocket.server.WebSocketUpgradeFilter
- Parameters:
context
- theServletContextHandler
to use- Returns:
- the configured default
WebSocketUpgradeFilter
instance - Throws:
ServletException
- if the filer cannot be configured
-
configureContext
@Deprecated public static WebSocketUpgradeFilter configureContext(ServletContextHandler context) throws ServletException
Deprecated.useconfigure(ServletContextHandler)
instead- Parameters:
context
- theServletContextHandler
to use- Returns:
- a configured
WebSocketUpgradeFilter
instance - Throws:
ServletException
- if the filer cannot be configured
-
configureContext
@Deprecated public static WebSocketUpgradeFilter configureContext(ServletContext context) throws ServletException
Deprecated.useconfigureContext(ServletContextHandler)
instead- Parameters:
context
- the ServletContext to use- Returns:
- a configured
WebSocketUpgradeFilter
instance - Throws:
ServletException
- if the filer cannot be configured
-
addMapping
public void addMapping(PathSpec spec, WebSocketCreator creator)
Deprecated.Description copied from interface:MappedWebSocketCreator
Add a mapping.- Specified by:
addMapping
in interfaceMappedWebSocketCreator
- Parameters:
spec
- the path spec to usecreator
- the creator for the mapping
-
addMapping
@Deprecated public void addMapping(PathSpec spec, WebSocketCreator creator)
Deprecated.Description copied from interface:MappedWebSocketCreator
Add a mapping.- Specified by:
addMapping
in interfaceMappedWebSocketCreator
- Parameters:
spec
- the path spec to usecreator
- the creator for the mapping
-
addMapping
public void addMapping(String spec, WebSocketCreator creator)
Deprecated.Description copied from interface:MappedWebSocketCreator
Add a mapping, of a pathspec to a WebSocketCreator.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)
- Specified by:
addMapping
in interfaceMappedWebSocketCreator
- Parameters:
spec
- the path spec to use.creator
- the websocket creator for this specific mapping
-
removeMapping
public boolean removeMapping(String spec)
Deprecated.Description copied from interface:MappedWebSocketCreator
Removes the mapping based on the given path spec.- Specified by:
removeMapping
in interfaceMappedWebSocketCreator
- Parameters:
spec
- the path spec to remove (using the same spec syntax as seen inMappedWebSocketCreator.addMapping(String, WebSocketCreator)
)- Returns:
- true if underlying mapping were altered, false otherwise
-
destroy
public void destroy()
Deprecated.Description copied from interface:Filter
Called by the web container to indicate to a filter that it is being taken out of service. This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.
This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
Deprecated.Description copied from interface:Filter
ThedoFilter
method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.A typical implementation of this method would follow the following pattern:-
1. Examine the request
2. Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
3. Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
4. a) Either invoke the next entity in the chain using the FilterChain object (chain.doFilter()
),
4. b) or not pass on the request/response pair to the next entity in the filter chain to block the request processing
5. Directly set headers on the response after invocation of the next entity in the filter chain.- Specified by:
doFilter
in interfaceFilter
- Parameters:
request
- The request to processresponse
- The response associated with the requestchain
- Provides access to the next filter in the chain for this filter to pass the request and response to for further processing- Throws:
IOException
- if an I/O error occurs during this filter's processing of the requestServletException
- if the processing fails for any other reason
-
dump
public void dump(Appendable out, String indent) throws IOException
Deprecated.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
-
getFactory
public WebSocketServletFactory getFactory()
Deprecated.
-
getConfiguration
@ManagedAttribute(value="configuration", readonly=true) public NativeWebSocketConfiguration getConfiguration()
Deprecated.
-
getMapping
public WebSocketCreator getMapping(String target)
Deprecated.Description copied from interface:MappedWebSocketCreator
/** Returns the creator for the given path spec.- Specified by:
getMapping
in interfaceMappedWebSocketCreator
- Parameters:
target
- the spec to test for (using the same spec syntax as seen inMappedWebSocketCreator.addMapping(String, WebSocketCreator)
)- Returns:
- the websocket creator if path spec exists, or null
-
init
public void init(FilterConfig config) throws ServletException
Deprecated.Description copied from interface:Filter
Called by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.The web container cannot place the filter into service if the init method either:
- Throws a ServletException
- Does not return within a time period defined by the web container
- Specified by:
init
in interfaceFilter
- Parameters:
config
- The configuration information associated with the filter instance being initialised- Throws:
ServletException
- if the initialisation fails
-
setToAttribute
public void setToAttribute(ServletContext context, String key) throws ServletException
Deprecated.- Throws:
ServletException
-
-