don't allow custom CoreClients to be supplied to JavaxClientContainer
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
c40a303e2c
commit
0b41386c0d
|
@ -40,6 +40,7 @@ import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
|
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
||||||
import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint;
|
import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint;
|
||||||
|
@ -64,34 +65,23 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple
|
||||||
|
|
||||||
public JavaxWebSocketClientContainer()
|
public JavaxWebSocketClientContainer()
|
||||||
{
|
{
|
||||||
this(() -> {
|
this(new WebSocketComponents(), null, null);
|
||||||
WebSocketCoreClient coreClient = new WebSocketCoreClient();
|
|
||||||
coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
|
|
||||||
return coreClient;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaxWebSocketClientContainer(Supplier<WebSocketCoreClient> coreClientFactory)
|
public JavaxWebSocketClientContainer(WebSocketComponents components, HttpClient httpClient, Executor executor)
|
||||||
{
|
{
|
||||||
this((WebSocketCoreClient)null);
|
this.objectFactory = components.getObjectFactory();
|
||||||
this.coreClientFactory = coreClientFactory;
|
this.extensionRegistry = components.getExtensionRegistry();
|
||||||
this.addBean(coreClientFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JavaxWebSocketClientContainer(WebSocketCoreClient coreClient)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
|
|
||||||
if (coreClient != null)
|
|
||||||
{
|
|
||||||
coreClient.setCustomizer(defaultCustomizer);
|
|
||||||
this.coreClient = coreClient;
|
|
||||||
this.addBean(coreClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.objectFactory = new DecoratedObjectFactory();
|
|
||||||
this.extensionRegistry = new WebSocketExtensionRegistry();
|
|
||||||
this.frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(this);
|
this.frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(this);
|
||||||
|
|
||||||
|
coreClientFactory = () ->
|
||||||
|
{
|
||||||
|
WebSocketCoreClient coreClient = new WebSocketCoreClient(httpClient, defaultCustomizer);
|
||||||
|
coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
|
||||||
|
if (executor != null && httpClient == null)
|
||||||
|
coreClient.getHttpClient().setExecutor(executor);
|
||||||
|
return coreClient;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,12 +106,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple
|
||||||
if (coreClient == null)
|
if (coreClient == null)
|
||||||
{
|
{
|
||||||
coreClient = coreClientFactory.get();
|
coreClient = coreClientFactory.get();
|
||||||
if (coreClient.isRunning())
|
|
||||||
addBean(coreClient,false);
|
|
||||||
else
|
|
||||||
addManaged(coreClient);
|
addManaged(coreClient);
|
||||||
|
|
||||||
coreClient.setCustomizer(defaultCustomizer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return coreClient;
|
return coreClient;
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||||
import org.eclipse.jetty.websocket.core.WebSocketException;
|
import org.eclipse.jetty.websocket.core.WebSocketException;
|
||||||
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry;
|
||||||
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
|
|
||||||
import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer;
|
import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer;
|
||||||
import org.eclipse.jetty.websocket.javax.server.internal.AnnotatedServerEndpointConfig;
|
import org.eclipse.jetty.websocket.javax.server.internal.AnnotatedServerEndpointConfig;
|
||||||
import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator;
|
import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator;
|
||||||
|
@ -138,13 +137,7 @@ public class JavaxWebSocketServerContainer
|
||||||
*/
|
*/
|
||||||
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents webSocketComponents, HttpClient httpClient, Executor executor)
|
public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents webSocketComponents, HttpClient httpClient, Executor executor)
|
||||||
{
|
{
|
||||||
super(() ->
|
super(webSocketComponents, httpClient, executor);
|
||||||
{
|
|
||||||
WebSocketCoreClient client = new WebSocketCoreClient(httpClient);
|
|
||||||
if (executor != null && httpClient == null)
|
|
||||||
client.getHttpClient().setExecutor(executor);
|
|
||||||
return client;
|
|
||||||
});
|
|
||||||
this.webSocketMapping = webSocketMapping;
|
this.webSocketMapping = webSocketMapping;
|
||||||
this.webSocketComponents = webSocketComponents;
|
this.webSocketComponents = webSocketComponents;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
|
|
|
@ -71,16 +71,6 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand
|
||||||
addBean(httpClient);
|
addBean(httpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrameHandler.ConfigurationCustomizer getCustomizer()
|
|
||||||
{
|
|
||||||
return customizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCustomizer(FrameHandler.ConfigurationCustomizer customizer)
|
|
||||||
{
|
|
||||||
this.customizer = customizer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(FrameHandler.CoreSession session)
|
public void customize(FrameHandler.CoreSession session)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue