The JCR installer modules (collectively known as JCRInstall) install OSGi bundles and configurations found in the JCR repository.
The goal is to allow Sling applications to be distributed as "content packages", which install additional services and configurations when copied to the JCR repository.
Here's a quick walkthrough of the JCR installer functionality.
Start the Sling launchpad/app and install and start the following additional bundles:
- RunMode service
- OSGi installer service (org.apache.sling.osgi.installer)
- JCR installer service (org.apache.sling.jcr.jcrinstall)
To watch the logs produced by these modules, you can filter sling/logs/error.log using egrep 'jcrinstall|osgi.installer'.
We'll use the Knopflerfish Desktop bundle for this example, it is convenient as it displays a graphical user interface when started.
We use curl to create content, to make it easy to reproduce the example by copying and pasting the curl commands. Any other way to create content in the repository will work, of course.
By default, JCRInstall picks up bundles found in folders named install under /libs and /apps, so we start by creating such a folder:
And we copy the bundle to install in that folder (a backslash in command lines means continued on next line):
That's it. After 2-3 seconds, the bundle should be picked up by JCRInstall, installed and started. If this works you'll see a small Knopflerfish Desktop window on your desktop, and Sling's OSGi console can of course be used to check the details.
Removing the bundle from the repository will cause it to be uninstalled, so:
Should cause the Knopflerfish Desktop window to disappear as the bundle is uninstalled.
TODO: document folder priorities (/apps over /libs), SNAPSHOT handling, bundle start retries.
JCRInstall installs OSGi configurations from nodes having the sling:OsgiConfig node type, found in folders named install under the installation roots (/apps and /libs).
Let's try this feature by creating a configuration with two properties:
And verify the contents of our config node:
Which should display something like
At this point, JCRInstall should have picked up our new config and installed it. The logs would confirm that, but we can also use the OSGi console's config status page (http://localhost:8888/system/console/config) to check it. That page should now contain:
Indicating that the configuration has been installed.
Let's try modifying the configuration parameters:
And check the changes in the console page:
We can now delete the configuration node:
And verify that the corresponding configuration is gone in the console page (after 1-2 seconds, like for all other JCRInstall operations).
TODO: A node named like o.a.s.foo.bar-a uses o.a.s.foo.bar as its factory PID creating a configuration with an automatically generated PID. The value of a is stored as an alias property in the configuration to correlate the configuration object with the repository node - demonstrate that.
TODO: folder names like install.dev are included in the repository scanning if the dev run mode is active - describe this feature.
The following modules contain lots of automated tests (under src/test, as usual):
- OSGi installer integration tests (org.apache.sling.installer.it)
- JCR installer service (org.apache.sling.installer.providers.jcr)
Many of these tests are fairly readable, and can be used to find out in more detail how these modules work.