Skip to main content

[jsr356-experts] Instances and lifecycles for annotated endpoints

  • From: Scott Ferguson < >
  • To:
  • Subject: [jsr356-experts] Instances and lifecycles for annotated endpoints
  • Date: Fri, 26 Oct 2012 19:13:55 -0700

http://java.net/jira/browse/WEBSOCKET_SPEC-21
http://java.net/jira/browse/WEBSOCKET_SPEC-37

This is an important issue.

In particular, the @WebSocketMessage methods really want to operate on beans that are scoped to the connection/session (using the standard @PostConstruct, @PreDestroy for lifecycle.) They're basically MessageHandlers, not endpoints, and should have the same lifecycle as MessageHandlers.

The @WebSocketOpen could be scoped to the application (as current, i.e. as Endpoint), but it might be cleaner to change it as well to be called on a new instance for each request (as if MessageHandler), to avoid recreating the old home/instance EJB model. Either way would be logical, but having a single lifecycle in the spec would be simpler to define/explain.

So I'd suggest the cleanest change would be to instantiate a new instance for each connection/session.

(Also, I assume each onMessage is in a new CDI RequestScope (?))

(Also, the 7.3.2 CDI injection into MessageHandlers doesn't make sense to me. In the current API, the developer instantiates the handler and therefore it would be weird for CDI to inject anything.)

-- Scott



[jsr356-experts] Post EDR: Back to work

Danny Coward 10/25/2012

[jsr356-experts] Instances and lifecycles for annotated endpoints

Scott Ferguson 10/27/2012

[jsr356-experts] Re: [jsr356-users] Instances and lifecycles for annotated endpoints

Jitendra Kotamraju 10/29/2012

[jsr356-experts] Re: Instances and lifecycles for annotated endpoints

Danny Coward 10/29/2012

[jsr356-experts] Re: [jsr356-users] Re: Instances and lifecycles for annotated endpoints

Scott Ferguson 10/29/2012

[jsr356-experts] Re: [jsr356-users] Re: Re: Instances and lifecycles for annotated endpoints

Danny Coward 10/29/2012
 
 
Close
loading
Please Confirm
Close