Guice Dependency Injection

Guice dependency injection may be used with by using the restli-guice-bridge module.

An example project using guice dependency injection is available in the codebase:

This example shows how’s GuiceRestliServlet may be used to run servers with full guice dependency injection.

To use it, first add a dependency to the restli-guice-bridge module, for example:

dependencies {
  compile "com.linkedin.pegasus:restli-guice-bridge:1.9.23"

Next, set up a guice servlet, defining a guice GuiceServletContextListener for your application. For an example, see /examples/guice-server/server/src/main/java/com/example/fortune/inject/

Lastly, configure your web.xml. For an example, see /examples/guice-server/server/src/main/webapp/WEB-INF/web.xml