jetty-9 alternative websocket discovery
This commit is contained in:
parent
49de22ea48
commit
4ff9bdc54d
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.websocket.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -128,8 +129,16 @@ public abstract class WebSocketServlet extends HttpServlet
|
|||
policy.setMaxBinaryMessageSize(Integer.parseInt(max));
|
||||
}
|
||||
|
||||
ServiceLoader<WebSocketServletFactory> loader = ServiceLoader.load(WebSocketServletFactory.class);
|
||||
WebSocketServletFactory baseFactory = loader.iterator().next();
|
||||
WebSocketServletFactory baseFactory ;
|
||||
Iterator<WebSocketServletFactory> factories = ServiceLoader.load(WebSocketServletFactory.class).iterator();
|
||||
|
||||
if (factories.hasNext())
|
||||
baseFactory=factories.next();
|
||||
else
|
||||
{
|
||||
Class<WebSocketServletFactory> wssf= (Class<WebSocketServletFactory>)getServletContext().getClass().getClassLoader().loadClass("org.eclipse.jetty.websocket.server.WebSocketServerFactory");
|
||||
baseFactory=wssf.newInstance();
|
||||
}
|
||||
|
||||
factory = baseFactory.createFactory(policy);
|
||||
|
||||
|
|
|
@ -172,6 +172,12 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
|
|
|
@ -149,7 +149,7 @@ public class TestServer
|
|||
server.setHandler(restart);
|
||||
|
||||
|
||||
// Setup deployers
|
||||
// Setup context
|
||||
|
||||
HashLoginService login = new HashLoginService();
|
||||
login.setName("Test Realm");
|
||||
|
@ -165,7 +165,8 @@ public class TestServer
|
|||
server.setSendServerVersion(true);
|
||||
|
||||
WebAppContext webapp = new WebAppContext();
|
||||
//webapp.setParentLoaderPriority(true);
|
||||
webapp.setParentLoaderPriority(true);
|
||||
webapp.prependServerClass("-org.eclipse.jetty.websocket.server.");
|
||||
webapp.setResourceBase("./src/main/webapp");
|
||||
webapp.setAttribute("testAttribute","testValue");
|
||||
File sessiondir=File.createTempFile("sessions",null);
|
||||
|
@ -190,7 +191,6 @@ public class TestServer
|
|||
|
||||
private static class RestartHandler extends HandlerWrapper
|
||||
{
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.server.handler.HandlerWrapper#handle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
|
@ -205,6 +205,7 @@ public class TestServer
|
|||
|
||||
new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
|
@ -222,7 +223,5 @@ public class TestServer
|
|||
}.start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue