Revert "416812 Only start WebSocketContainer if enabled by attribute"
This reverts commit a1cba900c5
.
This commit is contained in:
parent
f7bde55038
commit
7e3ef36f16
|
@ -16,12 +16,5 @@
|
|||
</Arg>
|
||||
</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>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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[] {
|
||||
|
|
|
@ -28,13 +28,8 @@ detected.
|
|||
<Set name="copyWebDir">false</Set>
|
||||
<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">
|
||||
<Array type="String">
|
||||
|
|
Loading…
Reference in New Issue