I have seen in some examples, like the Chat Application Showcase, or even in books ( like PrimeFaces Blueprints ), that it should be possible to inject the ServletContext, or the HttpServletRequest, in a PrimeFaces Java Class annotated with @PushEndpoint.
Just like this:
Code: Select all
@PushEndpoint("/{room}/{user}")
@Singleton
public class ChatResource {
...
@Inject
private ServletContext ctx;
...
}
Code: Select all
@OnClose
public void onClose(RemoteEndpoint r, EventBus eventBus) {
ChatUsers users= (ChatUsers) ctx.getAttribute("chatUsers");
...
The Java class is located in a WAR file ( so the ServletContext should be available ).
I am using WildFly 8.2.0.Final.
The problem happens with both PF 5.1 + Atmosphere 2.2.6 , or PF 5.2 + Atmosphere 2.3.0
Does anyone know how can the ServletContext be injected in a @PushEndpoint annotated class ??
At the end, what I want is to access a parameter in the Request that contains an Apache Shiro subject, injected by the Atmosphere ShiroInterceptor.
Thanks a lot in advance !!
Miguel Cubells