Just adding a little more to this - in my opinion there should definitely be support for the session scope during the processing of a websockets message (as the WebSockets API is session-based). Currently trying to access a session-scoped bean results in the following exception:
15:07:05,825 ERROR [stderr] (default task-53) Caused by: org.jboss.weld.context.ContextNotActiveException:
WELD-001303
: No active contexts for scope type javax.enterprise.context.SessionScoped 15:07:05,825 ERROR [stderr] (default task-53) at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:680) 15:07:05,825 ERROR [stderr] (default task-53) at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:79) 15:07:05,826 ERROR [stderr] (default task-53) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:78)
I'm not convinced there should be an active request scope while processing a message as a websockets connection is persistent and the communications are asynchronous, i.e. there is no request/response lifecycle analogous to what is provided by the servlet spec's request-based API. The websockets Session class (javax.websocket.Session) on the other hand is uniquely identifiable and IMHO provides an equivalent purpose as the servlet HttpSession.
|