Custom Jena function integration

83 views
Skip to first unread message

David Habgood

unread,
Nov 25, 2021, 1:45:36 AM11/25/21
to TopBraid Suite Users
Hi,

I have some custom Jena Value Functions that I have working against a vanilla Jena instance https://jena.apache.org/documentation/query/java-uri.html

I'd like these functions to be available in EDG.

I tried the approach at the bottom here: https://www.topquadrant.com/sparqlmotion/extending.html
By following a more detailed guide in the Composer help, and while a bit out of date, was able to complete the steps, however I couldn't get the functions to work.

Before I continue with the above, I wanted to ask more generally, assuming I may use EDG Studio and not eclipse going forward, and that the functions would ultimately be deployed on a server instance, what would the recommended approach be for integrating these functions?

Thanks
David

Richard Cyganiak

unread,
Nov 25, 2021, 11:21:23 AM11/25/21
to topbraid-users list
Hi David,

TopBraid Composer, and EDG versions prior to 7.0, were built on Eclipse and OSGi. With the EDG 7.x series of releases, we are transitioning off this technology foundation. This requires changes to the way extensions are done. The transition process is not complete, and our developer documentation is somewhat behind.

On 25 Nov 2021, at 06:45, David Habgood <david....@surroundaustralia.com> wrote:

Before I continue with the above, I wanted to ask more generally, assuming I may use EDG Studio and not eclipse going forward, and that the functions would ultimately be deployed on a server instance, what would the recommended approach be for integrating these functions?




For both Composer and EDG Studio, it is now necessary to create an instance of org.topbraid.core.PluginActivator that registers the SPARQL function in the activate() method. For example:

    public class MyPluginActivator implements PluginActivator {
        @Override
        public void activate() {
            FunctionRegistry.get().put("http://example.org/ns#myFunction", MyFunction.class);
        }
    }

This method will be called during system startup. Any other initialisation code may be placed there as well. An optional deactivate() method for shutdown can also be provided.


Making this work in Composer 7.0 and 7.1:

The plugin activator, SPARQL function implementation, and any other supporting Java code and jar files need to be packaged in an Eclipse plugin. The plugin activator needs to be announced in the plugin.xml file using the org.topbraid.core.pluginActivators extension point, for example:

    <plugin>
        <extension point="org.topbraid.core.pluginActivators">
            <activator class="org.example.MyPluginActivator"/>
        </extension>
    </plugin>

Note that these plugin activators are *not* OSGi/Eclipse bundle activators. They are our own homegrown mechanism for a similar purpose.

The Eclipse plugin needs to be placed in Composer's dropins folder. When Composer is running, the list of installed Eclipse plugins can be reviewed in the “About TopBraid Composer ME” window under “Installation Details” to verify that the plugin has been discovered.


Making this work in EDG Studio 7.1:

Plugin activator, SPARQL function implementation and any other supporting Java code need to be packaged in a normal jar file, and the plugin activator needs to be announced using Java's ServiceLoader mechanism. This means adding a file META-INF/services/org.topbraid.core.PluginActivator to the jar file, with its contents being the qualified class name of the plugin activator:

    org.example.MyPluginActivator

The jar file should include one of the strings "edg", "topbraid" or "tq" in the name to mark it as an EDG extension. The jar file, along with any other required library jar files, needs to be placed in EDG Studio's lib directory.

If EDG Studio is launched with --verbose, all plugin activators are listed on the console during startup, so this is a way of verifying that it is being found. After startup, this information can also be viewed under Server Administration > Startup Sequence.


Making this work in production EDG 7.0 and 7.1 on Tomcat:

A jar file built for EDG Studio will work in production EDG. To deploy it, place it, along with any other required library jar files, in the WEB-INF/lib subdirectory within the directory where edg.war is unpacked, e.g., webapps/edg/WEB-INF/lib.

All found plugin activators are listed in the edg.log during startup. After startup, this information can also be viewed under Server Administration > Startup Sequence.


Hope this helps,
Richard

David Habgood

unread,
Nov 25, 2021, 5:23:57 PM11/25/21
to topbrai...@googlegroups.com
Thanks Richard, that's very helpful

--
You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/topbraid-users/1gD6WR1OEaU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/25479A07-77F7-4CC0-8B70-3A1A95DC5078%40topquadrant.com.
Reply all
Reply to author
Forward
0 new messages