SDA SE Wiki

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

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
research:pdt:connector:plugin [2014/08/13 16:34]
Günter Kniesel
research:pdt:connector:plugin [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== PDT Connector - Eclipse Plugin ======
 +
 +The [[library|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 [[..:​docs:​download#​installation|update site]] or by [[..:​docs:​download|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|bootstrap contributions]].
 +  * A [[https://​github.com/​pdt-git/​public/​blob/​master/​pdt.connector/​src/​org/​cs3/​pdt/​connector/​registry/​PrologProcessRegistry.java|registry]] which manages Prolog processes. The registry can be accessed via \\ ''​org.cs3.pdt.connector.PDTConnectorPlugin.getDefault().getPrologProcessRegistry()''​.
 +  * A [[https://​github.com/​pdt-git/​public/​blob/​master/​pdt.connector/​src/​org/​cs3/​pdt/​connector/​service/​IPrologProcessService.java|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.
 +<Code lang-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>​
 +</​Code>​
 +
 +  * **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 [[#​subscriptions|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 ([[http://​www.swi-prolog.org/​pldoc/​doc_for?​object=file_search_path/​2|file_search_path/​2]]) you can do this with a ''​fileSearchPathContribution''​.
 +
 +<Code lang-xml>​
 +<​extension
 +   ​point="​org.cs3.pdt.connector.bootstrapContribution">​
 +   <​fileSearchPathContribution
 +      id="​my.plugin.pl.fileSearchPathContribution"​
 +      alias="​my_plugin_pl"​
 +      path="​prolog_code/"​
 +      key="">​
 +   </​fileSearchPathContribution>​
 +</​extension>​
 +</​Code>​
 +
 +This extension creates the following file search path entry in every Prolog process:
 +
 +<Code lang-prolog>​file_search_path(my_plugin_pl,​ '$path to plugin$/​prolog_code/'​).</​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 [[#​subscriptions|subscription]] containing this key.
 +
 +An example can be found in the [[https://​github.com/​pdt-git/​public/​blob/​master/​pdt.console/​plugin.xml|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 [[https://​github.com/​pdt-git/​public/​blob/​master/​pdt.connector/​src/​org/​cs3/​pdt/​connector/​internal/​service/​PrologProcessService.java|PrologProcessService]].
  

SEWiki, © 2019