Skip to content

Commit

Permalink
Issue #4568 - Upgrade websocket to use the jakarta namespace
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 af18fb3 commit cd3e8af
Show file tree
Hide file tree
Showing 363 changed files with 1,407 additions and 1,373 deletions.
2 changes: 1 addition & 1 deletion aggregates/jetty-all/pom.xml
Expand Up @@ -210,7 +210,7 @@
<!-- dependencies that jetty-all needs (some optional) -->
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-javax-websocket-api</artifactId>
<artifactId>jetty-jakarta-websocket-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
Expand Down
2 changes: 1 addition & 1 deletion aggregates/jetty-websocket-all/pom.xml
Expand Up @@ -144,7 +144,7 @@
<!-- dependencies that jetty-all needs (some optional) -->
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-javax-websocket-api</artifactId>
<artifactId>jetty-jakarta-websocket-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -18,18 +18,17 @@

package org.eclipse.jetty.embedded;

import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

import jakarta.websocket.OnMessage;
import jakarta.websocket.Session;
import jakarta.websocket.server.ServerEndpoint;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer;

/**
* Example of setting up a javax.websocket server with Jetty embedded
* Example of setting up a jakarta.websocket server with Jetty embedded
*/
public class WebSocketJsrServer
{
Expand All @@ -56,11 +55,11 @@ public static Server createServer(int port)
context.setContextPath("/");
handlers.addHandler(context);

// Enable javax.websocket configuration for the context
// Enable jakarta.websocket configuration for the context
JavaxWebSocketServletContainerInitializer.configure(context,
(servletContext, serverContainer) ->
{
// Add your websocket to the javax.websocket.server.ServerContainer
// Add your websocket to the jakarta.websocket.server.ServerContainer
serverContainer.addEndpoint(EchoJsrSocket.class);
}
);
Expand Down
Expand Up @@ -31,7 +31,7 @@
/**
* Example of setting up a Jetty WebSocket server
* <p>
* Note: this uses the Jetty WebSocket API, not the javax.websocket API.
* Note: this uses the Jetty WebSocket API, not the jakarta.websocket API.
*/
public class WebSocketServer
{
Expand Down
Expand Up @@ -20,14 +20,14 @@

import java.net.URI;
import java.util.concurrent.LinkedBlockingQueue;
import javax.websocket.CloseReason;
import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;

import jakarta.websocket.CloseReason;
import jakarta.websocket.ContainerProvider;
import jakarta.websocket.Endpoint;
import jakarta.websocket.EndpointConfig;
import jakarta.websocket.MessageHandler;
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.websocket.api.util.WSURI;
Expand Down
Expand Up @@ -1150,13 +1150,13 @@ There is a list of Eclipse P2 sites for the jetty releases maintained at http://
Each P2 repo has one big feature group that defines most of the Jetty jars.
*Beware: No 3rd party dependency jars are included, so you will need to have installed the dependencies listed previously in this document.*

In addition, as the feature group includes websocket, you will need to download and have installed the `javax.websocket-api` jar:
In addition, as the feature group includes websocket, you will need to download and have installed the `jakarta.websocket-api` jar:

.Extra Jars Required for Websocket
[cols=",,",options="header",]
|=======================================================================
|Jar |Bundle Symbolic Name |Location
|javax.websocket-api |javax.websocket-api
|jakarta.websocket-api |jakarta.websocket-api
|https://repo1.maven.org/maven2/javax/websocket/websocket-api[Maven
central]
|=======================================================================
Expand Up @@ -65,7 +65,7 @@ Use http://caniuse.com/websockets[caniuse.com/websockets] to find out.
____

http://www.jcp.org/en/jsr/detail?id=356[JSR-356]::
The Java WebSocket API (`javax.websocket`)
The Java WebSocket API (`jakarta.websocket`)
+
This is the official Java API for working with WebSockets.

Expand Down Expand Up @@ -97,9 +97,9 @@ Jetty WebSocket Server API::
Jetty WebSocket Client API::
Connect to WebSocket servers with Jetty.
Java WebSocket Client API::
The new standard Java WebSocket Client API (`javax.websocket`) [JSR-356]
The new standard Java WebSocket Client API (`jakarta.websocket`) [JSR-356]
Java WebSocket Server API::
The new standard Java WebSocket Server API (`javax.websocket.server`) [JSR-356]
The new standard Java WebSocket Server API (`jakarta.websocket.server`) [JSR-356]

=== Enabling WebSocket

Expand Down
4 changes: 2 additions & 2 deletions jetty-home/pom.xml
Expand Up @@ -203,7 +203,7 @@
</goals>
<configuration>
<includeGroupIds>org.eclipse.jetty.toolchain</includeGroupIds>
<includeArtifactIds>jetty-javax-websocket-api</includeArtifactIds>
<includeArtifactIds>jetty-jakarta-websocket-api</includeArtifactIds>
<includeTypes>jar</includeTypes>
<outputDirectory>${assembly-directory}/lib/websocket</outputDirectory>
</configuration>
Expand All @@ -216,7 +216,7 @@
</goals>
<configuration>
<includeGroupIds>org.eclipse.jetty.toolchain</includeGroupIds>
<includeArtifactIds>jetty-javax-websocket-api</includeArtifactIds>
<includeArtifactIds>jetty-jakarta-websocket-api</includeArtifactIds>
<includeTypes>jar</includeTypes>
<classifier>sources</classifier>
<outputDirectory>${source-assembly-directory}/lib/websocket</outputDirectory>
Expand Down
2 changes: 1 addition & 1 deletion jetty-osgi/test-jetty-osgi/pom.xml
Expand Up @@ -316,7 +316,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-javax-websocket-api</artifactId>
<artifactId>jetty-jakarta-websocket-api</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -34,7 +34,7 @@
<Call name="addEventListener">
<Arg>
<New class="org.eclipse.jetty.osgi.boot.utils.ServerConnectorListener">
<Set name="sysPropertyName">boot.javax.websocket.port</Set>
<Set name="sysPropertyName">boot.jakarta.websocket.port</Set>
</New>
</Arg>
</Call>
Expand Down
Expand Up @@ -19,13 +19,14 @@
package org.eclipse.jetty.osgi.test;

import java.util.concurrent.CountDownLatch;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;

import jakarta.websocket.ClientEndpoint;
import jakarta.websocket.CloseReason;
import jakarta.websocket.OnClose;
import jakarta.websocket.OnError;
import jakarta.websocket.OnMessage;
import jakarta.websocket.OnOpen;
import jakarta.websocket.Session;

import static org.junit.Assert.fail;

Expand Down
Expand Up @@ -23,11 +23,11 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.websocket.ContainerProvider;
import javax.websocket.RemoteEndpoint;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;

import jakarta.websocket.ContainerProvider;
import jakarta.websocket.RemoteEndpoint;
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
Expand Down Expand Up @@ -115,14 +115,14 @@ public void testWebsocket() throws Exception
if (Boolean.getBoolean(TestOSGiUtil.BUNDLE_DEBUG))
assertAllBundlesActiveOrResolved();

String port = System.getProperty("boot.javax.websocket.port");
String port = System.getProperty("boot.jakarta.websocket.port");
assertNotNull(port);

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
assertNotNull(container);

SimpleJavaxWebSocket socket = new SimpleJavaxWebSocket();
URI uri = new URI("ws://127.0.0.1:" + port + "/javax.websocket/");
URI uri = new URI("ws://127.0.0.1:" + port + "/jakarta.websocket/");
try (Session session = container.connectToServer(socket, uri))
{
RemoteEndpoint.Basic remote = session.getBasicRemote();
Expand Down
Expand Up @@ -153,7 +153,7 @@ public static List<Option> coreJettyDependencies()
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-server").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-client").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-common").versionAsInProject().start());
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-javax-websocket-api").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.toolchain").artifactId("jetty-jakarta-websocket-api").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-server").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-client").versionAsInProject().noStart());
res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-javax-common").versionAsInProject().noStart());
Expand Down
2 changes: 1 addition & 1 deletion jetty-websocket/websocket-core/pom.xml
Expand Up @@ -70,7 +70,7 @@
<bannedDependencies>
<includes>
<include>org.eclipse.jetty.websocket:websocket-jetty-api</include>
<include>javax.websocket</include>
<include>jakarta.websocket</include>
</includes>
</bannedDependencies>
</rules>
Expand Down
8 changes: 4 additions & 4 deletions jetty-websocket/websocket-javax-client/pom.xml
Expand Up @@ -8,7 +8,7 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>websocket-javax-client</artifactId>
<name>Jetty :: Websocket :: javax.websocket :: Client</name>
<name>Jetty :: Websocket :: jakarta.websocket :: Client</name>

<properties>
<bundle-symbolic-name>${project.groupId}.javax.client</bundle-symbolic-name>
Expand All @@ -32,7 +32,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-javax-websocket-api</artifactId>
<artifactId>jetty-jakarta-websocket-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -60,15 +60,15 @@
</goals>
<configuration>
<instructions>
<Bundle-Description>javax.websocket.client Implementation</Bundle-Description>
<Bundle-Description>jakarta.websocket.client Implementation</Bundle-Description>
<Export-Package>
org.eclipse.jetty.websocket.javax.client.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
</Export-Package>
<Require-Capability>
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
</Require-Capability>
<Provide-Capability>
osgi.serviceloader;osgi.serviceloader=javax.websocket.ContainerProvider
osgi.serviceloader;osgi.serviceloader=jakarta.websocket.ContainerProvider
</Provide-Capability>
</instructions>
</configuration>
Expand Down
Expand Up @@ -16,8 +16,7 @@
// ========================================================================
//

import javax.websocket.ContainerProvider;

import jakarta.websocket.ContainerProvider;
import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainerProvider;

module org.eclipse.jetty.websocket.javax.client
Expand Down
Expand Up @@ -20,9 +20,9 @@

import java.util.Collections;
import java.util.List;
import javax.websocket.ClientEndpoint;
import javax.websocket.ClientEndpointConfig;

