Non-Plugin Module
Adding Non-Plugin Modules to Commerce Manager
If you have created a new Commerce Engine Extension jar module (e.g. ext-settings
), or you have introduced a new third-party dependency (e.g. org.apache.commons:commons-text
), you will likely need to add this module to the Commerce Manager, particularly if the module is a dependency of ext-core
.
ext-cm-libs
Understanding New non-plugin modules can be made available to the Commerce Manager by embedding them within the com.elasticpath.extensions.cm.ext-cm-libs
project. ext-cm-libs
is a project which bundles together all extension libraries that must be deployed within Commerce Manager via an OSGi manifest. It also acts as a wrapper for libraries that are non-OSGi bundles, making their contents available to the OSGi container.
ext-cm-libs
Adding modules to To add modules to com.elasticpath.extensions.cm.ext-cm-libs
, modify the extensions/cm/ext-cm-libs/pom.xml
file and add your module to the <dependencies>
section:
<dependencies>
<!-- existing dependencies -->
<dependency>
<groupId>the.group.id</groupId>
<artifactId>your-artifact-id-here</artifactId>
</dependency>
</dependencies>
To ensure that the module is included within the com.elasticpath.extensions.cm.ext-cm-libs
bundle, add its artifact ID to the EmbedDependency
entry within the maven-bundle-plugin
configuration.
<Embed-Dependency>ext-core,ep-your-artifact-id-here</Embed-Dependency>
Exposing non-OSGi Classes to OSGi Bundles
If your module is a non-OSGi module, it’s like that it provides classes that need to be accessed by other bundles, perhaps to assign or instantiate a variable, in an instanceof
condition, or in a catch
block. In this case it must be exported from the com.elasticpath.extensions.cm.ext-cm-libs
module.
OSGi bundles only provide access to packages that are explicitly exported - if a class in a non-exported package is attempted to be loaded by another bundle, it will cause a ClassNotFoundException
or NoClassDefFoundError
.
A key role of the com.elasticpath.extensions.cm.ext-cm-libs
project is to allow non-OSGi modules to participate in an OSGi container. Part of its responsibility is to export the required packages on the embedded modules’ behalf.
Add the required packages to the maven-bundle-plugin
configuration in the extensions/cm/ext-cm-libs/pom.xml
file:
<_exportcontents>
org.some.package.to.export,
org.some.other.package.to.export,
com.elasticpath.extensions.*
</_exportcontents>
The nature of OSGi applications tends to make the previous step iterative; exporting one package reveals another that is also required. Add your dependency, as well as any other dependancies required.