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
import javax.net.websocket.annotations.WebSocketEndpoint;Based upon the discussion in JSR 356 EG, the package names have changed to
@WebSocketEndpoint("websocket")
public class MyEndpoint {
. . .
javax.websocket.*
.
So the updated endpoint definition will look like:import javax.websocket.WebSocketEndpoint;The POM dependency is:
@WebSocketEndpoint("websocket")
public class MyEndpoint {
. . .
<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;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.@WebSocketEndpoint(value="websocket", factory=MyEndpoint.DummyEndpointFactory.class)
public class MyEndpoint {. . .
class DummyEndpointFactory implements EndpointFactory {
@Override
public Object createEndpoint() { return null; }
}
}
Have you been tracking the latest Java EE 7 implementations in GlassFish 4 promoted builds ?