Maven and Spring
Maven modules
<groupId>org.openhubframework</groupId> <artifactId>openhub</artifactId>
OpenHub framework consists of the following Maven modules:
- common: module contains useful functions for other modules
- core-api: user API for writing new routes with OpenHub framework
- core-spi: interface for internal use in OpenHub framework components
- core: basic implementation module
- test: module with basic configuration and parent classes for tests
- components: OpenHub framework components
- examples: examples how to use OpenHub framework
- web-admin: admin GUI web application
<dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-common</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-core-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-core-spi</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-components</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-test</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub-examples</artifactId> <version>${project.version}</version> </dependency>
OpenHub framework depends on several Camel components and if you want to use another Camel component with same Camel's version then you can do it:
import dependencies from OpenHub framework
<dependency> <groupId>org.openhubframework</groupId> <artifactId>openhub</artifactId> <version>${openhub-version}</version> <scope>import</scope> <type>pom</type> </dependency>
use specific component which you want
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-crypto</artifactId> </dependency>
Spring contexts
OpenHub framework uses and is configured by Spring framework.
There are the following Spring contexts hierarchy from the web application (=admin GUI) point of view:
- root application context; Apache Camel, database and security (Spring security) is initialized in this context
- spring-ws: Spring Web Services context
- spring-admin-mvc: Spring Web MVC context
Spring profiles
OpenHub framework uses Spring profiles to simplify configuration for different target environments:
- dev (default): profile for development environment; this profile has disabled several functions which are enabled in production, e.g. scheduled tasks for asynchronous messages
- prod: profile for testing and production environment
Next Spring profiles are used for switching between databases (more in configuration file META-INF/sp_dataSources.xml)
- h2 (default): database H2 in embedded in-memory mode, more information in chapter about H2 database
- postgreSql: profile for PostgreSQL database
Defaults Spring profiles are set in web.xml, it's possible to override them by system parameter spring.profiles.active:
<context-param> <param-name>spring.profiles.default</param-name> <param-value>dev,h2</param-value> </context-param>
Spring configuration for tests
Maven profiles
There are also Maven profiles which correspond to Spring profiles. Maven profiles solve dependency to third-party libraries for specific target environment and settings of folders, logs etc. See pom.xml in module sc-web-admin.
- esb.dev
- esb.prod
- esb.psSqlb - profile for PostgreSQL database
- esb.psSql.prod - profile for PostgreSQL database but PostgreSQL libraries are "provided"
OpenHub framework compilation with Maven for local use (=dev) with PostgreSQL database:
mvn clean && mvn -DskipTests -Pesb.psSql package
Application server starts with the following system parameter spring.profiles.active:
postgreSql,dev