Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSR-330 support in Guice

The SVN version of Guice supports JSR-330 annotations ("JSR-330 Integration - This documents an experimental, unreleased feature available in Guice SVN only"). Google gives the advise: "For now, stick with Guice's annotations and Provider interface." Guice 2 is a year old now and I wonder if there will be JSR-330 support in the near future. Does anyone know?

like image 339
deamon Avatar asked Nov 26 '25 21:11

deamon


1 Answers

If you're comfortable using code from SVN, use that and the JSR-330 annotations. If you'd rather rely on a published release, use Guice's own annotations. Also, JSR-330 doesn't support optional injection.

Note that there's a tiny behaviour change with Guice post-2.0 to cope with the new @Inject annotation.

  • In Guice 2.0 and earlier: Methods not-annotated with @Inject are injected, if they override a method that does have that annotation.
  • After Guice 2.0: Guice not inject such methods. You need to reapply the annotation on every override.

We don't have a release date scheduled for Guice 2.1.

like image 159
Jesse Wilson Avatar answered Nov 28 '25 10:11

Jesse Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!