Written by The Jahia Team
   Estimated reading time:

What is a Module?

  • A Module is a type of Java JAR file called an "OSGi Bundle" and is stored in[Jahia-Installation-Folder]/digital-factory-data/modules.
  • They are specially designed plug-ins for building upon Jahia’s infrastructure and services. They can
    • Define new types of content like articles, news items, and sports events
    • Add features on sites like Tagcloud and Google Analytics
    • Extend the technology stack like OpenSocial, and LDAP

Key Advantages

Portability and reusability

Module are independent from each other and reusable across projects. 

Easy to maintain

All of a module's required elements are packaged in a single directory. As such, module updates can be performed independently from the rest of the platform.

Reliability

A defective module does not cause a general error on a page or site.

Team work

For large projects, it is easier to divide the work between developers with each being responsible for a set of modules.

Jahia Developers work on Modules by...

  • Modifying or adapting Modules provided out-of-the-box
  • Deploying new Modules from the Jahia AppStore
  • Creating new Modules from scratch

A Module's Contents

The standard structure of a Jahia module is generated with a Maven archetype. The Felix Maven Bundle plugin then generates an OSGi bundle out of the maven project.  

A Module can contain:

Definitions
Scripts (jsp, JSR 283, php)
Static resources (text, images, css, js)
Properties files and resource bundles
Java binaries
Filters
Permissions
Rules
jBPM files
Tags
Spring configuration files
Data files (XML)

How to Create a Module

Using Maven

maven-logo.png
 

Modules can be created with Apache Maven using a command like the one below:

mvn archetype:generate -Dfilter=org.jahia.archetypes:

In the menu choose archetype number 2 : jahia-module-archetype

Module creation requires a specified name, artifactId, and Jahia version.

See the Module Creation tutorial here: Module Management Tutorial

Using Eclipse

In Eclipse, a Module is created with a new Maven project.

For Jahia modules, the remote catalogue http://maven.jahia.org/maven2 is used.

Using Jahia Studio

studio-logo.png
 
  • "New Module" can be found in the "New" dropdown

new-module.png

  • The running Jahia version number is auto-populated.

my-first-module.png

 

Enabling a Module

To make a Module available to editors it must first be enabled. This can be done from Administration mode under Components/Modules. In the “Usage in sites” area, the 'Enable' button would be selected on the relevant site. 

enable-module.png

Exercise: Create a Module

  1. In Jahia Studio, create a new module.
  2. Ensure it's created as a 'module' type.
  3. Name the Module “acmeCompany”.