On Mar 9, 2009, at 12:43 AM, Jaka JanĨar wrote:
> Hi!
>
> This is a JAX-RS question more than a Jersey question, really.
>
> I want to use a JPA application-managed (=not container-managed)
> entity manager with resource-local (=not JTA) transactions. (coming
> from PHP, it took me a better part of a day to figure that out :P)
>
:-)
> Because of this, I need to:
> - perform some one-time intialization (build an EntityManagerFactory)
> - put the try{start;service;commit}catch{rollback} code somewhere.
>
> What is the appropriate place to do this when using JAX-RS?
>
There are no hooks defined in JAX-RS itself to do Web application
initialization, per and post dispatching.
Perhaps you can write a ServletFilter? to do pre/post processing
before and after invocation on the Servlet?
Paul.
> Of course, I could just override
> com.sun.jersey.spi.container.servlet.ServletContainer's init() and
> service() methods, but that is:
> - not portable to other JAX-RS implementations (RESTEasy)
> - not portable to JAX-RS aware containers.
>
> So the question is how to do this *within* JAX-RS, not outside of it?
>
> Thanks,
> Jaka
>
> P.S: Why is com.sun.jersey.spi.container.servlet.ServletContainer
> called a server *container*, when in fact it is a servlet? (server
> containers are Jetty, Tomcat, etc.) Or am I missing something here?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>