rename WebSocketMapping to WebSocketMappings
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
165beff3f3
commit
6dad0b1b7e
|
@ -40,7 +40,7 @@ import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
|||
import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerContainer;
|
||||
import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain
|
|||
{
|
||||
WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(context.getServer(), context.getServletContext());
|
||||
FilterHolder filterHolder = WebSocketUpgradeFilter.ensureFilter(context.getServletContext());
|
||||
WebSocketMapping mapping = WebSocketMapping.ensureMapping(context.getServletContext());
|
||||
WebSocketMappings mapping = WebSocketMappings.ensureMapping(context.getServletContext());
|
||||
serverContainer = JavaxWebSocketServerContainer.ensureContainer(context.getServletContext());
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.eclipse.jetty.websocket.javax.server.config.ContainerDefaultConfigura
|
|||
import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer;
|
||||
import org.eclipse.jetty.websocket.util.InvalidSignatureException;
|
||||
import org.eclipse.jetty.websocket.util.ReflectUtils;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
|
|||
|
||||
// Create the Jetty ServerContainer implementation
|
||||
container = new JavaxWebSocketServerContainer(
|
||||
WebSocketMapping.ensureMapping(servletContext),
|
||||
WebSocketMappings.ensureMapping(servletContext),
|
||||
WebSocketServerComponents.getWebSocketComponents(servletContext),
|
||||
coreClientSupplier);
|
||||
contextHandler.addManaged(container);
|
||||
|
@ -109,7 +109,7 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
|
|||
return container;
|
||||
}
|
||||
|
||||
private final WebSocketMapping webSocketMapping;
|
||||
private final WebSocketMappings webSocketMappings;
|
||||
private final JavaxWebSocketServerFrameHandlerFactory frameHandlerFactory;
|
||||
private List<Class<?>> deferredEndpointClasses;
|
||||
private List<ServerEndpointConfig> deferredEndpointConfigs;
|
||||
|
@ -117,31 +117,31 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
|
|||
/**
|
||||
* Main entry point for {@link JavaxWebSocketServletContainerInitializer}.
|
||||
*
|
||||
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
||||
* @param webSocketMappings the {@link WebSocketMappings} that this container belongs to
|
||||
*/
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping)
|
||||
public JavaxWebSocketServerContainer(WebSocketMappings webSocketMappings)
|
||||
{
|
||||
this(webSocketMapping, new WebSocketComponents());
|
||||
this(webSocketMappings, new WebSocketComponents());
|
||||
}
|
||||
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents components)
|
||||
public JavaxWebSocketServerContainer(WebSocketMappings webSocketMappings, WebSocketComponents components)
|
||||
{
|
||||
super(components);
|
||||
this.webSocketMapping = webSocketMapping;
|
||||
this.webSocketMappings = webSocketMappings;
|
||||
this.frameHandlerFactory = new JavaxWebSocketServerFrameHandlerFactory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for {@link JavaxWebSocketServletContainerInitializer}.
|
||||
*
|
||||
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
||||
* @param webSocketMappings the {@link WebSocketMappings} that this container belongs to
|
||||
* @param components the {@link WebSocketComponents} instance to use
|
||||
* @param coreClientSupplier the supplier of the {@link WebSocketCoreClient} instance to use
|
||||
*/
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents components, Function<WebSocketComponents, WebSocketCoreClient> coreClientSupplier)
|
||||
public JavaxWebSocketServerContainer(WebSocketMappings webSocketMappings, WebSocketComponents components, Function<WebSocketComponents, WebSocketCoreClient> coreClientSupplier)
|
||||
{
|
||||
super(components, coreClientSupplier);
|
||||
this.webSocketMapping = webSocketMapping;
|
||||
this.webSocketMappings = webSocketMappings;
|
||||
this.frameHandlerFactory = new JavaxWebSocketServerFrameHandlerFactory(this);
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer
|
|||
frameHandlerFactory.getMetadata(config.getEndpointClass(), config);
|
||||
JavaxWebSocketCreator creator = new JavaxWebSocketCreator(this, config, getExtensionRegistry());
|
||||
PathSpec pathSpec = new UriTemplatePathSpec(config.getPath());
|
||||
webSocketMapping.addMapping(pathSpec, creator, frameHandlerFactory, defaultCustomizer);
|
||||
webSocketMappings.addMapping(pathSpec, creator, frameHandlerFactory, defaultCustomizer);
|
||||
}
|
||||
catch (InvalidSignatureException e)
|
||||
{
|
||||
|
|
|
@ -12,16 +12,12 @@
|
|||
</context-param>
|
||||
|
||||
<filter>
|
||||
<filter-name>wsuf-test</filter-name>
|
||||
<filter-name>org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter</filter-name>
|
||||
<filter-class>org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>jetty.websocket.WebSocketMapping</param-name>
|
||||
<param-value>jetty.websocket.defaultMapping</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>wsuf-test</filter-name>
|
||||
<filter-name>org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter</filter-name>
|
||||
<url-pattern>/echo/*</url-pattern>
|
||||
</filter-mapping>
|
||||
</web-app>
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactor
|
|||
import org.eclipse.jetty.websocket.util.ReflectUtils;
|
||||
import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
// Create the Jetty ServerContainer implementation
|
||||
container = new JettyWebSocketServerContainer(
|
||||
contextHandler,
|
||||
WebSocketMapping.ensureMapping(servletContext),
|
||||
WebSocketMappings.ensureMapping(servletContext),
|
||||
WebSocketServerComponents.getWebSocketComponents(servletContext), executor);
|
||||
servletContext.setAttribute(JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE, container);
|
||||
contextHandler.addManaged(container);
|
||||
|
@ -90,7 +90,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
private static final Logger LOG = LoggerFactory.getLogger(JettyWebSocketServerContainer.class);
|
||||
|
||||
private final ServletContextHandler contextHandler;
|
||||
private final WebSocketMapping webSocketMapping;
|
||||
private final WebSocketMappings webSocketMappings;
|
||||
private final WebSocketComponents components;
|
||||
private final FrameHandlerFactory frameHandlerFactory;
|
||||
private final Executor executor;
|
||||
|
@ -102,14 +102,14 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
/**
|
||||
* Main entry point for {@link JettyWebSocketServletContainerInitializer}.
|
||||
*
|
||||
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
||||
* @param webSocketMappings the {@link WebSocketMappings} that this container belongs to
|
||||
* @param components the {@link WebSocketComponents} instance to use
|
||||
* @param executor the {@link Executor} to use
|
||||
*/
|
||||
JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMapping webSocketMapping, WebSocketComponents components, Executor executor)
|
||||
JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMappings webSocketMappings, WebSocketComponents components, Executor executor)
|
||||
{
|
||||
this.contextHandler = contextHandler;
|
||||
this.webSocketMapping = webSocketMapping;
|
||||
this.webSocketMappings = webSocketMappings;
|
||||
this.executor = executor;
|
||||
this.components = components;
|
||||
|
||||
|
@ -129,12 +129,12 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
|||
|
||||
public void addMapping(String pathSpec, JettyWebSocketCreator creator)
|
||||
{
|
||||
PathSpec ps = WebSocketMapping.parsePathSpec(pathSpec);
|
||||
if (webSocketMapping.getMapping(ps) != null)
|
||||
PathSpec ps = WebSocketMappings.parsePathSpec(pathSpec);
|
||||
if (webSocketMappings.getMapping(ps) != null)
|
||||
throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec");
|
||||
|
||||
WebSocketUpgradeFilter.ensureFilter(contextHandler.getServletContext());
|
||||
webSocketMapping.addMapping(ps,
|
||||
webSocketMappings.addMapping(ps,
|
||||
(req, resp) -> creator.createWebSocket(new DelegatedServerUpgradeRequest(req), new DelegatedServerUpgradeResponse(resp)),
|
||||
frameHandlerFactory, customizer);
|
||||
}
|
||||
|
|
|
@ -40,14 +40,14 @@ import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory;
|
|||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Abstract Servlet used to bridge the Servlet API to the WebSocket API.
|
||||
* <p>
|
||||
* To use this servlet, you will be required to register your websockets with the {@link WebSocketMapping} so that it can create your websockets under the
|
||||
* To use this servlet, you will be required to register your websockets with the {@link WebSocketMappings} so that it can create your websockets under the
|
||||
* appropriate conditions.
|
||||
* </p>
|
||||
* <p>The most basic implementation would be as follows:</p>
|
||||
|
@ -68,11 +68,11 @@ import org.slf4j.LoggerFactory;
|
|||
* }
|
||||
* </pre>
|
||||
* <p>
|
||||
* Only request that conforms to a "WebSocket: Upgrade" handshake request will trigger the {@link WebSocketMapping} handling of creating
|
||||
* Only request that conforms to a "WebSocket: Upgrade" handshake request will trigger the {@link WebSocketMappings} handling of creating
|
||||
* WebSockets. All other requests are treated as normal servlet requests. The configuration defined by this servlet init parameters will
|
||||
* be used as the customizer for any mappings created by {@link JettyWebSocketServletFactory#addMapping(String, JettyWebSocketCreator)} during
|
||||
* {@link #configure(JettyWebSocketServletFactory)} calls. The request upgrade may be peformed by this servlet, or is may be performed by a
|
||||
* {@link WebSocketUpgradeFilter} instance that will share the same {@link WebSocketMapping} instance. If the filter is used, then the
|
||||
* {@link WebSocketUpgradeFilter} instance that will share the same {@link WebSocketMappings} instance. If the filter is used, then the
|
||||
* filter configuraton is used as the default configuration prior to this servlets configuration being applied.
|
||||
* </p>
|
||||
* <p>
|
||||
|
@ -99,7 +99,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
private static final Logger LOG = LoggerFactory.getLogger(JettyWebSocketServlet.class);
|
||||
private final CustomizedWebSocketServletFactory customizer = new CustomizedWebSocketServletFactory();
|
||||
|
||||
private WebSocketMapping mapping;
|
||||
private WebSocketMappings mapping;
|
||||
private WebSocketComponents components;
|
||||
|
||||
/**
|
||||
|
@ -133,7 +133,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
ServletContext servletContext = getServletContext();
|
||||
|
||||
components = WebSocketServerComponents.getWebSocketComponents(servletContext);
|
||||
mapping = new WebSocketMapping(components);
|
||||
mapping = new WebSocketMappings(components);
|
||||
|
||||
String max = getInitParameter("idleTimeout");
|
||||
if (max == null)
|
||||
|
@ -208,7 +208,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
@Override
|
||||
public void addMapping(String pathSpec, JettyWebSocketCreator creator)
|
||||
{
|
||||
mapping.addMapping(WebSocketMapping.parsePathSpec(pathSpec), new WrappedJettyCreator(creator), getFactory(), this);
|
||||
mapping.addMapping(WebSocketMappings.parsePathSpec(pathSpec), new WrappedJettyCreator(creator), getFactory(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,7 +249,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
@Override
|
||||
public JettyWebSocketCreator getMapping(String pathSpec)
|
||||
{
|
||||
WebSocketCreator creator = mapping.getMapping(WebSocketMapping.parsePathSpec(pathSpec));
|
||||
WebSocketCreator creator = mapping.getMapping(WebSocketMappings.parsePathSpec(pathSpec));
|
||||
if (creator instanceof WrappedJettyCreator)
|
||||
return ((WrappedJettyCreator)creator).getJettyWebSocketCreator();
|
||||
|
||||
|
@ -259,7 +259,7 @@ public abstract class JettyWebSocketServlet extends HttpServlet
|
|||
@Override
|
||||
public boolean removeMapping(String pathSpec)
|
||||
{
|
||||
return mapping.removeMapping(WebSocketMapping.parsePathSpec(pathSpec));
|
||||
return mapping.removeMapping(WebSocketMappings.parsePathSpec(pathSpec));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.jetty.servlet.listener.ContainerInitializer;
|
|||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents;
|
||||
import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain
|
|||
* during the {@link ServletContext} initialization phase.
|
||||
*
|
||||
* @param context the context to add listener to.
|
||||
* @param configurator a lambda that is called to allow the {@link WebSocketMapping} to
|
||||
* @param configurator a lambda that is called to allow the {@link WebSocketMappings} to
|
||||
* be configured during {@link ServletContext} initialization phase
|
||||
*/
|
||||
public static void configure(ServletContextHandler context, Configurator configurator)
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
|
|||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.thread.AutoLock;
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
|
|||
* <p>
|
||||
* The configuration applied to this filter via init params will be used as the the default
|
||||
* configuration of any websocket upgraded by this filter, prior to the configuration of the
|
||||
* websocket applied by the {@link WebSocketMapping}.
|
||||
* websocket applied by the {@link WebSocketMappings}.
|
||||
* </p>
|
||||
* <p>
|
||||
* <b>Configuration / Init-Parameters:</b>
|
||||
|
@ -126,7 +126,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
}
|
||||
|
||||
private final Configuration.ConfigurationCustomizer defaultCustomizer = new Configuration.ConfigurationCustomizer();
|
||||
private WebSocketMapping mapping;
|
||||
private WebSocketMappings mapping;
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
|
||||
|
@ -162,7 +162,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
@Override
|
||||
public void init(FilterConfig config) throws ServletException
|
||||
{
|
||||
mapping = WebSocketMapping.ensureMapping(config.getServletContext());
|
||||
mapping = WebSocketMappings.ensureMapping(config.getServletContext());
|
||||
|
||||
String max = config.getInitParameter("idleTimeout");
|
||||
if (max == null)
|
||||
|
|
|
@ -56,14 +56,14 @@ import org.slf4j.LoggerFactory;
|
|||
* wrap that POJO with a {@link FrameHandler} and the customizer is used to configure the resulting
|
||||
* {@link CoreSession}.</p>
|
||||
*/
|
||||
public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
||||
public class WebSocketMappings implements Dumpable, LifeCycle.Listener
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebSocketMapping.class);
|
||||
public static final String WEBSOCKET_MAPPING_ATTRIBUTE = WebSocketMapping.class.getName();
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebSocketMappings.class);
|
||||
public static final String WEBSOCKET_MAPPING_ATTRIBUTE = WebSocketMappings.class.getName();
|
||||
|
||||
public static WebSocketMapping getMapping(ServletContext servletContext)
|
||||
public static WebSocketMappings getMapping(ServletContext servletContext)
|
||||
{
|
||||
return (WebSocketMapping)servletContext.getAttribute(WEBSOCKET_MAPPING_ATTRIBUTE);
|
||||
return (WebSocketMappings)servletContext.getAttribute(WEBSOCKET_MAPPING_ATTRIBUTE);
|
||||
}
|
||||
|
||||
public WebSocketCreator getMapping(PathSpec pathSpec)
|
||||
|
@ -72,12 +72,12 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
return cn == null ? null : cn.getWebSocketCreator();
|
||||
}
|
||||
|
||||
public static WebSocketMapping ensureMapping(ServletContext servletContext)
|
||||
public static WebSocketMappings ensureMapping(ServletContext servletContext)
|
||||
{
|
||||
WebSocketMapping mapping = getMapping(servletContext);
|
||||
WebSocketMappings mapping = getMapping(servletContext);
|
||||
if (mapping == null)
|
||||
{
|
||||
mapping = new WebSocketMapping(WebSocketServerComponents.getWebSocketComponents(servletContext));
|
||||
mapping = new WebSocketMappings(WebSocketServerComponents.getWebSocketComponents(servletContext));
|
||||
servletContext.setAttribute(WEBSOCKET_MAPPING_ATTRIBUTE, mapping);
|
||||
}
|
||||
|
||||
|
@ -127,12 +127,12 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
private final WebSocketComponents components;
|
||||
private final Handshaker handshaker = Handshaker.newInstance();
|
||||
|
||||
public WebSocketMapping()
|
||||
public WebSocketMappings()
|
||||
{
|
||||
this(new WebSocketComponents());
|
||||
}
|
||||
|
||||
public WebSocketMapping(WebSocketComponents components)
|
||||
public WebSocketMappings(WebSocketComponents components)
|
||||
{
|
||||
this.components = components;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
public void lifeCycleStopping(LifeCycle context)
|
||||
{
|
||||
ContextHandler contextHandler = (ContextHandler)context;
|
||||
WebSocketMapping mapping = contextHandler.getBean(WebSocketMapping.class);
|
||||
WebSocketMappings mapping = contextHandler.getBean(WebSocketMappings.class);
|
||||
if (mapping == this)
|
||||
{
|
||||
contextHandler.removeBean(mapping);
|
Loading…
Reference in New Issue