0

As I see, I can use autosearch annotation @Service to create singleton to use that via @Inject. Like:

@Service
class MyService {
    //.....
}

@Service
class MyOtherService {
    @Inject MyService myService;
    //.....
}

But would like to create Service using options that depends on environment. I could do that using AbstractBinder like:

        final ResourceConfig resourceConfig = new ResourceConfig()
            .register(new AbstractBinder() {
                @Override
                protected void configure() {
                    String someOption = "optionOne";
                    String anotherOption = "optionTwo";
                    MyService myService = new MyService.create(someOption, anotherOption);
                    bind(MyService).to(MyService.class).in(Singleton.class);
                }
            })

But how can I do just the same but using annotation autoconfig style? Without creating AbstractBinder object.

Aleksey Kozel
  • 319
  • 1
  • 9
  • 16

0 Answers0