The LPhy extension mechanism is implemented using the Service Provider Interface (SPI)
and the Java Platform Module System (JPMS).
An LPhy extension has to be a Java module, which also needs to implement the interface
LPhyExtension.java to provide a list of the required classes to extend the functionality of LPhy.
The LPhy repository contains two modules
separated in two subfolder, where lphy contains core classes, such as parser, distributions, functions and data types,
and lphy-studio are GUI. The project folder structure looks like:
The module lphy
declares the package dependencies and SPI LPhyExtension using the following code.
Because we consider the core itself as an extension, the Container Provider class LPhyExtImpl
is also required to declare in this module using the following one-line code.
Here is the source code of SPI in LPhy :
Then the Container Provider class LPhyExtImpl lists all classes required to be extended:
GenerativeDistribution, Func, and SequenceType.
These two classes can be seen from the package lphy.spi.
In the next sub-project lphy-studio, even though it is not going to extend anything from lphy,
we still create an empty class LPhyStudioImpl as a flag to make it recognised by the extension mechanism.
The project is migrated to a Gradle project from version 1.1.0.
How to set up the project is available in the developer note.