import jakarta.websocket.ClientEndpoint;
import jakarta.websocket.ClientEndpointConfig;
import org.eclipse.jetty.websocket.javax.common.ClientEndpointConfigWrapper;
import org.eclipse.jetty.websocket.util.InvalidWebSocketException;

Expand Down
Expand Up @@ -20,8 +20,9 @@

import java.util.List;
import java.util.Map;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.HandshakeResponse;

import jakarta.websocket.ClientEndpointConfig;
import jakarta.websocket.HandshakeResponse;

public class EmptyConfigurator extends ClientEndpointConfig.Configurator
{
Expand Down
Expand Up @@ -28,14 +28,14 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import javax.websocket.ClientEndpoint;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.Extension;
import javax.websocket.Session;

import jakarta.websocket.ClientEndpoint;
import jakarta.websocket.ClientEndpointConfig;
import jakarta.websocket.DeploymentException;
import jakarta.websocket.Endpoint;
import jakarta.websocket.EndpointConfig;
import jakarta.websocket.Extension;
import jakarta.websocket.Session;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.websocket.core.WebSocketComponents;
Expand All @@ -47,12 +47,12 @@
import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory;

/**
* Container for Client use of the javax.websocket API.
* Container for Client use of the jakarta.websocket API.
* <p>
* This should be specific to a JVM if run in a standalone mode. or specific to a WebAppContext if running on the Jetty server.
*/
@ManagedObject("JSR356 Client Container")
public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer implements javax.websocket.WebSocketContainer
public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer implements jakarta.websocket.WebSocketContainer
{
protected WebSocketCoreClient coreClient;
protected Function<WebSocketComponents, WebSocketCoreClient> coreClientFactory;
Expand All @@ -64,7 +64,7 @@ public JavaxWebSocketClientContainer()
}

/**
* Create a {@link javax.websocket.WebSocketContainer} using the supplied
* Create a {@link jakarta.websocket.WebSocketContainer} using the supplied
* {@link HttpClient} for environments where you want to configure
* SSL/TLS or Proxy behaviors.
*
Expand Down
Expand Up @@ -18,17 +18,16 @@

package org.eclipse.jetty.websocket.javax.client;

import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;

import jakarta.websocket.ContainerProvider;
import jakarta.websocket.WebSocketContainer;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.thread.ShutdownThread;

/**
* Client {@link ContainerProvider} implementation.
* <p>
* Created by a {@link java.util.ServiceLoader} call in the
* {@link javax.websocket.ContainerProvider#getWebSocketContainer()} call.
* {@link jakarta.websocket.ContainerProvider#getWebSocketContainer()} call.
* </p>
*/
public class JavaxWebSocketClientContainerProvider extends ContainerProvider
Expand All @@ -47,9 +46,9 @@ public static void stop(WebSocketContainer container) throws Exception
* <p>
* <em>NOTE: A WebSocket Client Container is a heavyweight object.</em>
* It is dangerous to repeatedly request a new container, or to manage many containers.
* The existing javax.websocket API has no lifecycle for a ClientContainer, once started
* The existing jakarta.websocket API has no lifecycle for a ClientContainer, once started
* they exist for the duration of the JVM with no ability to stop them.
* See/Comment on <a href="https://github.com/javaee/websocket-spec/issues/212">javax.websocket Issue #212</a>
* See/Comment on <a href="https://github.com/javaee/websocket-spec/issues/212">jakarta.websocket Issue #212</a>
* if this is a big concern for you.
* </p>
*/
Expand Down

0 comments on commit cd3e8af

Please sign in to comment.