-
1. Re: Access to session in RPC methods
cbrock Jun 11, 2010 11:57 AM (in response to alexmd)Yes.
QueueSession session = Message.getResource(QueueSession.class, "Session");
-
2. Re: Access to session in RPC methods
alexmd Jun 11, 2010 5:13 PM (in response to cbrock)Hello Christopher,
thank you for your answer. Unfortunately, this doesn't work because the getResource() method can be invoked only for an instance of Message. It's not a static method (in Errai 1.1.0.M1 that I use). My problem is: I don't know how to get the (valid and corresponding) Message instance in an RPC method on the server side. In a service class that inherits MessageCallback I get a reference to the Message instance as parameter in the callback. But my RPC service is a standalone class that inherits nothing and implements my RPC interface only. I searched for a solution in documentation and examples. Maybe I missed something...
Best regards,
Alexander.
-
3. Re: Access to session in RPC methods
cbrock Jun 11, 2010 8:41 PM (in response to alexmd)Yeah, I answered your question a little bit too hastily there. The truth is there's really no way to do it out of the box with RPC calls. The only really reliable way to hack it, would be to use a modified DefautlBlockingServlet which holds a copy of the session in a ThreadLocal and use SimpleDispatcher implementations to prevent any off-thread processing.
But this is definitely something we should consider adding support for.
-
4. Re: Access to session in RPC methods
misqu23 Sep 25, 2010 2:08 PM (in response to cbrock)If you are using errai-cdi you can inject HttpSession object (maybe you do not need queuesession) into the rpc service.
-
5. Re: Access to session in RPC methods
alexmd Sep 27, 2012 12:53 PM (in response to misqu23)For the sake of completeness: In Errai 2 there is the RpcContext class which provides access to the HttpSession and ServletRequest.