On Dec 4, 2009, at 6:52 PM, Comerford, Sean wrote:
> Ahhh, GF v3!
>
> I did see that example and couldn't figure out why I couldn't seem
> to get
> that working.
>
> But I was using 2.1.1 and thought maybe the Jersey adaptor servlet
> had some
> magic in it that made the injectable stuff work but it sounds like
> EE 6 is
> the "magic".
>
> Thanks Pavel... I'll switch to v3 and try this.
>
OK!
Just to answer your original question. You can inject:
@Context CloseableService cs; [1]
then add instances of Closeable to that.
An alternative is to add properties to the HttpServletRequest and then
register a ServletRequestListener [2] in the web.xml that cleans up on
ServletRequestListener.requestDestroyed.
Paul.
[1]
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/CloseableService.html
[2]
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequestListener.html
> On 12/4/09 12:27 PM, "Pavel Bucek" <Pavel.Bucek_at_Sun.COM> wrote:
>
>> 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-S
>> NAPSHOT/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
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
> --
> Sean Comerford, Software Engineer
> ESPN.com Site Architecture Group
> Office: 860.766.6454 Cell: 860.329.5842
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>