Hi James,
So would something like the following work for you:
def getElement(@<I do not know what to call this!> subResource:
Element) = { ... }
?
That would be really easy to support because we can write an
InjectableProvider that defers to ResourceContext. I can even send one
in the email in addition to adding it to the workspace so that one can
use it with a stable version.
But as you can tell i am having a naming problem :-) any suggestions?
Paul.
On Jun 30, 2010, at 4:23 PM, James Strachan wrote:
> On 20 April 2010 15:01, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>> Hi James,
>>
>> There are currently two ways for the application to instantiate
>> resource
>> classes:
>>
>> 1) Injected @Context ReosurceContext rc then call
>> rc.getResource(MyClass.class);
>>
>>
>> https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ResourceContext.html
>>
>> def getElement(@PathParam("id") key : String, @Context
>> ReosurceContext rc)
>> {
>> doSomething;
>> val e = rc.get(classOf[Element]);
>> e.setKey(e);
>> return e;
>> }
>>
>> 2) Using Jersey's @Inject (i know it is an unfortunate clash with
>> 330).
>>
>> def getElement(@PathParam("id") key : String, @Inject
>> Injectable<Element>
>> ie) {
>> doSomething;
>> val e = ie.get();
>> e.setKey(e);
>> return e;
>> }
>>
>> None are quite what you want :-)
>>
>> Injecting after instantiation sort of breaks the life-cycle contract
>> (injection onto fields or setter methods should occur after
>> construction and
>> before any post construct method is invoked).
>
> A colleague hit this again today so I was wondering if we could come
> up with a clean canonical way to get Jersey create sub resources for
> us doing all the lifecycle/injection goodness without using the
> ResourceContext/Injectable API?
>
> e.g. something like...
>
> class Container extends Foo {
> @GET
> @Path("{id}")
> def getElement(subResource: Element) = {
> // possibly modify the object we are given, or return something
> else...
> subResource
> }
> ...
> }
>
> class Element(@PathParam("id") key: String) extends Foo {
> @GET
> def index = {
> ...
> }
> ...
> }
>
> We might want to annotation the getElement's subResource parameter
> somehow to indicate to Jersey its meant to inject a sub resource into
> the method call?
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>