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: module with core functionality, implements API and SPI interfaces 
  • test: module with basic configuration and parent classes for unit tests
  • components: OpenHub framework components
  • examples: examples how to use OpenHub framework
  • web: configures OpenHub as web application, "backend" for admin-console client with REST interface implementation
  • admin-console: admin GUI client written in React
  • war: WAR build

See Reference implementation how to use dependencies in a specific project.


			<dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-common</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-core-api</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-core-spi</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-core</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-components</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-test</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-examples</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-admin-console</artifactId>
            </dependency>
            <dependency>
                <groupId>org.openhubframework</groupId>
                <artifactId>openhub-war</artifactId>
            </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:

  1. import dependencies from OpenHub framework

    <dependency>
     <groupId>org.openhubframework</groupId>
     <artifactId>openhub</artifactId>
     <version>2.0.0-SNAPSHOT</version>
     <scope>import</scope>
     <type>pom</type>
    </dependency>
  2. 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:

  • root application context (Apache Camel, database, Spring Web Services - MessageDispatcherServlet and Spring Security) + web-admin-mvc (Spring Web MVC context for admin GUI)
  • extension child context

Spring profiles

OpenHub framework uses Spring profiles to simplify configuration for different target environments (profiles ar defined in org.openhubframework.openhub.common.Profiles):

  • dev: profile for development environment; this profile has disabled several functions which are enabled in production, e.g. scheduled tasks for asynchronous messages
  • test: profile is activated for unit testing
  • prod: profile for production environment

Next Spring profiles are used for switching between databases:

  • h2 (default): database H2 in embedded in-memory mode, more information in chapter about H2 database
  • postgresql: profile for PostgreSQL database

There is profile cluster for cluster environment. 

Apart from these profiles it's good practice to define Spring profile for each module and use it for configuration all beans in this module.

Defaults Spring profiles are set in application.properties, it's possible to override them by Environment parameter spring.profiles.active.

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 web-admin.

  • esb.dev
  • esb.prod
  • esb.psSqlb - profile for PostgreSQL database
  • esb.psSql.prod - profile for PostgreSQL database but PostgreSQL libraries are "provided"
  • esb.executable - profile used for packaging OpenHub to support standalone running
  • full-build - profile which is activated by default (to deactivate use skipDefault property), can be deactivated for example to exclude admin-console maven module from build (faster build).
  • full-clean - profile which is activated by default (to deactivate use skipDefault property), it can be deactivated for example if cached admin-console maven module libs (npm packages and so on) should be used (=> faster build)

 

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

Faster build

mvn clean && mvn -DskipTests -Pesb.psSql package -P !'full-build',!'full-clean' -Dmaven.javadoc.skip=true

where full-build and full-clean maven profiles are deactivated