Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor edits #6016

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions modules/ROOT/pages/jakarta-ee10-diff.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,20 @@ For more information, see the https://jakarta.ee/specifications/mail/2.1/jakarta
[#socket]
== Differences between Jakarta WebSocket 2.1 and 2.0

The feature:websocket-2.1[display=Jakarta WebSocket 2.1] feature implements changes for specification APIs and methods, as well as updates to the handling of user properties and the setting of the client SSL context.
The feature:websocket-2.1[display=Jakarta WebSocket 2.1] feature implements changes for specification APIs and methods. It also includes updates to the handling of user properties and the setting of the client SSL context.

=== API replacement for the WsWsocServerContainer#upgrade SPI

In Jakarta WebSocket 2.1, you can programmatically upgrade your HTTP requests to a WebSocket connection by using the new link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/server/servercontainer#upgradeHttpToWebSocket(java.lang.Object,java.lang.Object,jakarta.websocket.server.ServerEndpointConfig,java.util.Map)[jakarta.websocket.server.ServerContainer#upgradeHttpToWebSocket()] API method. This method replaces the link:https://www.ibm.com/docs/en/was-liberty/nd?topic=SSAW57_liberty/com.ibm.websphere.javadoc.liberty.doc/com.ibm.websphere.appserver.api.wsoc_1.0-javadoc/com/ibm/websphere/wsoc/WsWsocServerContainer.htm[com.ibm.websphere.wsoc.WsWsocServerContainer] SPI, which is now deprecated, with plans to remove it in the next WebSocket release. However, this SPI is available in WebSocket features before version 2.1.
In Jakarta WebSocket 2.1, you can programmatically upgrade your HTTP requests to a WebSocket connection by using the new link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/server/servercontainer#upgradeHttpToWebSocket(java.lang.Object,java.lang.Object,jakarta.websocket.server.ServerEndpointConfig,java.util.Map)[jakarta.websocket.server.ServerContainer#upgradeHttpToWebSocket()] API method. This method replaces the link:https://www.ibm.com/docs/en/was-liberty/nd?topic=SSAW57_liberty/com.ibm.websphere.javadoc.liberty.doc/com.ibm.websphere.appserver.api.wsoc_1.0-javadoc/com/ibm/websphere/wsoc/WsWsocServerContainer.htm[com.ibm.websphere.wsoc.WsWsocServerContainer] SPI, which is now deprecated, with plans to remove it in the next WebSocket release. However, this SPI is still available with the Jakarta WebSocket feature version 2.0 and earlier.

=== Updates for for handling of user properties

The WebSocket 2.1 release includes changes for link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/session#getUserProperties()[user properties]. The user properties for server sessions are initially populated by the `ServerEndpointConfig.getUserProperties()` method, which enables endpoints to retrieve properties that are set in a link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/server/serverendpointconfig.configurator#modifyHandshake(jakarta.websocket.server.ServerEndpointConfig,jakarta.websocket.server.HandshakeRequest,jakarta.websocket.HandshakeResponse)[ServerEndpointConfig.Configurator#modifyHandshake] instance​. Similarly, link:https://jakarta.ee/specifications/websocket/2.1/apidocs/client/jakarta/websocket/session#getUserProperties()[user properties for client sessions] are populated with the `EndpointConfig.getUserProperties()` method. These initial contents are shallow copies, which means that `ClientEndpointConfig#getUserProperties` and `ServerEndpointConfig#getUserProperties()` instances are now handled per endpoint, per WebSocket session. Properties are no longer global between all endpoint instances as they were in previous WebSocket versions.
The WebSocket 2.1 release includes changes for link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/session#getUserProperties()[user properties]. The user properties for server sessions are initially populated by the `ServerEndpointConfig.getUserProperties()` method, which enables endpoints to retrieve properties that are set in a link:https://jakarta.ee/specifications/websocket/2.1/apidocs/server/jakarta/websocket/server/serverendpointconfig.configurator#modifyHandshake(jakarta.websocket.server.ServerEndpointConfig,jakarta.websocket.server.HandshakeRequest,jakarta.websocket.HandshakeResponse)[ServerEndpointConfig.Configurator#modifyHandshake] instance​.

Similarly, link:https://jakarta.ee/specifications/websocket/2.1/apidocs/client/jakarta/websocket/session#getUserProperties()[user properties for client sessions] are populated with the `EndpointConfig.getUserProperties()` method. These initial contents are shallow copies, which means that `ClientEndpointConfig#getUserProperties` and `ServerEndpointConfig#getUserProperties()` instances are now handled per endpoint, per WebSocket session. Properties are no longer global between all endpoint instances as they were in previous WebSocket versions.

=== Client SSL configuration
Starting with WebSocket 2.1, applications can set their SSLContext by using a link:https://jakarta.ee/specifications/websocket/2.1/apidocs/client/jakarta/websocket/clientendpointconfig.builder#sslContext(javax.net.ssl.SSLContext)[jakarta.websocket.ClientEndpointConfig.Builder#sslContext]​ instance, which Liberty uses to establish the `wss` connection to a server. This option overrides all Liberty server SSL configurations and must be used with caution. It is recommended to enable SSL communication in the `server.xml` file by enabling the feature:transportSecurity[display=Transport Security] feature. Also, you can configure SSL by setting the config:wsocOutbound[] attribute in the `server.xml` file.
Starting with WebSocket 2.1, applications can set their `SSLContext` class by using a link:https://jakarta.ee/specifications/websocket/2.1/apidocs/client/jakarta/websocket/clientendpointconfig.builder#sslContext(javax.net.ssl.SSLContext)[jakarta.websocket.ClientEndpointConfig.Builder#sslContext]​ instance, which Liberty uses to establish the `wss` connection to a server. This option overrides all Liberty server SSL configurations and must be used with caution. It is recommended to enable SSL communication in the `server.xml` file by enabling the feature:transportSecurity[display=Transport Security] feature. Also, you can configure SSL by setting the config:wsocOutbound[] attribute in the `server.xml` file.

=== Other changes

Expand All @@ -487,6 +489,7 @@ The following changes are effective starting with WebSocket 2.1.
* The link:https://jakarta.ee/specifications/websocket/2.1/apidocs/client/jakarta/websocket/session#getRequestURI()[jakarta.websocket.Session.getRequestURI()] method returns the full URI String from the protocol to the query string, if the string is present.

For more information, see the https://jakarta.ee/specifications/websocket/2.1/jakarta-websocket-spec-2.1.html[Jakarta WebSocket 2.1] specification.

== See also

* xref:jakarta-ee.adoc[Jakarta EE overview]