WebSocket Samples in GlassFish 4 build 66 - javax.websocket.* package: TOTD #190

Posted by arungupta on Oracle Blogs See other posts from Oracle Blogs or by arungupta
Published on Wed, 12 Dec 2012 20:27:42 +0000 Indexed on 2012/12/12 23:11 UTC
Read the original article Hit count: 363

Filed under:

This blog has published a few blogs on using JSR 356 Reference Implementation (Tyrus) integrated in GlassFish 4 promoted builds.
  • TOTD #183: Getting Started with WebSocket in GlassFish
  • TOTD #184: Logging WebSocket Frames using Chrome Developer Tools, Net-internals and Wireshark
  • TOTD #185: Processing Text and Binary (Blob, ArrayBuffer, ArrayBufferView) Payload in WebSocket
  • TOTD #186: Custom Text and Binary Payloads using WebSocket
  • TOTD #189: Collaborative Whiteboard using WebSocket in GlassFish 4
The earlier blogs created a WebSocket endpoint as:
import javax.net.websocket.annotations.WebSocketEndpoint;

@WebSocketEndpoint("websocket")
public class MyEndpoint {
. . .
Based upon the discussion in JSR 356 EG, the package names have changed to javax.websocket.*. So the updated endpoint definition will look like:
import javax.websocket.WebSocketEndpoint;

@WebSocketEndpoint("websocket")
public class MyEndpoint {
. . .
The POM dependency is:
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0-b09</version>
</dependency>

And if you are using GlassFish 4 build 66, then you also need to provide a dummy EndpointFactory implementation as:
import javax.websocket.WebSocketEndpoint;

@WebSocketEndpoint(value="websocket", factory=MyEndpoint.DummyEndpointFactory.class)
public class MyEndpoint {
 . . .   
class DummyEndpointFactory implements EndpointFactory {
    @Override
public Object createEndpoint() { return null; }
  }
}
This is only interim and will be cleaned up in subsequent builds. But I've seen couple of complaints about this already and so this deserves a short blog.

Have you been tracking the latest Java EE 7 implementations in GlassFish 4 promoted builds ?

© Oracle Blogs or respective owner

Related posts about /General