Tag Archives: jsr356

Accessing HTTP Session in WebSocket endpoint

It’s possible to obtain a reference to the HttpSession within a WebSocket application using a custom implementation of ServerEndpointConfig.Configurator Here is an example application on Github Steps… Override the modifyHandshakeRequest method call the getHttpSession method on the HandshakeRequest object which is passed into the … Continue reading

Posted in Java EE | Tagged , , , , | Leave a comment

Handling ‘state’ in Java WebSocket applications

By and large, there are two kinds of states in a WebSocket application User/client specific: related to a connected user/Session e.g. user ID, list of subscriptions, last message received etc. Global: state which is relevant across your application and something … Continue reading

Posted in Java, Java EE | Tagged , , | 2 Comments

Github: WebSocket applications…

I recently pushed a couple of WebSocket samples to Github. Both are based around the notion of a chat service – a canonical WebSocket example! These were originally meant to serve as additional material to the Java WebSocket API Handbook in order … Continue reading

Posted in Java EE | Tagged , , , | Leave a comment

Quick tip: managing Stateful EJBs in WebSocket endpoints

@Stateful EJBs can be injected in WebSocket endpoints (supported by the WebSocket specification). There is an one-to-one association between the WebSocket client & endpoint (which is by default) as well as the injected Stateful EJB instance, which makes it an good candidate for storing … Continue reading

Posted in Java, Java EE | Tagged , , , , , , | Leave a comment

Using Asynchronous timeouts in the Java WebSocket API

Sending messages in an asynchronous manner avoid blocking the sending thread. This is a great where your solution needs to scale in order to support a large number of clients. But there is a limit on how long can we … Continue reading

Posted in Java, Java EE | Tagged , , , , , | Leave a comment

WebSocket and CDI integration.. again..

In one of my older blog posts, I had written about what does not work as far as WebSocket and CDI integration within the Java EE Platform 😉 This one talks about what’s possible with CDI in terms of Dependency Injection Interceptors … Continue reading

Posted in Java, Java EE | Tagged , , , , , , , | 3 Comments

Configuring WebSocket server endpoints

WebSocket Server endpoint configuration Before we dive into the details, here is a quick snapshot of the related interfaces Class/Interface Description ServerEndpointConfig A derivative of EndpointConfig interface which is specific for configuration related to server side WebSocket endpoints ServerEndpointConfig.Configurator An … Continue reading

Posted in Java, Java EE | Tagged , , , , | Leave a comment

Deploying WebSocket annotated & programmatic server endpoints together

One of my previous blog post discussed Programmatic WebSocket endpoints and their deployment methodology using the javax.server.ServerApplicationConfig class. When annotated and programmatic endpoints co-exist… you have to make use of the a custom implementation of ServerApplicationConfig and explicitly return set … Continue reading

Posted in Java EE | Tagged , , , | Leave a comment

Programmatic Websocket endpoints in Java EE 7…

This post briefly demonstrates how to develop and deploy (server and client) Websocket endpoints using the programmatic version of the Java Websocket API To begin with… extend the javax.websocket.Endpoint class This file contains bidirectional Unicode text that may be interpreted or compiled … Continue reading

Posted in Java EE | Tagged , , | 2 Comments

Just a follow up on WebSocket API issue with Tyrus (on GlassFish)

Follow up on the WebSocket API issue with Tyrus (on GlassFish). I initially reported this under Glassfish 4 – details. This has been appropriately filed under TYRUS – link and should hopefully be resolved soon. Thanks to Pavel Bucek ! Cheers!

Posted in Java, Java EE | Tagged , , , | Leave a comment