loading table of contents...

4.1.5. Project Extensions

One of the main goals of CoreMedia DXP 8 is to offer a developer friendly system with a lot of prefabricated features, that can simply be extended modularly. To this end, CoreMedia provides the Maven based CoreMedia Blueprint workspace and the extensions mechanism.

An extension adds new features to one or more CoreMedia components. To preserve a modular structure in the workspace an extension should be developed in its own Maven module and should have submodules for extensions that affect different CoreMedia applications. Assume, for example, that you want to extend your CoreMedia system to integrate external content and render this content with a proof of origin. In this case there is a submodule for the CAE containing new view templates for this content and there is another submodule containing new UI components for Studio to search specific sources and create new content.

In CoreMedia Blueprint workspace extensions are, in principle, enabled for one component by adding a Maven dependency on the extension module to the component module.

Nevertheless, because extensions often affect more than one component (for example the CAE and Studio as shown in Figure 4.2, “CoreMedia Extensions Overview”) that would mean that a dependency for each affected component has to be declared. If the extension should be disabled, the corresponding dependencies have to be removed from the components. This requires many manual steps and it is error-prone if dependencies are forgotten. The CoreMedia Blueprint Maven Plugin is a Maven build extension that does all the dependency management for you. It allows you to define extensions for multiple CoreMedia components in separate modules and to enable or disable them in one place. Find the details described in the following paragraphs.

CoreMedia Extensions Overview

Figure 4.2. CoreMedia Extensions Overview


How Extensions and Components Integrate

The CoreMedia Blueprint Maven Plugin requires the following features in the Maven workspace for operation :

  • Extension Point: Each CoreMedia component that can be extended defines an extension point in the modules/extensions-config folder. The extension point is a simple POM file in a component specific submodule. For instance extensions-config/studio-extension-dependencies/pom.xml is the extension point of CoreMedia Studio.

  • Extension Descriptor: A simple BOM POM file of the extension that has dependencies on the component specific extension modules. The root POM file of the project has to depend on this POM file in order to activate the extension.

  • coremedia.project.extension.for: A property in the POM files of the component specific extension submodule. The property defines for which CoreMedia component the extension is intended.

The CoreMedia Blueprint Maven Plugin ia a tool which manages extensions for you. It analyzes the root pom.xml file and its dependencyManagement entries to identify the registered extensions by their extension descriptor. If any are found, each extension module defined in the extension descriptor of the extension is added to the extension point. An application now only needs to depend on its extension points and all necessary dependencies will be added to the applications dependency tree by transitivity. The following sections describe this in detail.

Mapping Components and Extensions

The CoreMedia Blueprint Maven Plugin handles the dependencies for you in order to enable or disable an extension. To reach that, a relation between extension module and corresponding component must exist. This relation will be defined by the extension module itself. In other words the extension module exposes its target component. The CoreMedia Blueprint Maven Plugin expects a Maven property in the extension module. The name of the property is coremedia.project.extension.for. The value of this property describes the target component or more precisely it matches the prefix of one module of the extension points. The CoreMedia Blueprint Maven Plugin adds a dependency on the extension module to the matching extension point module (see Figure 4.3, “Component Mapping”).

Component Mapping

Figure 4.3. Component Mapping


Activating Extensions

As already mentioned the CoreMedia Blueprint Maven Plugin allows you to enable and disable an extension in one place. Extensions are enabled by adding the Extension Descriptor to the project's root POM and running the update-extensions goal of this Maven plugin. While the Extension Descriptor is a BOM POM you have to import it to the dependencyManagement section of the project's root POM as shown in Example 4.5, “Enabling an Extension”. To disable an extension you have to remove the import also followed by the update-extensions goal of this plugin. For more information about developing with the CoreMedia Blueprint Maven Plugin see Section 4.3.2, “Developing with Extensions”.

      
<dependencyManagement>
  <dependencies>
    ...
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>my-extension-bom</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    ...
  </dependencies>
</dependencyManagement>
    
      
$ cd $BLUEPRINT_HOME
$ mvn com.coremedia.maven:coremedia-blueprint-maven-plugin:\
      update-extensions
    

Example 4.5. Enabling an Extension


[Note]Note

The Project Extension mechanism does not corrupt the Maven dependency resolving in any way. The dependencies are added before Maven analyzes dependencies and calculates the build order. Since the managed dependencies are persisted in a standard pom.xml, every IDE and other Maven based tool should work as expected.

Example

The example bases on the extension mentioned above; an extension that extends your CoreMedia system to integrate external content and render this content in the CAE. Therefore, it needs sub modules for Studio and CAE specific parts:

--extensions
  --externalContent
    --externalContent-cae
    --externalContent-studio
    

Example 4.6. Module structure of the extension


Each component specific submodule needs to show for which CoreMedia component it is intended. The pom.xml file of the externalContent-studio module, for example, has to contain the following property:

      
<properties>
    <coremedia.project.extension.for>
      studio
    </coremedia.project.extension.for>
</properties>
    

Example 4.7. Define the component


The extensions need to be defined in the extension descriptor in the BOM POM file of the extension.

--extensions
  --externalContent
    --externalContent-bom
      --pom.xml
    --externalContent-cae
    --externalContent-studio
    

Example 4.8. Module structure with BOM POM


      
<dependencies>
  <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>externalContent-cae</artifactId>
    <version>${project.version}</version>
  </dependency>
  <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>externalContent-studio</artifactId>
    <version>${project.version}</version>
  </dependency>
</dependencies>
    

Example 4.9. BOM POM with dependencies on submodules


Now, you have to activate the extension. Simply add a dependency on the BOM POM file to the root pom.xml file:

      <dependencies>
  <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>externalContent-bom</artifactId>
    <version>${project.version}</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencies>
    

Example 4.10. Enabling the extension in the root POM file


    
$ cd $BLUEPRINT_HOME
$ mvn com.coremedia.maven:coremedia-blueprint-maven-plugin:\
      update-extensions
  

The CoreMedia Blueprint Maven Plugin will add the dependencies on the externalContent-cae and externalContent-studio to the respective extension points of CAE and Studio.