users@jersey.java.net

Re: [Jersey] _at_Inject Annotation can inject to Java Interfact type variable?

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Mon, 6 Sep 2010 11:36:41 +0200

Hi,

Unfortunately Jersey's @Inject (renamed to @InjectParam for 1.4) only
works for concrete classes. It's just offers very simple behavior for
developers who don't want/need to use a DI framework, such as Guice,
that offers a fully feature binding API that can support what you
require.

See Jersey's Guice support for more details:

   https://jersey.dev.java.net/nonav/apidocs/latest/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html

Paul.

On Sep 5, 2010, at 4:57 AM, kota wrote:

>
> Jersey 1.1.5.1
>
> Hi,everybody
>
> I have a trouble with @Inject(com.sun.jersey.spi.inject.Inject)
> Annotation.
> (I use Jersey 1.1.5.1)
>
> Acctually, I can inject the instance of GreetingImpl class to
> "greeting" by
> using @Inject like this.
>
> @Inject
> private GreetingImpl greeting;
>
> but I can't inject like below and gets error messages "unable to
> create
> instance "
>
> @Inject
> private Greeting greeting;
>
> @Inject Annotation can inject the instance for Java Interface type
> variable?
>
> if can do, how inject? any hint please.
>
> public interface Greeting {
>
> public String sayHello();
> }
>
> public class GreetingImpl implements Greeting {
>
> public String sayHello() {
> return "Hello,Jersey!";
> }
> }
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Inject-Annotation-can-inject-to-Java-Interfact-type-variable-tp5499697p5499697.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>