Skip to content

Commit

Permalink
Issue #4568 - rename websocket methods containing the name javax
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Mar 3, 2020
1 parent 4b5c10d commit 09e076d
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion jetty-websocket/pom.xml
Expand Up @@ -23,7 +23,7 @@
<module>websocket-jetty-client</module>
<module>websocket-jetty-server</module>
<module>websocket-jetty-tests</module>
<!-- Javax WebSocket Implementation -->
<!-- Jakarta WebSocket Implementation -->
<module>websocket-jakarta-common</module>
<module>websocket-jakarta-client</module>
<module>websocket-jakarta-server</module>
Expand Down
@@ -1,7 +1,7 @@
DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html

[description]
Enable both jetty and javax websocket modules for deployed web applications.
Enable both jetty and jakarta websocket modules for deployed web applications.

[tags]
websocket
Expand Down
Expand Up @@ -75,7 +75,7 @@ public JakartaWebSocketClientContainer(final HttpClient httpClient)
this(new WebSocketComponents(), (wsComponents) ->
{
WebSocketCoreClient coreClient = new WebSocketCoreClient(httpClient, wsComponents);
coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
coreClient.getHttpClient().setName("Jakarta-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
return coreClient;
});
}
Expand All @@ -85,7 +85,7 @@ public JakartaWebSocketClientContainer(WebSocketComponents components)
this(components, (wsComponents) ->
{
WebSocketCoreClient coreClient = new WebSocketCoreClient(wsComponents);
coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
coreClient.getHttpClient().setName("Jakarta-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
return coreClient;
});
}
Expand Down
Expand Up @@ -58,6 +58,6 @@ public JakartaWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass,
}

JakartaWebSocketFrameHandlerMetadata metadata = new JakartaWebSocketFrameHandlerMetadata(endpointConfig);
return discoverJavaxFrameHandlerMetadata(endpointClass, metadata);
return discoverJakartaFrameHandlerMetadata(endpointClass, metadata);
}
}
Expand Up @@ -155,7 +155,7 @@ public Set<jakarta.websocket.Session> getOpenSessions()

public JakartaWebSocketFrameHandler newFrameHandler(Object websocketPojo, UpgradeRequest upgradeRequest)
{
return getFrameHandlerFactory().newJavaxWebSocketFrameHandler(websocketPojo, upgradeRequest);
return getFrameHandlerFactory().newJakartaWebSocketFrameHandler(websocketPojo, upgradeRequest);
}

