NOTE: The Guice Integration does not have dependencies on other parts of Soabase and, so, can be used independently if needed.
The Guice Integration includes:
The GuiceBundle integrates the Guice/HK2 Bridge so that objects bound via Guice are available to your Jersey 2.0 resources.
The JerseyGuiceModule adds most of the functionality of Guice's ServletModule and JerseyServletModule. All registrations are forwarded to the appropriate Dropwizard/Jersey/Jetty methods.
The following features from Guice's ServletModule and the JerseyServletModule are supported/emulated:
The Guice Integration is available from Maven Central. Use any dependency tool (e.g. Maven or Gradle) to add the artifact to your application's project:
io.soabase:soabase-guice
Add the GuiceBundle to your application. Its constructor takes an InjectorProvider that returns the Guice Injector to use. Any objects that are part of the Injector will be available to your Jersey resources. Additionally, any bound Jersey Providers will be registered via Dropwizard.
InjectorProvider injectorProvider = ... bootstrap.addBundle(new GuiceBundle<>(injectorProvider));
The JerseyGuiceModule is used exactly as Guice's ServletModule and JerseyServletModule. Add the module to your injector and override the configureServlets() method. Guice's ServletModule documentation applies to JerseyGuiceModule. Additionally, any objects registered via SoaFeatures and the SoaFeatures instance itself are bound into the Guice injector.
Example code for using the Guice integration is here: Soabase Guice Example