Improve inter-communication between extensions
|Reported by:||Nicklas Nordborg||Owned by:||Nicklas Nordborg|
Due to how classloading is implemented in Java, Tomcat and the BASE core the possibilities for communication between extensions is very limited. Actually, the extension system has been designed to make each extension as independent as possible from other extensions. This is something that among other things makes it possible to install and update extensions without having to restart Tomcat.
There are currently only a few possibilities for extensions to communicate:
- Using a common class/interface defined by BASE. For example a
Buttoninstance can be passed between extensions since the
Buttonclass is defined by the BASE core. However, the
Buttoncan't be passed directly. It has to be passed via BASE as a middle-hand using the extensions API. It's doable but complicated and of limited use.
- Using a Job and Plug-in. An extension can define a job for any plug-in, even plug-ins that are part of other extensions. Since #2026 it is even possible to execute the job without saving it to the database. The drawback is that parameters need to be passed using a few basic Java types (eg. strings, numbers, etc). This method is more or less just as complicated to use as the one above.
- Using a Servlet. An extension can invoke any servlet that it wants. This is mostly useful when using the GUI from a browser and is already in use for Reggie/LabEnv integration (http://baseplugins.thep.lu.se/ticket/530). This method is of limited use from the server-side.
It would be nice to make it possible for extensions to directly use classes and methods defined by other extensions. In one sense it is not very complex to do. Simply make sure that the classloaders are linked so that one is the parent of the other. This information could for example be stored in the MANIFEST.MF file. In reality a lot of issues may arise:
- What if one extension want to use functionality from two or more other extensions? Then it need multiple parents.
- Updating extensions must still work. A new version of an extension must be picked up by dependencies without having to restart Tomcat.
- Class collisions. There is already a chance that class collisions occur with classes that are shipped with BASE and classes that are shipped with an extension. It has been solved by stating that extensions should not duplicate classes that are shipped with BASE. The risk of collisions increases if one also has to consider dependencies between extensions. Extensions with multiple parents may create impossible situations.
- Class loading search order. An extension may specify if the parent class loader is searched before or after searching it's own classloader. With dependencies on other extensions the search order may become even more important. A different search order may solve some types of class collisions.
- And probably a lot more that I don't know about yet...