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?
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?