users@jsr311.java.net

Re: Sub-Resource Locators

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 31 Jul 2008 13:36:56 -0400

On Jul 31, 2008, at 1:30 PM, Craig McClanahan wrote:

> Paul Sandoz wrote:
>> Sergey Beryozkin wrote:
>>> Hi
>>>
>>> My understanding is that you can get @Context values injected as
>>> method parameters
>>> of subresource locator resource methods
>>>
>>
>> Correct. Although a disadvantage is that the UriInfo parameter may
>> get "sprinkled" over many methods,
>>
>> I have been experimenting with three implementation specific things
>> in this respect.
>>
>> 1) returning a Class from the sub-locator;
> This is Jersey-specific currently, right? Is it planned to include
> this in the spec as well?
>
We haven't discussed that, I'm not opposed to it.

> Alas, it doesn't help in my specific use case, because it's my own
> application code calling the sub-resource locator (not the JAX-RS
> runtime). I suppose that means I should really isolate my shared
> application logic that's in the sub-resource class, but then I need
> to be able to inject *that* into all the places it is needed.
>
> That sounds like the job for an IoC framework of some sort ... but
> I'd rather not force a particular choice in (what amounts to)
> framework level code.
>
>>
>> 2) Injecting a ResourceContext that can be used to get an instance
>> of a
>> resource class from which it can be modified and then returned from
>> the sub-locator; and
>>
> That would work for me if it was portable across JAX-RS
> implementations (i.e. part of the spec).

Injection of instances returned from a locator is problematic because
the runtime doesn't know or control the lifecycle of the instance. Its
a tough problem to crack without a unified IoC framework to handle
creation and injection but we don't want to tackle that in this JSR,
that's a job for WebBeans.

Marc.

>
>> 3) See a discussion in the comments on a blog entry i wrote [1].
>>
>> Paul.
>>
> Craig
>
>> [1]
>> http://blogs.sun.com/sandoz/entry/ejb_injection#comment-1217426760000
>> http://blogs.sun.com/sandoz/entry/ejb_injection#comments
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.