/**
Expand Down
Expand Up @@ -83,7 +83,7 @@ public class JakartaWebSocketFrameHandler implements FrameHandler
* </p>
* <p>
* The values are represented as {@link String} and are essentially static for this
* instance of the the JavaxWebSocketFrameHandler. They will be converted to the
* instance of the the JakartaWebSocketFrameHandler. They will be converted to the
* type declared by the {@code @PathParam} annotations following the JSR356 advice
* to only support String, Java Primitives (or their Boxed version).
* </p>
Expand Down Expand Up @@ -197,7 +197,7 @@ public void onOpen(CoreSession coreSession, Callback callback)
if (openHandle != null)
openHandle.invoke();

container.notifySessionListeners((listener) -> listener.onJavaxWebSocketSessionOpened(session));
container.notifySessionListeners((listener) -> listener.onJakartaWebSocketSessionOpened(session));
callback.succeeded();
}
catch (Throwable cause)
Expand Down Expand Up @@ -291,7 +291,7 @@ public void onClose(Frame frame, Callback callback)
public void onClosed(CloseStatus closeStatus, Callback callback)
{
notifyOnClose(closeStatus, callback);
container.notifySessionListeners((listener) -> listener.onJavaxWebSocketSessionClosed(session));
container.notifySessionListeners((listener) -> listener.onJakartaWebSocketSessionClosed(session));
}

private void notifyOnClose(CloseStatus closeStatus, Callback callback)
Expand Down
Expand Up @@ -146,7 +146,7 @@ public JakartaWebSocketFrameHandlerFactory(JakartaWebSocketContainer container,

public abstract EndpointConfig newDefaultEndpointConfig(Class<?> endpointClass, String path);

public JakartaWebSocketFrameHandler newJavaxWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest)
public JakartaWebSocketFrameHandler newJakartaWebSocketFrameHandler(Object endpointInstance, UpgradeRequest upgradeRequest)
{
Object endpoint;
EndpointConfig config;
Expand Down Expand Up @@ -364,10 +364,10 @@ public static MethodHandle wrapNonVoidReturnType(MethodHandle handle, JakartaWeb

// Technique from https://stackoverflow.com/questions/48505787/methodhandle-with-general-non-void-return-filter

// Change the return type of the to be Object so it will match exact with JavaxWebSocketSession.filterReturnType(Object)
// Change the return type of the to be Object so it will match exact with JakartaWebSocketSession.filterReturnType(Object)
handle = handle.asType(handle.type().changeReturnType(Object.class));

// Filter the method return type to a call to JavaxWebSocketSession.filterReturnType() bound to this session
// Filter the method return type to a call to JakartaWebSocketSession.filterReturnType() bound to this session
handle = MethodHandles.filterReturnValue(handle, FILTER_RETURN_TYPE_METHOD.bindTo(session));

return handle;
Expand Down Expand Up @@ -408,7 +408,7 @@ protected JakartaWebSocketFrameHandlerMetadata createEndpointMetadata(Class<? ex
return metadata;
}

protected JakartaWebSocketFrameHandlerMetadata discoverJavaxFrameHandlerMetadata(Class<?> endpointClass, JakartaWebSocketFrameHandlerMetadata metadata)
protected JakartaWebSocketFrameHandlerMetadata discoverJakartaFrameHandlerMetadata(Class<?> endpointClass, JakartaWebSocketFrameHandlerMetadata metadata)
{
MethodHandles.Lookup lookup = getMethodHandleLookup(endpointClass);
Method onmethod;
Expand Down
Expand Up @@ -215,7 +215,7 @@ private long getBlockingTimeout()
*
* @param obj the return object
*/
@SuppressWarnings("unused") // used by JavaxWebSocketFrameHandlerFactory via MethodHandle
@SuppressWarnings("unused") // used by Jakarta WebSocketFrameHandlerFactory via MethodHandle
public void filterReturnType(Object obj)
{
if (obj != null)
Expand Down
Expand Up @@ -20,7 +20,7 @@

public interface JakartaWebSocketSessionListener
{
void onJavaxWebSocketSessionOpened(JakartaWebSocketSession session);
void onJakartaWebSocketSessionOpened(JakartaWebSocketSession session);

void onJavaxWebSocketSessionClosed(JakartaWebSocketSession session);
void onJakartaWebSocketSessionClosed(JakartaWebSocketSession session);
}
Expand Up @@ -41,13 +41,13 @@ public Set<Session> getSessions()
}

@Override
public void onJavaxWebSocketSessionOpened(JakartaWebSocketSession session)
public void onJakartaWebSocketSessionOpened(JakartaWebSocketSession session)
{
sessions.add(session);
}

@Override
public void onJavaxWebSocketSessionClosed(JakartaWebSocketSession session)
public void onJakartaWebSocketSessionClosed(JakartaWebSocketSession session)
{
sessions.remove(session);
}
Expand Down
Expand Up @@ -29,7 +29,7 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

public abstract class AbstractJavaxWebSocketFrameHandlerTest
public abstract class AbstractJakartaWebSocketFrameHandlerTest
{
protected static DummyContainer container;

Expand All @@ -52,7 +52,7 @@ public static void stopContainer() throws Exception
protected EndpointConfig endpointConfig;
protected CoreSession coreSession = new CoreSession.Empty();

public AbstractJavaxWebSocketFrameHandlerTest()
public AbstractJakartaWebSocketFrameHandlerTest()
{
endpointConfig = ClientEndpointConfig.Builder.create().build();
encoders = new AvailableEncoders(endpointConfig);
Expand All @@ -65,6 +65,6 @@ protected JakartaWebSocketFrameHandler newJakartaFrameHandler(Object websocket)
JakartaWebSocketFrameHandlerFactory factory = container.getFrameHandlerFactory();
ConfiguredEndpoint endpoint = new ConfiguredEndpoint(websocket, endpointConfig);
UpgradeRequest upgradeRequest = new UpgradeRequestAdapter();
return factory.newJavaxWebSocketFrameHandler(endpoint, upgradeRequest);
return factory.newJakartaWebSocketFrameHandler(endpoint, upgradeRequest);
}
}
Expand Up @@ -51,6 +51,6 @@ public JakartaWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass,
}

