Skip to main content
Introduction to the Web Sockets SDK
Danny Coward, December 2011

The Web Sockets SDK consists of the pieces a developer needs to annotated Plain Old Java Objects and turn them into Web Socket End points.

As a developer using this SDK, you'll be writing code that is some more sophisticated version of the basic form you see on the right.

When you run this example on the SDK, you'll get a web socket deployed to ws://hostname:port/hello, which says hello back in web sockets when you send it a message.
    @WebSocket(path="/hello")
public class HelloTest {
   
    @WebSocketMessage
    public String doThis(String caller) {
        return "hello " + caller + "!";
    }

}

On the right is a picture of a bigger web sockets application, containing POJOs annotated to turn them into Web Socket end points. Everything below the Web Socket Application is the runtime portion of the SDK.

The WS API: this is the API that developers use in their POJOs. The contains the annotations like @WebSocket and things like a session objects. Here's the current javadoc.

The WS Runtime manages the code generated by the SDK from the POJOs in the web socket application and supports the features of the WS API like the session object.

The runtime uses Grizzly, either running on its own from the command line, or within Glassfish thanks to the Java EE integration layer in the SDK. That's why in the picture Glassfish has a dotted line around it. If the developer is going to use the SDK in Glassfish mode, he'll be able to use all the Java EE APIs too; like JSPs and the HttpSession object of the web session his application will be in.

The other parts of the SDK (so far !) are the annotation processors that slot into the compiler at development time, a bunch of tests (mostly testing one thing at a time), and some samples like a group stock portfolio application, a chat application, and a group drawing app. The tests and samples all come with javascript/HTML5 clients that run on any Java EE server.

Now its probably time to get started.









 
 
Close
loading
Please Confirm
Close