CreatorNegotiator should remain private, use from on WebSocketNegotiator
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
0a944ac0a9
commit
78707fffde
|
@ -33,6 +33,7 @@ import org.eclipse.jetty.websocket.core.CoreSession;
|
|||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.exception.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.core.server.internal.CreatorNegotiator;
|
||||
import org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -174,7 +175,7 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener
|
|||
*/
|
||||
public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) throws WebSocketException
|
||||
{
|
||||
mappings.put(pathSpec, new CreatorNegotiator(creator, factory, customizer));
|
||||
mappings.put(pathSpec, WebSocketNegotiator.from(creator, factory, customizer));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,11 +18,17 @@ import java.util.function.Function;
|
|||
|
||||
import org.eclipse.jetty.websocket.core.Configuration;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.server.internal.CreatorNegotiator;
|
||||
|
||||
public interface WebSocketNegotiator extends Configuration.Customizer
|
||||
{
|
||||
FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException;
|
||||
|
||||
@Override
|
||||
default void customize(Configuration configurable)
|
||||
{
|
||||
}
|
||||
|
||||
static WebSocketNegotiator from(Function<WebSocketNegotiation, FrameHandler> negotiate)
|
||||
{
|
||||
return from(negotiate, null);
|
||||
|
@ -40,6 +46,16 @@ public interface WebSocketNegotiator extends Configuration.Customizer
|
|||
};
|
||||
}
|
||||
|
||||
static WebSocketNegotiator from(WebSocketCreator creator, FrameHandlerFactory factory)
|
||||
{
|
||||
return from(creator, factory, null);
|
||||
}
|
||||
|
||||
static WebSocketNegotiator from(WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer)
|
||||
{
|
||||
return new CreatorNegotiator(creator, factory, customizer);
|
||||
}
|
||||
|
||||
abstract class AbstractNegotiator extends Configuration.ConfigurationCustomizer implements WebSocketNegotiator
|
||||
{
|
||||
final Configuration.Customizer customizer;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.core.server;
|
||||
package org.eclipse.jetty.websocket.core.server.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -20,6 +20,12 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.websocket.core.FrameHandler;
|
||||
import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest;
|
||||
import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketCreator;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator;
|
||||
|
||||
public class CreatorNegotiator extends WebSocketNegotiator.AbstractNegotiator
|
||||
{
|
|
@ -31,7 +31,6 @@ import org.eclipse.jetty.servlet.ServletHolder;
|
|||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
import org.eclipse.jetty.websocket.core.WebSocketComponents;
|
||||
import org.eclipse.jetty.websocket.core.server.CreatorNegotiator;
|
||||
import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory;
|
||||
import org.eclipse.jetty.websocket.core.server.Handshaker;
|
||||
import org.eclipse.jetty.websocket.core.server.WebSocketCreator;
|
||||
|
@ -100,7 +99,7 @@ public class ProgrammaticWebSocketUpgradeTest
|
|||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
WebSocketCreator creator = (req, resp) -> new EchoSocket();
|
||||
WebSocketNegotiator negotiator = new CreatorNegotiator(creator, frameHandlerFactory);
|
||||
WebSocketNegotiator negotiator = WebSocketNegotiator.from(creator, frameHandlerFactory);
|
||||
handshaker.upgradeRequest(negotiator, request, response, components, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue