-
1. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
lightguard Apr 16, 2012 4:15 PM (in response to johnz2012)Do you have a producer for your EntityManager?
-
2. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
johnz2012 Apr 17, 2012 5:14 PM (in response to lightguard)Well, I think so. Just to be sure: You mean the factory which generates the instance, don't you?
-
3. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
serkan Apr 18, 2012 10:28 AM (in response to johnz2012)I think the @Provider gets executed before Seam's BijectionFilter, that's why the EntityManager is null.
What exactly are you trying do ?
Personaly, I don't think it's a good way to use the EntityManager inside a Rest Provider class. The provider should handle the (un-)marshalling and pass the result to the next filter/component in the chain (which then should handle the authentication logic).
-
4. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
johnz2012 Apr 19, 2012 3:20 PM (in response to serkan)Yeah, this might be the cause. How would you implement an authentication method using an existing Seam entity and RESTEasy?
I'd like to use signed and stateless requests. E.g.:
GET /seam/resource/rest/service/foobar HTTP/1.1 Host: foobar.com Authorization: API [SHA512-hashed request]
The hash is calculated from a concatenation of the username, the query and a secret key.
How would you implement such an authentication procedure?
-
5. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
serkan Apr 20, 2012 6:04 AM (in response to johnz2012)Did you try calling Lifecyle.begin() and Lifecyle.end() in your method (in the preprocessor) ?
Between these methods you should be able to lookup for the EntityManager as follows:
EntityManager em = (EntityManager) Component.getInstance("entityManager");
-
6. Re: Use EntityManager in a RESTEasy PreProcessInterceptor
johnz2012 Apr 26, 2012 12:25 PM (in response to serkan)Thank you very much!
Calling
Lifecycle.begin()
solved the issue.