Install hooks are just Java classes which are called during package installation. One can use them to execute arbitrary operations automatically on certain stages during package import.
Install hooks must implement the interface org.apache.jackrabbit.vault.packaging.InstallHook
.
The internal install hooks have to be packaged as JARs and placed in META-INF/vault/hooks
within the content package. The JAR needs to have a Main-Class
attribute in its manifest pointing to the hook class.
External install hooks are loaded through the class loader by their fully qualified class name. The class name is given in the package property installhook.<name>.class
where <name>
is an arbitrary string (must not contain a dot).
The following class loaders are used by default to load the given class:
InstallHookProcessorImpl
class (in an OSGi container this is the bundle class loader of the FileVault bundle)The class loader can be overridden by calling ImportOptions.setHookClassLoader(...)
and pass the import options then to the package importer.
You must make sure that the external install hook class is accessible from the used class loader.