Testing / UntrustedWSServer improvements
This commit is contained in:
parent
e1ebcdaf18
commit
c496dd7961
|
@ -23,6 +23,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -55,6 +56,7 @@ public class UntrustedWSServer extends ContainerLifeCycle implements UntrustedWS
|
||||||
private URI wsUri;
|
private URI wsUri;
|
||||||
private boolean ssl = false;
|
private boolean ssl = false;
|
||||||
private SslContextFactory sslContextFactory;
|
private SslContextFactory sslContextFactory;
|
||||||
|
private Consumer<Server> serverConsumer;
|
||||||
|
|
||||||
private Map<URI, CompletableFuture<UntrustedWSSession>> onOpenFutures = new ConcurrentHashMap<>();
|
private Map<URI, CompletableFuture<UntrustedWSSession>> onOpenFutures = new ConcurrentHashMap<>();
|
||||||
private final ServletContextHandler context = new ServletContextHandler();
|
private final ServletContextHandler context = new ServletContextHandler();
|
||||||
|
@ -111,6 +113,12 @@ public class UntrustedWSServer extends ContainerLifeCycle implements UntrustedWS
|
||||||
// Serve untrusted endpoint
|
// Serve untrusted endpoint
|
||||||
context.addServlet(UntrustedWSServlet.class, "/untrusted/*").setInitOrder(1);
|
context.addServlet(UntrustedWSServlet.class, "/untrusted/*").setInitOrder(1);
|
||||||
|
|
||||||
|
// Allow for server customization
|
||||||
|
if (serverConsumer != null)
|
||||||
|
{
|
||||||
|
serverConsumer.accept(server);
|
||||||
|
}
|
||||||
|
|
||||||
// Start Server
|
// Start Server
|
||||||
addBean(server);
|
addBean(server);
|
||||||
|
|
||||||
|
@ -134,6 +142,16 @@ public class UntrustedWSServer extends ContainerLifeCycle implements UntrustedWS
|
||||||
super.doStart();
|
super.doStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setServerCustomizer(Consumer<Server> customizer)
|
||||||
|
{
|
||||||
|
this.serverConsumer = customizer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void join() throws InterruptedException
|
||||||
|
{
|
||||||
|
server.join();
|
||||||
|
}
|
||||||
|
|
||||||
public URI getWsUri()
|
public URI getWsUri()
|
||||||
{
|
{
|
||||||
return wsUri;
|
return wsUri;
|
||||||
|
|
Loading…
Reference in New Issue