Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created February 14, 2017 03:53
Show Gist options
  • Select an option

  • Save abhirockzz/3503a8a38c986598e13cc4d44970008f to your computer and use it in GitHub Desktop.

Select an option

Save abhirockzz/3503a8a38c986598e13cc4d44970008f to your computer and use it in GitHub Desktop.
Stateful EJB In WebSocket (2/2)
@Stateful
public class ClientChatState {
...
@Remove
public void dispose(){
//this can just be a marker method
}
@PreDestroy
public void closeResources(){
//close connections, resources etc.
}
}
@ServerEndpoint("/letschat/{login-id}")
public class ChatEndpoint {
....
@OnClose
public void disconnected(Session session) {
ccs.dispose(); //method annotated with @Remove
}
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment