1

I'm starting my way with google guice. Since guice does not support jsr-250 annotations out of the box I'm trying to bridge this gap. Specifically I'm interested on using @PostConstruct and @PreDestroy annotations.

  • I tried following guiceyfruit as described here with no success.
  • I tried mycila support for JSR-250 with no success (see section 3, JSR-250): injector = Guice.createInjector(Stage.PRODUCTION, new CloseableModule(), new Jsr250Module(), new MyModule()); Or using Jsr250.newJsr250Module() with no success.

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

Thanks

forhas
  • 11,551
  • 21
  • 77
  • 111
  • https://github.com/google/guice/issues/62#issuecomment-115452493 maybe this will help – Adam Siemion Nov 09 '15 at 10:55
  • 1
    I did my own simple implementation for this https://github.com/xvik/guice-ext-annotations (using TypeListener instead of ProvisionListener). But you should understand that guice philosophy is different from spring and if you follow it you should avoid implicit behaviour (see https://github.com/google/guice/wiki/ModulesShouldBeFastAndSideEffectFree). – xvik Nov 09 '15 at 22:00
  • I guess I can make it work using shutdown hooks as described here: http://hellotojavaworld.blogspot.co.il/2010/11/runtimeaddshutdownhook.html – forhas Nov 10 '15 at 08:43
  • 1
    I made good experiences with mycilla, worked out of the box. Could you post your code? Maybe you did st wrong ... – Jan Galinski Nov 10 '15 at 19:29

0 Answers0