JakartaWebSocketFrameHandlerMetadata metadata = new JakartaWebSocketFrameHandlerMetadata(endpointConfig);
return discoverJavaxFrameHandlerMetadata(endpointClass, metadata);
return discoverJakartaFrameHandlerMetadata(endpointClass, metadata);
}
}
Expand Up @@ -31,7 +31,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class JakartaWebSocketFrameHandlerBadSignaturesTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerBadSignaturesTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private void assertBadSocket(Object socket, String expectedString) throws Exception
{
Expand Down
Expand Up @@ -35,7 +35,7 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;

public class JakartaWebSocketFrameHandlerOnCloseTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnCloseTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private static final String EXPECTED_REASON = "CloseReason[1000,Normal]";

Expand Down Expand Up @@ -89,7 +89,7 @@ public void testInvokeCloseSession() throws Exception
{
assertOnCloseInvocation(new CloseSessionSocket(),
allOf(
containsString("onClose(JavaxWebSocketSession@"),
containsString("onClose(JakartaWebSocketSession@"),
containsString(CloseSessionSocket.class.getName())
));
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testInvokeCloseSessionReason() throws Exception
{
assertOnCloseInvocation(new CloseSessionReasonSocket(),
allOf(
containsString("onClose(JavaxWebSocketSession@"),
containsString("onClose(JakartaWebSocketSession@"),
containsString(CloseSessionReasonSocket.class.getName())
));
}
Expand Down
Expand Up @@ -32,7 +32,7 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;

public class JakartaWebSocketFrameHandlerOnErrorTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnErrorTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private static final String EXPECTED_THROWABLE = "java.lang.RuntimeException: From Testcase";

Expand Down Expand Up @@ -62,7 +62,7 @@ public void testInvokeErrorSessionThrowable() throws Exception
{
assertOnErrorInvocation(new ErrorSessionThrowableSocket(),
allOf(
containsString("onError(JavaxWebSocketSession@"),
containsString("onError(JakartaWebSocketSession@"),
containsString(ErrorSessionThrowableSocket.class.getName()),
containsString(EXPECTED_THROWABLE)
));
Expand Down
Expand Up @@ -36,7 +36,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class JakartaWebSocketFrameHandlerOnMessageBinaryStreamTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnMessageBinaryStreamTest extends AbstractJakartaWebSocketFrameHandlerTest
{
@SuppressWarnings("Duplicates")
private TrackingSocket performOnMessageInvocation(TrackingSocket socket, Function<JakartaWebSocketFrameHandler, Void> func) throws Exception
Expand Down
Expand Up @@ -40,7 +40,7 @@
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class JakartaWebSocketFrameHandlerOnMessageBinaryTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnMessageBinaryTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private void assertOnMessageInvocation(TrackingSocket socket, Matcher<String> eventMatcher) throws Exception
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public void testInvokeMessageSession() throws Exception
assertThrows(InvalidSignatureException.class, () ->
assertOnMessageInvocation(new MessageSessionSocket(),
allOf(
containsString("onMessage(JavaxWebSocketSession@"),
containsString("onMessage(JakartaWebSocketSession@"),
containsString(MessageSessionSocket.class.getName())
))
);
Expand All @@ -132,7 +132,7 @@ public void testInvokeMessageSessionByteBuffer() throws Exception
{
assertOnMessageInvocation(new MessageSessionByteBufferSocket(),
allOf(
containsString("onMessage(JavaxWebSocketSession@"),
containsString("onMessage(JakartaWebSocketSession@"),
containsString(MessageSessionByteBufferSocket.class.getName())
));
}
Expand Down
Expand Up @@ -35,7 +35,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class JakartaWebSocketFrameHandlerOnMessageTextStreamTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnMessageTextStreamTest extends AbstractJakartaWebSocketFrameHandlerTest
{
@SuppressWarnings("Duplicates")
private TrackingSocket performOnMessageInvocation(TrackingSocket socket, Function<JakartaWebSocketFrameHandler, Void> func) throws Exception
Expand Down
Expand Up @@ -39,7 +39,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class JakartaWebSocketFrameHandlerOnMessageTextTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnMessageTextTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private void onText(TrackingSocket socket, String msg) throws Exception
{
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testInvokeMessageSessionText() throws Exception
{
assertOnMessageInvocation(new MessageSessionTextSocket(),
allOf(
containsString("onMessage(JavaxWebSocketSession@"),
containsString("onMessage(JakartaWebSocketSession@"),
containsString(MessageSessionTextSocket.class.getName()),
containsString(", Hello World)")
));
Expand Down
Expand Up @@ -32,7 +32,7 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;

public class JakartaWebSocketFrameHandlerOnOpenTest extends AbstractJavaxWebSocketFrameHandlerTest
public class JakartaWebSocketFrameHandlerOnOpenTest extends AbstractJakartaWebSocketFrameHandlerTest
{
private void assertOnOpenInvocation(TrackingSocket socket, Matcher<String> eventMatcher) throws Exception
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public void testInvokeOpenSession() throws Exception
{
assertOnOpenInvocation(new OpenSessionSocket(),
allOf(
containsString("onOpen(JavaxWebSocketSession"),
containsString("onOpen(JakartaWebSocketSession"),
containsString(OpenSessionSocket.class.getName())
));
}
Expand Down
Expand Up @@ -39,7 +39,7 @@ public JakartaWebSocketConfiguration()
addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName());
protectAndExpose("org.eclipse.jetty.websocket.servlet."); // For WebSocketUpgradeFilter
protectAndExpose("org.eclipse.jetty.websocket.jakarta.server.config.");
protectAndExpose("JavaxWebSocketClientContainerProvider");
protectAndExpose("JakartaWebSocketClientContainerProvider");
hide("org.eclipse.jetty.websocket.jakarta.server.internal");
}
}
Expand Up @@ -50,7 +50,7 @@ public class JakartaWebSocketServletContainerInitializer implements ServletConta
* The ServletContext attribute key name for the
* ServerContainer per jakarta.websocket spec 1.0 final section 6.4 Programmatic Server Deployment
*/
public static final String ATTR_JAVAX_SERVER_CONTAINER = jakarta.websocket.server.ServerContainer.class.getName();
public static final String ATTR_JAKARTA_SERVER_CONTAINER = jakarta.websocket.server.ServerContainer.class.getName();

public static final String ENABLE_KEY = "org.eclipse.jetty.websocket.jakarta";
public static final String HTTPCLIENT_ATTRIBUTE = "org.eclipse.jetty.websocket.jakarta.HttpClient";
Expand Down Expand Up @@ -175,11 +175,11 @@ public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletExc

if (!websocketEnabled)
{
LOG.info("Javax Websocket is disabled by configuration for context {}", context.getContextPath());
LOG.info("Jakarta Websocket is disabled by configuration for context {}", context.getContextPath());
return;
}

ServletContextHandler servletContextHandler = ServletContextHandler.getServletContextHandler(context, "Javax WebSocket SCI");
ServletContextHandler servletContextHandler = ServletContextHandler.getServletContextHandler(context, "Jakarta WebSocket SCI");
ServerContainer container = initialize(servletContextHandler);

try (ThreadClassLoaderScope scope = new ThreadClassLoaderScope(context.getClassLoader()))
Expand Down
Expand Up @@ -79,7 +79,7 @@ public AnnotatedServerEndpointConfig(JakartaWebSocketContainer containerScope, C
ServerEndpointConfig.Configurator rawConfigurator = getConfigurator(baseServerConfig, anno);
ServerEndpointConfig.Configurator configurator = containerScope.getObjectFactory().decorate(rawConfigurator);

// Build a ServerEndpointConfig with the Javax API builder to wrap.
// Build a ServerEndpointConfig with the Jakarta API builder to wrap.
ServerEndpointConfig endpointConfig = ServerEndpointConfig.Builder.create(endpointClass, path)
.configurator(configurator)
.encoders(encoders)
Expand Down
Expand Up @@ -84,7 +84,7 @@ public static JakartaWebSocketServerContainer ensureContainer(ServletContext ser

// create the core client
coreClient = new WebSocketCoreClient(httpClient, wsComponents);
coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
coreClient.getHttpClient().setName("Jakarta-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode()));
if (executor != null && httpClient == null)
coreClient.getHttpClient().setExecutor(executor);
servletContext.setAttribute(WebSocketCoreClient.WEBSOCKET_CORECLIENT_ATTRIBUTE, coreClient);
Expand Down
Expand Up @@ -54,12 +54,12 @@ public JakartaWebSocketFrameHandlerMetadata getMetadata(Class<?> endpointClass,
UriTemplatePathSpec templatePathSpec = new UriTemplatePathSpec(anno.value());
JakartaWebSocketFrameHandlerMetadata metadata = new JakartaWebSocketFrameHandlerMetadata(endpointConfig);
metadata.setUriTemplatePathSpec(templatePathSpec);
return discoverJavaxFrameHandlerMetadata(endpointClass, metadata);
return discoverJakartaFrameHandlerMetadata(endpointClass, metadata);
}

@Override
public FrameHandler newFrameHandler(Object websocketPojo, ServletUpgradeRequest upgradeRequest, ServletUpgradeResponse upgradeResponse)
{
return newJavaxWebSocketFrameHandler(websocketPojo, new JakartaServerUpgradeRequest(upgradeRequest));
return newJakartaWebSocketFrameHandler(websocketPojo, new JakartaServerUpgradeRequest(upgradeRequest));
}
}

0 comments on commit 09e076d

Please sign in to comment.