users@jersey.java.net

[Jersey] Re: Using _at_Inject in Jersey

From: Ivan Li <email2liyang_at_gmail.com>
Date: Sun, 09 Mar 2014 12:17:13 +0800

should be bind( MyService.class ).to( MyServiceImpl.class );

right?

Best regards,
Ivan

On 3/9/14, 1:07 AM, Robert DiFalco wrote:
> Answering my own question here:
>
> Don't use register in RestConfig. Instead create an AbstractBinder
> with the service to inject.
>
> register( new AbstractBinder() {
> @Override
> protected void configure() {
> bind( MyServiceImpl.class ).to( MyService.class );
> }
> });
>
>
>
> On Fri, Mar 7, 2014 at 2:45 PM, Robert DiFalco
> <robert.difalco_at_gmail.com <mailto:robert.difalco_at_gmail.com>> wrote:
>
> How do I make a service available for injection with Jersey 2.6?
>
> I simply want to have something like:
>
> @Inject
> private MyService service;
>
> In a resource. I assumed in my configuration I could just do this:
>
> register( MyService.class );
>
> But apparently that doesn't work. What's the simplest way to make
> MyResource @Inject-able with MyService in 2.6?
>
> TIA!
>
> R.
>
>