users@jersey.java.net

Re: [Fwd: Re: Comment: Integrating Jersey and Spring: Take 2]

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 25 Mar 2008 12:07:34 +0100

On Mar 22, 2008, at 7:01 PM, Martin Grotzke wrote:
> I want to write/sum up several use cases / scenarios of
> IoC-DI/jersey-DI.

That would be very useful.


> To bring up one thing before: I could imagine that a
> bean would be injected into a method invocation and runtime
> dependencies
> are set within the method:
>
> @Path("{id}/")
> public UserResource getUser( @PathParam("id") final String username,
> @SpringBean UserResource result ) {
> final User user = _facade.getUserByUsername( username );
> result.setUser( user );
> return result;
> }
>
> The UserResource might then e.g. have a constructor with dependencies
> that are injected by spring, additionally contain fields that are
> injected by jersey, and the runtime-dependencies like that user are
> set
> within the method.
> With this approach the user would not have to cope with the
> ComponentProvider and scopes in his resources classes, so this
> would be
> the complement to returning just a class from a resource method.
>
> Of course the @SpringBean might be s.th. different, just to denote
> what
> is meant here :)
>
> What do you think of this?
>

A good use case. Somewhat similar to the constructor case for the
intermixing of method parameters. But since Jersey is responsible for
invoking the call maybe it is a little easier? e.g. asking the
ComponentProvider please get me an instance of this parameter because
i do not know what to do with it.

Paul.