About Java modules
Modules are an important part of Jahia and can be considered Jahia's plug-in infrastructure. Modules are composed of directories and files that are packaged as an OSGi bundle JAR file and then deployed into Jahia through the module administration UI, a REST API call, from a central module store, or copied into Jahia's digital-factory-data/modules
directory for deployment. When Jahia encounters a new module, it starts the module and makes it available to the whole system. Modules range from very simple, that only define new views for existing content types, to very complex implementations of new communication layers such as a REST API, or that implement back-end LDAP user and group providers.
Advantages of modules include:
- Reusability
Because modules are autonomous, it is easy to move them from development to staging or production environments. You can also reuse them across projects or share them with others. Modules can also inherit from other modules, making it easy to extend a default module. - Maintenance
Because modules are autonomous, they can focus on specific use cases, as with a forum module, which makes maintenance and evolution easy. - Reliability
If a module fails, only that part of the system is unavailable and the rest of the platform continues to serve requests. - Separation of concern
As modules may be integrated at any time, it is easier to split work among team members. - Hot deployment
As modules are OSGi bundles, you can hot deploy them or even remove them without shutting down the whole system, even if they include Java code or workflow definitions. - Isolation
With the introduction of OSGi as a module framework in DX 7.0, modules are executed in their own class loaders. This makes it possible for modules to embed their own dependencies, even if they differ in version from the ones used by Jahia or another module.
Developers work mostly on modules, either creating new ones or extending out-of-the-box modules. Developers can also share their work (or reuse contributions from others) on Jahia's App Store (http://www.jahia.com/store) to make modules available at large, get feedback and potentially community contributions.
Different types of modules
You can create complex modules that offer a lot of built-in functionality. Custom modules usually fall into one of the following categories:
- Template sets
Provides a set of page and content templates - Content definitions and views
Provides new content components - Single-page applications/headless
Browser-based applications built using modern stacks such as React & GraphQL, either hosted on Jahia or externally - Extensions (for example, custom logic and UI)
Extends the functionality of Jahia by using various plugin extension points. May range from new administration screens, to custom editor selectors, and to custom backend Java logic.
What can modules contain?
A module may contain:
- Content type definitions (CND)
- Content view scripts (JSP)
- Static resources (text file, images, CSS files, and JavaScript files)
- Resource bundles or other property files
- Java classes or JAR libraries
- Filters
- Permission and role definitions
- Rules
- jBPM workflow definitions
- Tag libraries
- OSGi Blueprint or Declarative service files
- Content import files (in XML format)
- Extensions
Creating your first module
For more information on creating a module, try the following tutorial:
- Create and Manage Jahia Modules
Shows how to create, build, and deploy a module