Back to DevDoc
OpenMOLE provide a plugin mechanism based on OSGi specifications. So you can easily add new features or integrate exotic libraries in the platform.
Add features to the console
You can add features to the console by using the IConsole interface. You can get this console service with the following code to put in your OSGi bundle activator:
@Override
public void start(BundleContext bc) throws Exception {
ServiceReference serviceReference = bc.getServiceReference(ITask.class.getName());
if (serviceReference != null) {
((IConsole) bc.getService(serviceReference)).setVariable("builder", new Builder());
}
}
How to turn your module into an OSGi module
Inherits the predefined maven module
The first solution (the easier) is to let your project inherit the artifact org.openmole:plugins, so your pom.xml should contain:
<parent>
<artifactId>plugins</artifactId>
<groupId>org.openmole</groupId>
<version>0.3</version>
</parent>
<artifactId>your.artifact.name</artifactId>
<packaging>bundle</packaging>
Then, you can add dependencies to your project like another maven project.
If you want to define an Activator that will be invocated at the startup of your module, you have to specify the complete class name of your Activator in the property bundle.activator, for example:
<properties>
<bundle.activator>${project.artifactId}.internal.Activator</bundle.activator>
</properties>
Use the maven bnd plugin
The second solution is less intrusive for your project as you don't need to inherit our provided module. To turn a maven project into a plugin for OpenMOLE, you should first configure the maven bundle plugin:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<manifestLocation>target/META-INF</manifestLocation>
<finalName>${symbolic.name}_${project.version}</finalName>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Import-Package>*;resolution:=optional</Import-Package>
<Export-Package>${project.groupId}.${project.artifactId}.*</Export-Package>
<Embed-Dependency>*;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
Change the packaging of your maven project to "bundle":
<packaging>bundle</packaging>
This sould embed all the requiered jar into the builded jar and write an osgi manifest, like this one





