Writing a Custom WildFly Module: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 9: Line 9:
=Example=
=Example=


<blockquote style="background-color: AliceBlue; border: solid thin LightSteelBlue;">
{{External|https://github.com/NovaOrdis/playground/tree/master/jboss/wildfly/custom-module}}
:<br>https://github.com/NovaOrdis/playground/tree/master/wildfly/custom-module<br><br>
 
</blockquote>
=Naming Conventions=
 
==Module Name==
 
The module name is a dot-separated, fully qualified, unique, package name-like string. Conventionally, the name of the module coincides with the embedded top package, though nothing bad seems to happen it does not. Example: <tt>com.novaordis.playground.wildfly.custommodule</tt>.
 
==Module JAR Name==
 
Conventionally, it should be the condensed form of the module name, including the version string. Example <tt>custom-wildfly-module-1.0.jar</tt>.
 
==Module Location==
 
<pre>
$JBOSS_HOME/modules/com/novaordis/playground/wildfly/custommodule/<version>|main/
</pre>
 
=Process=
 
==Write Code and Package It According the Naming Conventions==
 
See [[#Naming_Conventions|Naming Conventions]] above.
 
==Copy the JAR under WildFly's module Directory==
 
See [[#Module_Location|Module Location]] above.
 
==Create a module.xml in the Same Module Directory==
 
The content of the <tt>module.xml</tt> should be similar to:
 
<pre>
<?xml version="1.0" encoding="UTF-8"?>
 
<module xmlns="urn:jboss:module:1.1" name="com.novaordis.playground.wildfly.custommodule" slot="1.0">
 
    <!--
    <main-class name="com.novaordis.playground.wildfly.custommodule.SharedFunctionality"/>
    -->
 
    <properties>
        <property name="some.property.name" value="some.property.value"/>
    </properties>
 
    <resources>
        <resource-root path="custom-wildfly-module-1.0.jar"/>
    </resources>
 
</module>
</pre>
 
==Module's Dependencies==
 
The module may have its own dependencies, which can be other JBoss modules, third party packages or JDK classes. Those must be declared as shown here: {{Internal|Module.xml#Module_Dependencies|Expressing Module Dependencies in module.xml}}
 
==Make the Module Dependents Aware==
 
In case of a web application, place a <tt>jboss-deployment-structure.xml</tt> similar to the example shown below under <tt>WEB-INF</tt>:
 
<pre>
<?xml version="1.0" encoding="UTF-8"?>
 
<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="com.novaordis.playground.wildfly.custommodule" slot="1.0"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>
</pre>
 
=Maven Infrastructure Required to Create a EAP Module as an Assembly=
 
Create the EAP module as artifact of a dedicated "eap-module" Maven module:
* [[Custom WildFly Module POM Example|eap-module pom.xml Example]]
* [[Custom WildFly Module Assembly Example|eap-module.xml assembly Example]]
* [[Custom WildFly Module module.xml Example|module.xml Example]]
 
=Deploying a Module with CLI=
 
{{Internal|WildFly CLI - Add a Module|Deploying a Module with CLI}}

Latest revision as of 20:37, 8 March 2017

External

Internal

Example

https://github.com/NovaOrdis/playground/tree/master/jboss/wildfly/custom-module

Naming Conventions

Module Name

The module name is a dot-separated, fully qualified, unique, package name-like string. Conventionally, the name of the module coincides with the embedded top package, though nothing bad seems to happen it does not. Example: com.novaordis.playground.wildfly.custommodule.

Module JAR Name

Conventionally, it should be the condensed form of the module name, including the version string. Example custom-wildfly-module-1.0.jar.

Module Location

$JBOSS_HOME/modules/com/novaordis/playground/wildfly/custommodule/<version>|main/

Process

Write Code and Package It According the Naming Conventions

See Naming Conventions above.

Copy the JAR under WildFly's module Directory

See Module Location above.

Create a module.xml in the Same Module Directory

The content of the module.xml should be similar to:

<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="com.novaordis.playground.wildfly.custommodule" slot="1.0">

    <!--
    <main-class name="com.novaordis.playground.wildfly.custommodule.SharedFunctionality"/>
    -->

    <properties>
        <property name="some.property.name" value="some.property.value"/>
    </properties>

    <resources>
        <resource-root path="custom-wildfly-module-1.0.jar"/>
    </resources>

</module>

Module's Dependencies

The module may have its own dependencies, which can be other JBoss modules, third party packages or JDK classes. Those must be declared as shown here:

Expressing Module Dependencies in module.xml

Make the Module Dependents Aware

In case of a web application, place a jboss-deployment-structure.xml similar to the example shown below under WEB-INF:

<?xml version="1.0" encoding="UTF-8"?>

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="com.novaordis.playground.wildfly.custommodule" slot="1.0"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

Maven Infrastructure Required to Create a EAP Module as an Assembly

Create the EAP module as artifact of a dedicated "eap-module" Maven module:

Deploying a Module with CLI

Deploying a Module with CLI