Plug-in Architecture
Plug-in Architecture
Elastic Path Core Commerce uses a lightweight plug-in architecture based on Spring functionality. This architecture allows you to create plug-ins that work with existing Core Commerce modules, without needing to make any changes to the core application code or configuration files.
The Spring contexts of Elastic Path applications use wildcards to include Spring configuration files from well-known classpath locations. There are two patterns:
The first pattern is for the plug-ins to be included from an extensions module. For example, the elastic-path-servlet.xml file in the extensions/integration module contains:
<import resource="classpath*:META-INF/elasticpath/conf/spring/plugin.xml"/commerce-legacy/> <import resource="classpath*:META-INF/conf/ep-core-plugin.xml"/commerce-legacy/>
The second pattern is for the extensions to be included from a commerce-engine module. For example the import-export-context.xml file in the ep-importexport module contains:
<import resource="classpath*:META-INF/conf/ep-core-plugin.xml"/commerce-legacy/> <import resource="classpath*:META-INF/conf/ep-importexport-plugin.xml" />
These statements cause the application to examine all JARs on the classpath and automatically include any copies of these files.
There are three separate plug-in conventions in these examples:
- <import resource="classpath*:META-INF/elasticpath/conf/spring/plugin.xml> is used to automatically import Spring configuration from any JAR on the classpath with a plugin.xml file in META-INF/conf/ep-core-plugin.xml. Modules that declare Spring configuration in this location must not rely on any specific order in which their plugin.xml file is processed. Examples of modules that use this convention are the ep-messaging-camel module, and most Accelerator Kit modules.
- <import resource="classpath*:META-INF/conf/ep-core-plugin.xml> is used to import the ext-core module's configuration into other extensions modules. The import should always be done after the generic plugin.xml imports to allow overriding generic plugin.xml configuration in ext-core.
- <import resource="classpath*:META-INF/conf/ep-importexport-plugin.xml> is defined in ep-import-export to create an extension point that is implemented by the ep-importexport-plugin.xml file in the ext-importexport extension module.