By Juergenkress-Oracle on Mar 14, 2015
The latest release of JDeveloper 12c (22.214.171.124) along with WebLogic
Server 12.1.3 came up with some new Java EE 7 features. One of them is
support of JSR 356 Java API for WebSockets. Actually the WebSocket
Protocol (RFC 6455) has been supported starting from 126.96.36.199 release,
but it was based on WebLogic specific implementation of the WebSocket
API. Now this proprietary WebLogic Server WebSocket API has been deprecated. However, it is still supported for backward compatibility.
In this post I am going to show an example of using JSR 356 Java API for WebSockets in a simple ADF application. The use case is about some sailing regatta which takes place in the Tasman Sea. There are three boats participating in the regatta and they are going to cross the Tasman Sea sailing from Australia to New Zealand coast. The goal of the sample application is to monitor the regatta and inform users about how it is going on, showing the positions of the boats on a map.
We're going to declare a WebSocket server endpoint in the application and when a user opens a page a Java script function opens a new WebSocket connection. The application uses a scheduled service which every second updates boats coordinates and sends a message containing new boats positions to all active WebSocket clients. On the client side a Java script function receives the message and adds markers to the Google map according to the GPS coordinates. So, each user, interested in the regatta, is going to see the same updated picture representing the current status of the competition.
WebSocket server endpoint
start with declaring a WebSocket server endpoint. There is a small
issue in the current implementation, which probably will be resolved in
future releases. The WebSocket endpoints can not be mixed with ADF pages
and they should be deployed in a separate WAR file. The easiest way to
do that is to create a separate WebSocket project within the application
and to declare all necessary endpoints in this project: Read the complete article here.
For regular information become a member in the WebLogic Partner Community please visit: http://www.oracle.com/partners/goto/wls-emea ( OPN account required). If you need support with your account please contact the Oracle Partner Business Center.