Revert "416812 Only start WebSocketContainer if enabled by attribute"

This reverts commit a1cba900c5.
This commit is contained in:
Joakim Erdfelt 2013-09-09 09:28:33 -07:00
parent f7bde55038
commit 7e3ef36f16
5 changed files with 12 additions and 54 deletions

View File

@ -17,11 +17,4 @@
</Call>
</Call>
<!-- Enable/Disable JSR356 Container for all contexts -->
<!-- This attribute may be enabled/disabled either on the server or on individual contexts -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.websocket.jsr356</Arg>
<Arg type="Boolean">false</Arg>
</Call>
</Configure>

View File

@ -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);
}
}

View File

@ -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<Class<?>> c, ServletContext ctx) throws ServletException
{
if (!WebSocketConfiguration.isJSR356Context(WebAppContext.getCurrentWebAppContext()))
return;
WebSocketUpgradeFilter filter = (WebSocketUpgradeFilter)ctx.getAttribute(WebSocketUpgradeFilter.class.getName());
if (filter == null)
{

View File

@ -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[] {

View File

@ -29,11 +29,6 @@ detected.
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Set name="overrideDescriptor"><Property name="jetty.base" default="."/>/etc/override-web.xml</Set>
<!-- Enable/Disable JSR356 Container for this context -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.websocket.jsr356</Arg>
<Arg type="Boolean">true</Arg>
</Call>
<!-- virtual hosts
<Set name="virtualHosts">