WildFly Modular Service Container Programmatic Access: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * WildFly Modular Service Container =Maven= <pre> <dependency> <groupId>org.jboss.msc</groupId>...")
 
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


* [[WildFly Modular Service Container#Programmatic_Access|WildFly Modular Service Container]]
* [[WildFly Modular Service Container#Programmatic_Access|WildFly Modular Service Container]]
=Code=
{{External|https://github.com/NovaOrdis/playground/tree/master/jboss/wildfly/msc-programmatic-access}}


=Maven=
=Maven=
Line 31: Line 35:


will return null.
will return null.
For the code to work, the following module dependency must be added to the module.xml or jboss-deployment-structure.xml of the deployment artifact:
<pre>
<dependencies>
    <module name="org.jboss.as.server"/>
</dependencies>
</pre>

Latest revision as of 21:42, 1 March 2017

Internal

Code

https://github.com/NovaOrdis/playground/tree/master/jboss/wildfly/msc-programmatic-access

Maven

<dependency>
    <groupId>org.jboss.msc</groupId>
    <artifactId>jboss-msc</artifactId>
    <version>1.1.6.Final-redhat-1</version>
</dependency>

The following is needed for org.jboss.as.server.CurrentServiceContainer:

<dependency>
    <groupId>org.jboss.as</groupId>
    <artifactId>jboss-as-server</artifactId>
    <version>7.5.9.Final-redhat-2</version>
    <scope>provided</scope>
</dependency>

It is particularly important to declare the org.jboss.as.jboss-as-server dependency as provided, and to use the classes deployed within the WildFly instance, because otherwise

ServiceContainer sc = CurrentServiceContainer.getServiceContainer();

will return null.

For the code to work, the following module dependency must be added to the module.xml or jboss-deployment-structure.xml of the deployment artifact:

<dependencies>
    <module name="org.jboss.as.server"/>
</dependencies>