X

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

Guest Author


This blog has published a few blogs on using JSR 356 Reference
Implementation (Tyrus) integrated in href="http://download.java.net/glassfish/4.0/promoted">GlassFish 4
promoted builds.
  • href="https://blogs.oracle.com/arungupta/entry/websocket_applications_using_java_jsr">TOTD
    #183: Getting Started with WebSocket in GlassFish
  • href="https://blogs.oracle.com/arungupta/entry/logging_websocket_frames_using_chrome">TOTD
    #184: Logging WebSocket Frames using Chrome Developer
    Tools, Net-internals and Wireshark
  • href="https://blogs.oracle.com/arungupta/entry/processing_text_and_binary_payload">TOTD
    #185: Processing Text and Binary (Blob, ArrayBuffer,
    ArrayBufferView) Payload in WebSocket
  • href="https://blogs.oracle.com/arungupta/entry/custom_text_and_binary_payloads">TOTD
    #186: Custom Text and Binary Payloads using WebSocket
  • href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in">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 href="http://java.net/projects/websocket-spec/lists/users/archive/2012-12/message/34">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 href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b66.zip">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 href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/">GlassFish
4 promoted builds ?


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.