SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


PDT Connector - Eclipse Plugin

The Java-Prolog Connector Library is used in the PDT for implementing the connection of Java to Prolog. If you develop an Eclipse plugin and want to use the features listed below (which are also used by the PDT), you have to depend on the org.cs3.pdt.connector plugin. You can retrieve the org.cs3.pdt.connector plugin either from the update site or by installing the PDT. This allows using additional features which the Prolog Connector Library does not support:

  • Automatically load files and define file search paths by using bootstrap contributions.
  • A registry which manages Prolog processes. The registry can be accessed via
    org.cs3.pdt.connector.PDTConnectorPlugin.getDefault().getPrologProcessRegistry().
  • A Prolog process service which manages an active Prolog process and allows consulting files in Prolog processes including the notification of registered listeners.

Bootstrap Contributions

fileContribution

If your plugin contains Prolog files which should be automatically loaded you can add a fileContribution extension to your plugin.xml.

<extension
  point="org.cs3.pdt.connector.bootstrapContribution">
  <fileContribution
     id="my.plugin.pl.fileContribution"
     path="pl/load.pl"
     key="">
     <dependency
        contribution="org.cs3.pdt.common.fileContribution">
     </dependency>
  </fileContribution>
</extension>
  • id: this can be any unique id
  • path: the path to the file which should be consulted (typically a load file)
  • key (optional): if the key is empty or not defined the Prolog file is consulted to every Prolog process. If a key is defined, it's only consulted to processes which are access via a subscription containing this key.
  • dependency contribution (optional): here you can specify the id of the contribution whose Prolog file must be consulted before consulting the Prolog file of this contribution.

fileSearchPathContribution

If you want to add a path to the Prolog file search path (file_search_path/2) you can do this with a fileSearchPathContribution.

<extension
   point="org.cs3.pdt.connector.bootstrapContribution">
   <fileSearchPathContribution
      id="my.plugin.pl.fileSearchPathContribution"
      alias="my_plugin_pl"
      path="prolog_code/"
      key="">
   </fileSearchPathContribution>
</extension>

This extension creates the following file search path entry in every Prolog process:

file_search_path(my_plugin_pl, '$path to plugin$/prolog_code/').
  • id: this can be any unique id
  • alias: the alias which is used for the file_search_path/2 predicate
  • path: path to the folder which contains the Prolog code
  • key (optional): if the key is empty or not defined the file search path entry is added to every Prolog process. If there is a key, it's only added to processes which are access via a subscription containing this key.

An example can be found in the plugin.xml of the Prolog Console plugin.

Subscriptions

A subscription can be used to get a PrologProcess and to make sure that certain Prolog code is loaded in this process.

A subscription has a name and a list of keys. If you ask for a process via a subscription, the process having the same name as the subscription is returned and it is ensured that all file and file search path contributions whose key is contained in the subscription's list of keys are loaded in this process.

To get the process via the subscription you can use: PDTConnectorPlugin.getDefault().getPrologProcess(Subscription)

An example can be found in the getDefaultPrologProcess() method of the type PrologProcessService.

research/pdt/connector/plugin.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2025