OSGi enables you to hot deploy packaged modules at runtime. Deploy-free coding builds on top of OSGi's capabilities and makes it possible to use changes made in file's source code without needing any redeployment. Deploy-free coding only requires an initial deployment using Jahia's Maven plugin.
Using deploy-free coding
- Create your module’s source code project.
- Compile and deploy it to your Jahia server that must be on the same file system as your project. The initial deployment “links” source code with Jahia server. Note that the file system could also be a network shared file system.
- Modify static resources directly in your source code. Jahia will pick up the changes directly from the source. No deployment is needed.
How deploy-free coding works
When building the project, the Jahia Maven Plugin will add a special
MANIFEST.MF header that points to the source code location with an absolute path. This is configured in the Felix Maven Bundle plugin by the following line:
Upon generation of the
MANIFEST.MF inside the JAR, it will look something like this:
When a request comes in to a /modules/assets URL, Jahia will use the Jahia-Source-Folders manifest header (if present) to look for the source code of the project. If it is present, it will try to access the requested resource directly from the source folder instead of using the contents of the bundle. There are some limitations. Not all files can be directly used as some require compilation or internal caches that may interfere with the proper detection of file modifications. Here is a list of resource types that are supported with deploy-free coding:
- Other static file types such as documents and text files
The following resources types are not supported:
- Groovy files (due to the internal Groovy engine class cache)
- Java classes
- Java libraries
Of course, for the file types that don’t work with deploy-free coding, you can still hot deploy them using OSGi bundle redeployment. So, for those file types the deployment life cycle is a little longer but still much faster than in previous versions of Jahia.
When releasing modules, it is recommended that you remove the Jahia-Source-Folders configuration attribute from the Felix Maven Bundle plugin configuration. This is just to avoid any potential lookups in case the source folders also exist on the server. It will also prevent unnecessary file lookups.