0

I tried to implement something like this

    @Path("foo")
public class Foo {

    @Context
    private BarContext barContext;

    @GET
    @Bar(name="foo")
    public String index() {
        barContext.name // output => foo
         ...
    }

}

But I have no idea if it is feasible or not someone can help me thank you

ghaziksibi
  • 471
  • 3
  • 12

1 Answers1

0

@Context can't inject arbitrary objects for you.

If you're looking for a general dependency injection library/framework, your JAX-RS implementation might come with one (for example, Jersey comes with HK2, a JSR-330 implementation). Or try Guice. Or Dagger.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710