users@jersey.java.net

Re: [Jersey] Injectable providers

From: Pavel Bucek <Pavel.Bucek_at_Sun.COM>
Date: Fri, 04 Dec 2009 18:27:04 +0100

Hi Sean,

take a look at bookmark-em sample:
https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/samples/bookmark-em/
or
http://download.java.net/maven/2/com/sun/jersey/samples/bookmark-em/1.1.5-ea-SNAPSHOT/bookmark-em-1.1.5-ea-SNAPSHOT-gf-project.zip

With latest Jersey and recent GFv3 build is possible to inject
EntityManager to Managed bean, so you can have something like:

@Path("/users/")
@ManagedBean
public class UsersResource {

// injected EntityManager property
@PersistenceContext(unitName="BookmarkPU")
private EntityManager em;
...
}

Regards,
Pavel

Comerford, Sean wrote:
> After getting side tracked for awhile, I’m starting to look heavily at
> Jersey again.
>
> Awhile back I had asked about having JPA EntityManager’s injected into
> my resources.
>
> Paul explained that this sort of thing wouldn’t be available until
> Java EE 6 time frame but that one potential interim solution was to
> use Jerey’s CloseableService.
>
> Can Paul or anyone else point me to more information on this?
>
> Currently I’ve more or less rigged up my on framework (and I use that
> term loosely here :-) for injecting the em or emf into my resources
> but am looking for a more standardized method.
>
> Would like to avoid introducing Spring - too many frameworks we don’t
> currently use in the mix already plus it seems like overkill for what
> I’m looking to do :-)
>
> --
> Sean Comerford, Software Engineer
> ESPN.com Site Architecture Group
> Office: 860.766.6454 Cell: 860.329.5842