The “openlmis-example” repository now contains proof of concept that is a result of work on OLMIS-783: Extension modules - design & example.
Following classes are example of extension points usage:
- OrderQuantity.java - sample extension point, that has getInfo method.
- DefaultOrderQuantity.java - default implementation of that extension point, it has @DefaultImplementation annotation.
- ExtensionManager.java - class that has getImplementation method. It returns implementation of given extension point. Decision about which implementation should be returned is made based on configuration file “extensions.xml”. If there is no extension defined for given extension point, Extension Manager will return default implementation.
Endpoint using extension point is defined in MessageController.java: http://localhost:8080/extensionPoint
All extension modules should be deployed as JAR and placed in extensions directory of the project. They are added to the classpath of the project when initializing a docker container using openlmis/example image. Example extension module will be soon published in the new repository - openlmis-example-extension.
For now, to test this endpoint you can download JAR from here: https://www.dropbox.com/s/7r7ibtr0wicwweq/openlmis-extension.jar?dl=0
Place it in “extensions” directory of the project. If you want to test default implementation, simply remove extensions.xml file.
Also, for testing purposes, you have to build openlmis/example image (docker-compose -f docker-compose.builder.yml build image) and change image in docker-compose.override.yml file to “openlmis/example”.
I am currently working on adding extensions to the openlmis/dev image.
I will be grateful for your opinions. If you have any questions I will be happy to answer them.