rename of WebSocketResources to WebSocketComponents
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
b2f2a16aed
commit
0c85b3138f
|
@ -22,7 +22,6 @@ import java.time.Duration;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.EndpointConfig;
|
||||
|
@ -43,9 +42,9 @@ import org.eclipse.jetty.util.component.LifeCycle;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||
import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer;
|
||||
import org.eclipse.jetty.websocket.javax.server.internal.AnnotatedServerEndpointConfig;
|
||||
|
@ -108,7 +107,7 @@ public class JavaxWebSocketServerContainer
|
|||
// Create the Jetty ServerContainer implementation
|
||||
container = new JavaxWebSocketServerContainer(
|
||||
WebSocketMapping.ensureMapping(servletContext, WebSocketMapping.DEFAULT_KEY),
|
||||
WebSocketResources.ensureWebSocketResources(servletContext),
|
||||
WebSocketComponents.ensureWebSocketComponents(servletContext),
|
||||
httpClient, executor);
|
||||
contextHandler.addManaged(container);
|
||||
contextHandler.addLifeCycleListener(container);
|
||||
|
@ -119,7 +118,7 @@ public class JavaxWebSocketServerContainer
|
|||
}
|
||||
|
||||
private final WebSocketMapping webSocketMapping;
|
||||
private final WebSocketResources webSocketResources;
|
||||
private final WebSocketComponents webSocketComponents;
|
||||
private final JavaxWebSocketServerFrameHandlerFactory frameHandlerFactory;
|
||||
private final Executor executor;
|
||||
private final FrameHandler.ConfigurationCustomizer customizer = new FrameHandler.ConfigurationCustomizer();
|
||||
|
@ -130,16 +129,16 @@ public class JavaxWebSocketServerContainer
|
|||
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, HttpClient httpClient, Executor executor)
|
||||
{
|
||||
this(webSocketMapping, new WebSocketResources(), httpClient, executor);
|
||||
this(webSocketMapping, new WebSocketComponents(), httpClient, executor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point for {@link JavaxWebSocketServletContainerInitializer}.
|
||||
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
||||
* @param webSocketResources the {@link WebSocketResources} instance to use
|
||||
* @param webSocketComponents the {@link WebSocketComponents} instance to use
|
||||
* @param httpClient the {@link HttpClient} instance to use
|
||||
*/
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketResources webSocketResources, HttpClient httpClient, Executor executor)
|
||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents webSocketComponents, HttpClient httpClient, Executor executor)
|
||||
{
|
||||
super(() ->
|
||||
{
|
||||
|
@ -149,7 +148,7 @@ public class JavaxWebSocketServerContainer
|
|||
return client;
|
||||
});
|
||||
this.webSocketMapping = webSocketMapping;
|
||||
this.webSocketResources = webSocketResources;
|
||||
this.webSocketComponents = webSocketComponents;
|
||||
this.executor = executor;
|
||||
this.frameHandlerFactory = new JavaxWebSocketServerFrameHandlerFactory(this);
|
||||
}
|
||||
|
@ -170,7 +169,7 @@ public class JavaxWebSocketServerContainer
|
|||
@Override
|
||||
public ByteBufferPool getBufferPool()
|
||||
{
|
||||
return webSocketResources.getBufferPool();
|
||||
return webSocketComponents.getBufferPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -182,7 +181,7 @@ public class JavaxWebSocketServerContainer
|
|||
@Override
|
||||
public WebSocketExtensionRegistry getExtensionRegistry()
|
||||
{
|
||||
return webSocketResources.getExtensionRegistry();
|
||||
return webSocketComponents.getExtensionRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,7 +193,7 @@ public class JavaxWebSocketServerContainer
|
|||
@Override
|
||||
public DecoratedObjectFactory getObjectFactory()
|
||||
{
|
||||
return webSocketResources.getObjectFactory();
|
||||
return webSocketComponents.getObjectFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -288,7 +287,7 @@ public class JavaxWebSocketServerContainer
|
|||
{
|
||||
frameHandlerFactory.getMetadata(config.getEndpointClass(), config);
|
||||
|
||||
JavaxWebSocketCreator creator = new JavaxWebSocketCreator(this, config, webSocketResources
|
||||
JavaxWebSocketCreator creator = new JavaxWebSocketCreator(this, config, webSocketComponents
|
||||
.getExtensionRegistry());
|
||||
|
||||
PathSpec pathSpec = new UriTemplatePathSpec(config.getPath());
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.javax.server;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -37,7 +36,7 @@ import org.eclipse.jetty.util.TypeUtil;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.thread.ThreadClassLoaderScope;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.servlet.WebSocketMapping;
|
||||
import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter;
|
||||
|
||||
|
@ -84,13 +83,13 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain
|
|||
|
||||
public static JavaxWebSocketServerContainer configureContext(ServletContextHandler context)
|
||||
{
|
||||
WebSocketResources resources = WebSocketResources.ensureWebSocketResources(context.getServletContext());
|
||||
WebSocketComponents components = WebSocketComponents.ensureWebSocketComponents(context.getServletContext());
|
||||
FilterHolder filterHolder = WebSocketUpgradeFilter.ensureFilter(context.getServletContext());
|
||||
WebSocketMapping mapping = WebSocketMapping.ensureMapping(context.getServletContext(), WebSocketMapping.DEFAULT_KEY);
|
||||
JavaxWebSocketServerContainer container = JavaxWebSocketServerContainer.ensureContainer(context.getServletContext());
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("configureContext {} {} {} {}", mapping, resources, filterHolder, container);
|
||||
LOG.debug("configureContext {} {} {} {}", mapping, components, filterHolder, container);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.websocket.server;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -29,7 +28,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
|
||||
/**
|
||||
* ServletContext configuration for Jetty Native WebSockets API.
|
||||
|
@ -73,10 +72,10 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain
|
|||
@Override
|
||||
public void onStartup(Set<Class<?>> c, ServletContext servletContext) throws ServletException
|
||||
{
|
||||
WebSocketResources resources = WebSocketResources.ensureWebSocketResources(servletContext);
|
||||
WebSocketComponents components = WebSocketComponents.ensureWebSocketComponents(servletContext);
|
||||
JettyServerFrameHandlerFactory factory = JettyServerFrameHandlerFactory.ensureFactory(servletContext);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onStartup {} {}", resources, factory);
|
||||
LOG.debug("onStartup {} {}", components, factory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,29 +25,29 @@ import org.eclipse.jetty.io.MappedByteBufferPool;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
|
||||
public class WebSocketResources
|
||||
public class WebSocketComponents
|
||||
{
|
||||
public static WebSocketResources ensureWebSocketResources(ServletContext servletContext)
|
||||
public static WebSocketComponents ensureWebSocketComponents(ServletContext servletContext)
|
||||
{
|
||||
ContextHandler contextHandler = ContextHandler.getContextHandler(servletContext);
|
||||
|
||||
// Ensure a mapping exists
|
||||
WebSocketResources resources = contextHandler.getBean(WebSocketResources.class);
|
||||
if (resources == null)
|
||||
WebSocketComponents components = contextHandler.getBean(WebSocketComponents.class);
|
||||
if (components == null)
|
||||
{
|
||||
resources = new WebSocketResources();
|
||||
contextHandler.addBean(resources);
|
||||
components = new WebSocketComponents();
|
||||
contextHandler.addBean(components);
|
||||
}
|
||||
|
||||
return resources;
|
||||
return components;
|
||||
}
|
||||
|
||||
public WebSocketResources()
|
||||
public WebSocketComponents()
|
||||
{
|
||||
this(new WebSocketExtensionRegistry(), new DecoratedObjectFactory(), new MappedByteBufferPool());
|
||||
}
|
||||
|
||||
public WebSocketResources(WebSocketExtensionRegistry extensionRegistry, DecoratedObjectFactory objectFactory, ByteBufferPool bufferPool)
|
||||
public WebSocketComponents(WebSocketExtensionRegistry extensionRegistry, DecoratedObjectFactory objectFactory, ByteBufferPool bufferPool)
|
||||
{
|
||||
this.extensionRegistry = extensionRegistry;
|
||||
this.objectFactory = objectFactory;
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.servlet;
|
|||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -39,8 +38,8 @@ import org.eclipse.jetty.util.component.LifeCycle;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
import org.eclipse.jetty.websocket.core.server.Handshaker;
|
||||
import org.eclipse.jetty.websocket.core.server.Negotiation;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator;
|
||||
|
@ -75,7 +74,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
}
|
||||
else
|
||||
{
|
||||
WebSocketMapping mapping = new WebSocketMapping(WebSocketResources.ensureWebSocketResources(servletContext));
|
||||
WebSocketMapping mapping = new WebSocketMapping(WebSocketComponents.ensureWebSocketComponents(servletContext));
|
||||
contextHandler.setAttribute(mappingKey, mapping);
|
||||
return mapping;
|
||||
}
|
||||
|
@ -84,17 +83,17 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
public static final String DEFAULT_KEY = "org.eclipse.jetty.websocket.WebSocketMapping";
|
||||
|
||||
private final PathMappings<Negotiator> mappings = new PathMappings<>();
|
||||
private final WebSocketResources resources;
|
||||
private final WebSocketComponents components;
|
||||
private final Handshaker handshaker = Handshaker.newInstance();
|
||||
|
||||
public WebSocketMapping()
|
||||
{
|
||||
this(new WebSocketResources());
|
||||
this(new WebSocketComponents());
|
||||
}
|
||||
|
||||
public WebSocketMapping(WebSocketResources resources)
|
||||
public WebSocketMapping(WebSocketComponents components)
|
||||
{
|
||||
this.resources = resources;
|
||||
this.components = components;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -253,7 +252,7 @@ public class WebSocketMapping implements Dumpable, LifeCycle.Listener
|
|||
|
||||
public Negotiator(WebSocketCreator creator, FrameHandlerFactory factory, FrameHandler.Customizer customizer)
|
||||
{
|
||||
super(resources.getExtensionRegistry(), resources.getObjectFactory(), resources.getBufferPool(), customizer);
|
||||
super(components.getExtensionRegistry(), components.getObjectFactory(), components.getBufferPool(), customizer);
|
||||
this.creator = creator;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.servlet;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.time.Duration;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
@ -34,8 +33,8 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
|
||||
/**
|
||||
* Abstract Servlet used to bridge the Servlet API to the WebSocket API.
|
||||
|
@ -96,7 +95,7 @@ public abstract class WebSocketServlet extends HttpServlet
|
|||
private final CustomizedWebSocketServletFactory customizer = new CustomizedWebSocketServletFactory();
|
||||
|
||||
private WebSocketMapping mapping;
|
||||
private WebSocketResources resources;
|
||||
private WebSocketComponents components;
|
||||
|
||||
/**
|
||||
* Configure the WebSocketServletFactory for this servlet instance by setting default
|
||||
|
@ -114,8 +113,8 @@ public abstract class WebSocketServlet extends HttpServlet
|
|||
{
|
||||
ServletContext servletContext = getServletContext();
|
||||
|
||||
resources = WebSocketResources.ensureWebSocketResources(servletContext);
|
||||
mapping = new WebSocketMapping(resources);
|
||||
components = WebSocketComponents.ensureWebSocketComponents(servletContext);
|
||||
mapping = new WebSocketMapping(components);
|
||||
|
||||
String max = getInitParameter("maxIdleTime");
|
||||
if (max != null)
|
||||
|
@ -180,7 +179,7 @@ public abstract class WebSocketServlet extends HttpServlet
|
|||
{
|
||||
public WebSocketExtensionRegistry getExtensionRegistry()
|
||||
{
|
||||
return resources.getExtensionRegistry();
|
||||
return components.getExtensionRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.servlet;
|
|||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
|
@ -42,7 +41,7 @@ import org.eclipse.jetty.util.component.Dumpable;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketResources;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
|
||||
/**
|
||||
* Inline Servlet Filter to capture WebSocket upgrade requests.
|
||||
|
@ -164,7 +163,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable
|
|||
if (mappingKey != null)
|
||||
mapping = WebSocketMapping.ensureMapping(context, mappingKey);
|
||||
else
|
||||
mapping = new WebSocketMapping(WebSocketResources.ensureWebSocketResources(context));
|
||||
mapping = new WebSocketMapping(WebSocketComponents.ensureWebSocketComponents(context));
|
||||
|
||||
String max = config.getInitParameter("maxIdleTime");
|
||||
if (max != null)
|
||||
|
|
Loading…
Reference in New Issue