Skip to content

Using Pinject as a JBoss Module

Michael Irwin edited this page Jan 24, 2018 · 4 revisions

If you plan to deploy your applications in Wildfly or the JBoss EAP, you can install Pinject as a module in the container, making it available to all application deployments.

Installing Pinject as a Module

Obtain the modules distribution for Pinject. You can get it from Maven Central or you can build Pinject yourself and get it from pinject-modules/target directory after the build.

Extract the modules distribution into the base directory of your Wildfly/JBoss installation. It will extract as modules/org/soulwing/pinject.

Using Pinject as a Module

In your application's dependencies, you need only the pinject-api dependency. If using Maven, the following is all you need. Note that the scope here is provided so that the JAR for the API will be excluded from the final artifact when your application is built -- it will be provided by the module at runtime.

<dependency>
  <groupId>org.soulwing</groupId>
  <artifactId>pinject-api</artifactId>
  <version>VERSION NUMBER HERE</version>
  <scope>provided</scope>
</dependency>

In your application's WEB-INF directory, you need a jboss-deployment-structure.xml that declares your runtime dependency on Pinject.

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="org.soulwing.pinject" services="import"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>