Dynamic extension loading


Dynamic extensions loading allows to add selected extension to OpenHub application independently by each other.

There is extensions.cfg configuration file (in web-admin module by default) with extension configuration parameters. 

 

If you want to add one specific extension to OpenHub application then follow the following steps:

0) Prerequisite - extension configuration loader must be initialized

/**
 * OpenHub extensions loader where extensions are defined in properties.
 * Relevant properties are with '{@value #PROPERTY_PREFIX}' prefix.
 */
@Service
@DependsOn("camelContext")
public class PropertiesExtensionConfigurationLoader extends AbstractExtensionConfigurationLoader {

1) add Maven dependency to specific extension

For example add dependency to File upload extension:

<groupId>org.openhubframework.ext</groupId>
<artifactId>file-upload</artifactId>

2) add Spring configuration of specific extension

extensions.cfg (defined directly in OpenHub framework web-admin module) defines references to Spring root configuration files for each extension. Each property has to starts with context.ext prefix.

Example:

context.ext1 = classpath:/META-INF/sp_ext_fileupload.xml

sp_ext_fileupload.xml file can contain "unlimited" another Spring configurations specific for File upload extension, imports other configurations for the extension, choose between XML, annotation or Java config style etc.

 

For each item in the previous configuration file is new Spring child context created. This context is child context of Spring Camel (Web Service) context.

Child Spring context is type of ClassPathXmlApplicationContext

See PropertiesExtensionConfigurationLoader for more details.

 

There is the following Spring context hierarchy:

  • root context - Camel (Spring Web Service) context + Spring MVC (admin) context
    • extension1 context
    • extension2 context