0

Pardon my language if question is not clear. I want to use JSR 330 annotations. And I want to be able switch my DI provider. At present my application has to to know at some point that it has to use spring or google-guice. Is there any way I can avoid this.

Right now I've to call :

ApplicationContext ctx = new AnnotationConfigApplicationContext(
    "com.package1", "com.package2");

to get the app context to get the beans. My understanding is that for google-guice i'll have use google-guice specific code.

Is my understanding correct or I totally missed something.

  • You indeed need bootstrapping code. Switching the DI container would consist in changing this bootstrapping code, which is just one or two lines. And you'll probably never do it anyway. – JB Nizet May 03 '13 at 22:15
  • What is your container and packaging. There are many ways to load the application context without writing code – fpmoles May 04 '13 at 00:21
  • Thank you for your answers. @Moles I wanted to avoid ApplicationContext entirely as it is spring based. – user2225138 May 05 '13 at 14:44
  • Okay, you should always be able to do that, but what is your packaging so I can help you do that. Are you building a war for instance, or just an executable jar? – fpmoles May 06 '13 at 13:35

0 Answers0