Plugins are loaded into Elastic Path Commerce services in two circumstances:
- At startup, where the plugin folder is scanned and all plugins in that folder are loaded and started automatically.
- From a running instance on-demand, using JMX, plugins can be loaded and started.
In both of these circumstances, the plugin class is instantiated right away, and the constructor is invoked.
Plugins are also unloaded from Elastic Path Commerce services in two circumstances:
- When the service is terminated.
- From a running instance on-demand using JMX.
The lifecycle for extensions is the same regardless of whether the extension comes from a plugin or is embedded into the platform source.
Extension classes are singletons; they are intialized the first time they are needed and reused for each method invocation. If there is no
extensions.json entry for the extension class, then only a single instance of that class is created. For each separate entry in
extensions.json for the same extension class, a separate instance is created. This ensures that each extension class can be aware of different setting values, and can lazy initialize functionality based on those settings if necessary.
Extension classes are released from memory in two circumstances; When the service is terminated or if the extension belongs to a plugin unloaded from a running instance on-demand using JMX.