JAR Extensions
Last modified by Thomas Mortagne on 2024/03/25 12:07
JAR extensions are extensions packaged as JAVA JAR packages.
What does installing a JAR extension exactly means
When a JAR extension is installed, the following happens in practice:
- the JAR is loaded in the ClassLoader corresponding to the namespace where it was installed (root namespace, wiki namespace, user namespace, etc.)
- the components in the JAR extension are loaded into the ComponentManager corresponding to the namespace where it was installed (root namespace, wiki namespace, user namespace, etc.)
- various listeners react to those new components/extensions events (for example the ObservationManager receive new listeners)
Subtleties related to classes and the upgrade/uninstallation of extensions
In Java, you cannot really remove a class from a ClassLoader. This means that when you upgrade/uninstall an extension in XWiki, the whole ClassLoader from where it needs to be removed has to be destroyed and recreated. That means that if any extension is upgraded or uninstalled from the same namespace as your extension or the root namespace, it will be entirely reloaded, so you should be sure that it supports it.
Here are some examples of things to be careful about:
- Every resource your components uses should be released when it's disposed
- You should not store an instance of a class coming from an installed extension in a core location (and in general better be safe and only store these kinds of objects in locations you fully control), unless you remove it when the components of your extension are disposed. This includes, for example: