diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/config/etc/jetty-websockets.xml b/jetty-websocket/javax-websocket-server-impl/src/main/config/etc/jetty-websockets.xml index 797f84efd8f..190a58e5bb2 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/config/etc/jetty-websockets.xml +++ b/jetty-websocket/javax-websocket-server-impl/src/main/config/etc/jetty-websockets.xml @@ -16,12 +16,5 @@ - - - - - org.eclipse.jetty.websocket.jsr356 - false - diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/WebSocketConfiguration.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/WebSocketConfiguration.java index 971d6d11c5a..2040ca95644 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/WebSocketConfiguration.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/WebSocketConfiguration.java @@ -30,15 +30,10 @@ import org.eclipse.jetty.websocket.jsr356.server.deploy.ServerEndpointAnnotation import org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter; /** - * WebSocket Server Configuration component. - * This configuration will configure a context for JSR356 Websockets if - * the attribute "org.eclipse.jetty.websocket.jsr356" is set to true. This - * attribute may be set on an individual context or on the server to affect - * all deployed contexts. + * WebSocket Server Configuration component */ public class WebSocketConfiguration extends AbstractConfiguration { - public static final String ENABLE="org.eclipse.jetty.websocket.jsr356"; private static final Logger LOG = Log.getLogger(WebSocketConfiguration.class); public static ServerContainer configureContext(ServletContextHandler context) @@ -58,46 +53,27 @@ public class WebSocketConfiguration extends AbstractConfiguration return jettyContainer; } - public static boolean isJSR356Context(WebAppContext context) - { - Object enable=context.getAttribute(ENABLE); - if (enable instanceof Boolean) - return ((Boolean)enable).booleanValue(); - - enable=context.getServer().getAttribute(ENABLE); - if (enable instanceof Boolean) - return ((Boolean)enable).booleanValue(); - - return false; - } - @Override public void configure(WebAppContext context) throws Exception { - if (isJSR356Context(context)) - { - LOG.debug("Configure javax.websocket for WebApp {}",context); - WebSocketConfiguration.configureContext(context); - } + LOG.debug("Configure javax.websocket for WebApp {}",context); + WebSocketConfiguration.configureContext(context); } @Override public void preConfigure(WebAppContext context) throws Exception { - if (isJSR356Context(context)) + boolean scanningAdded = false; + // Add the annotation scanning handlers (if annotation scanning enabled) + for (Configuration config : context.getConfigurations()) { - boolean scanningAdded = false; - // Add the annotation scanning handlers (if annotation scanning enabled) - for (Configuration config : context.getConfigurations()) + if (config instanceof AnnotationConfiguration) { - if (config instanceof AnnotationConfiguration) - { - AnnotationConfiguration annocfg = (AnnotationConfiguration)config; - annocfg.addDiscoverableAnnotationHandler(new ServerEndpointAnnotationHandler(context)); - scanningAdded = true; - } + AnnotationConfiguration annocfg = (AnnotationConfiguration)config; + annocfg.addDiscoverableAnnotationHandler(new ServerEndpointAnnotationHandler(context)); + scanningAdded = true; } - LOG.debug("@ServerEndpoint scanning added: {}", scanningAdded); } + LOG.debug("@ServerEndpoint scanning added: {}", scanningAdded); } } diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerApplicationConfigListener.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerApplicationConfigListener.java index 5eebf2935f9..5b82dff24c3 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerApplicationConfigListener.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/ServerApplicationConfigListener.java @@ -35,9 +35,7 @@ import javax.websocket.server.ServerEndpointConfig; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.websocket.jsr356.server.ServerContainer; -import org.eclipse.jetty.websocket.jsr356.server.WebSocketConfiguration; import org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter; @HandlesTypes( @@ -49,9 +47,6 @@ public class ServerApplicationConfigListener implements ServletContainerInitiali @Override public void onStartup(Set> c, ServletContext ctx) throws ServletException { - if (!WebSocketConfiguration.isJSR356Context(WebAppContext.getCurrentWebAppContext())) - return; - WebSocketUpgradeFilter filter = (WebSocketUpgradeFilter)ctx.getAttribute(WebSocketUpgradeFilter.class.getName()); if (filter == null) { diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java index 1fa5333de39..d35fe99cab5 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java @@ -110,7 +110,6 @@ public class WSServer WebAppContext context = new WebAppContext(); context.setContextPath(this.contextPath); context.setBaseResource(Resource.newResource(this.contextDir)); - context.setAttribute(WebSocketConfiguration.ENABLE,Boolean.TRUE); // @formatter:off context.setConfigurations(new Configuration[] { diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml index 42e03cb333a..09f59b7ce9f 100644 --- a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml +++ b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml @@ -28,13 +28,8 @@ detected. false /etc/webdefault.xml /etc/override-web.xml - - - - org.eclipse.jetty.websocket.jsr356 - true - +