It is possible to package one or multiple builtins in an OSGI bundle. The bundle must register a BuiltinProvider service to announce its builtin contributions to OntoBroker. Most simply, a declarative service in OSGI can be used for this purpose.
The BuiltinProvider interface has one single method to return the builtin classes of this extension bundle.
package com.ontoprise.ontobroker.kernel.builtinsystem;
public interface BuiltinProvider {
Collection<Class<? extends IBuiltin>> getBuiltins();
}
To implement this interface, create a class like the following example
package com.acme.mypackage
import java.util.*
import com.ontoprise.ontobroker.api.extension.builtin.IBuiltin;
public class MyBuiltinsProvider implements BuiltinProvider {
@Override
public Collection<Class<? extends IBuiltin>> getBuiltins() {
ArrayList<Class<? extends IBuiltin>> list = new ArrayList<Class<? extends IBuiltin>>();
list.add(MyBuiltin.class);
return list;
}
}
Package this class together with your builtin classes in a JAR file. You need to add an OSGI conform META-INF/MANIFEST.MF file to the JAR.
META-INF/MANIFEST.MF (minimalistic version)
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyBuiltins
Bundle-SymbolicName: com.acme.mypackage
Bundle-Version: 1.0.0
Require-Bundle: com.ontoprise.ontobroker.base,com.ontoprise.ontobroker.datamodel
Import-Package: org.osgi.framework,org.osgi.service.component
Export-Package: com.acme.mypackage
Service-Component: OSGI-INF/component.xml
In addition, to register the OSGI service the simplest way is to define it as declarative service in an OSGI-INF/component.xml.
OSGI-INF/component.xml
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.acme.mypackage">
<implementation class="mypackage.MyBuiltinsProvider"/>
<service>
<provide interface="com.ontoprise.ontobroker.kernel.builtinsystem.BuiltinProvider"/>
</service>
</scr:component>
Also see the example in the Eclipse project located at $ONTOBROKER_HOME/interfaces/development/Code Examples