Creating multi-plugin AIBench applications¶
One of the main focus of the AIBench framework is to enhance reusability. For achieving this, you can exploit the underlying plugin-architecture of AIBench.
In this sense, You can put your Operations, Views and Datatypes in one, two or more separated plugins, based on your own design decision. The only rules that have to be followed are:
- If there are Operations and/or Views in a plugin, this plugin must be connected to the properly extension points as it was explained before.
- If the Operations and/or Views in a plugin make use of the Datatypes located in other plugin, this plugin must depend on the plugin containing the needed Datatypes.
You have to develop one Maven project for each plugin (see Maven). For
example, if your application will have two plugins (plugin1
and plugin2
)
and plugin2
depends on plugin1
, you will need to:
- Create an AIBench application for
plugin1
using the archetype. - Perform
mvn install
in theplugin1
application. - Create an AIBench application for
plugin2
and establish a dependency to plugin1 (see next section).
Creating a dependency between plugins¶
You will need to create dependencies between plugins when:
- You are developing a multi-plugin AIBench application and some plugin needs to access classes or resources from another plugin.
- You need to get access to classes and resources in another AIBench plugin, for example, if you want to use the AIBench Core and Workbench API (see AIBench API).
The connection and dependency between plugins is made through the pom.xml
file and, optionally, trough the plugin.xml
file.
In the pom.xml
, you need to create a regular maven dependency as well as to
declare the artifact id in the aibench.plugins.artifactIds
property.
<project>
...
<properties>
...
<aibench.plugins.artifactIds>
aibench-core,aibench-workbench,aibench-shell,aibench-pluginmanager,another-plugin
</aibench.plugins.artifactIds>
...
</properties>
...
<dependencies>
...
<dependency>
<groupId>my-group-id</groupId>
<artifactId>another-plugin</artifactId>
<version>[version]</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
...
</project>
If you need to access classes or resources of one plugin from another, you will
also need to add a dependency
in the plugin.xml
:
<plugin start="true">
<uid>my-aibench-application</uid>
...
<dependencies>
<!-- we will use the API so we need to
depend on Core and Workbench plugins -->
<dependency uid="aibench.workbench"/>
<dependency uid="aibench.core"/>
<dependency uid="another.plugin"/>
</dependencies>
...
</plugin>
Note
Why do you need to edit two files? The pom.xml
makes that your application
include another plugin, and the plugin.xml
allows you to also use a
plugin from another, that is, classes from one plugin can use classes from
another plugin. Remember that plugins are isolated by default (see
Plugin-based architecture).