Allow @PostConstruct annotation on Google Guice based app

admin

Administrator
Staff member
I'm starting my way with <a href="https://github.com/google/guice" rel="nofollow">google guice</a>.
Since guice does not support <a href="https://en.wikipedia.org/wiki/JSR_250" rel="nofollow">jsr-250</a> annotations out of the box I'm trying to bridge this gap. Specifically I'm interested on using <a href="https://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html" rel="nofollow">@PostConstruct</a> and <a href="http://docs.oracle.com/javaee/5/api/javax/annotation/PreDestroy.html" rel="nofollow">@PreDestroy</a> annotations.

<ul>
<li>I tried following <a href="https://code.google.com/p/guiceyfruit/wiki/Maven" rel="nofollow">guiceyfruit</a> as <a href="https://devsurf.wordpress.com/2010/...ctpredestroy-guicejndi-and-the-childinjector/" rel="nofollow">described here</a> with no success.</li>
<li>I tried <a href="http://code.mycila.com/guice/" rel="nofollow">mycila</a> support for JSR-250 with no success (see section 3, JSR-250):
Code:
injector = Guice.createInjector(Stage.PRODUCTION, new CloseableModule(), new Jsr250Module(), new MyModule());
Or using
Code:
Jsr250.newJsr250Module()
with no success.</li>
</ul>

Has anyone managed to use JSR-250 annotations in a guice based application and can show me how it is done?

Thanks