Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2106

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Java to Prolog interface</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_158.html">previous</A>, <A HREF="ciao_160.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC670" HREF="ciao_toc.html#TOC670">Java to Prolog interface</A></H1>
<P>
<A NAME="IDX7522"></A>


<P>
<STRONG>Author(s):</STRONG> Jes&uacute;s Correas.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.9#65 (2003/3/14, 12:48:10 CET)


<P>
 
<A NAME="IDX7523"></A>
<A NAME="IDX7524"></A>
This module defines the Prolog side of the Java to Prolog interface. This side of the interface only has one public predicate: a server that listens at the socket connection with Java, and executes the commands received from the Java side. 


<P>
In order to evaluate the goals received from the Java side, this module can work in two ways: executing them in the same engine, or starting a thread for each goal. The easiest way is to launch them in the same engine, but the goals must be evaluated sequentially: once a goal provides the first solution, all the subsequent goals must be finished before this goal can backtrack to provide another solution. The Prolog side of this interface works as a top-level, and the goals partially evaluated are not independent. 


<P>
The solution of this goal dependence is to evaluate the goals in a different prolog engine. Although Ciao includes a mechanism to evaluate goals in different engines, the approach used in this interface is to launch each goal in a different thread. 


<P>
The decision of what kind of goal evaluation is selected is done by the Java side. Each evaluation type has its own command terms, so the Java side can choose the type it needs. 


<P>
A Prolog server starts by calling the <CODE>prolog_server/0</CODE> predicate, or by calling <CODE>prolog_server/1</CODE> predicate and providing the port number as argument. The user predicates and libraries to be called from Java must be included in the executable file, or be accesible using the built-in predicates dealing with code loading. 



<UL>
<LI><A HREF="ciao_159.html#SEC671">Usage and interface (jtopl)</A>
<LI><A HREF="ciao_159.html#SEC672">Documentation on exports (jtopl)</A>
</UL>



<H2><A NAME="SEC671" HREF="ciao_toc.html#TOC671">Usage and interface (<CODE>jtopl</CODE>)</A></H2>

<div class="cartouche">

<UL>

<LI><STRONG>Library usage:</STRONG>

<CODE>:- use_module(library(jtopl)).</CODE>

<LI><STRONG>Exports:</STRONG>


<UL>

<LI><EM>Predicates:</EM>

<A NAME="IDX7525"></A>
<CODE>prolog_server/0</CODE>, 
<A NAME="IDX7526"></A>
<CODE>prolog_server/1</CODE>, 
<A NAME="IDX7527"></A>
<CODE>prolog_server/2</CODE>, 
<A NAME="IDX7528"></A>
<CODE>shell_s/0</CODE>, 
<A NAME="IDX7529"></A>
<CODE>query_solutions/2</CODE>, 
<A NAME="IDX7530"></A>
<CODE>query_requests/2</CODE>, 
<A NAME="IDX7531"></A>
<CODE>running_queries/2</CODE>.

</UL>

<LI><STRONG>Other modules used:</STRONG>


<UL>

<LI><EM>System library modules:</EM>

<A NAME="IDX7532"></A>
<CODE>concurrency/concurrency</CODE>, 
<A NAME="IDX7533"></A>
<CODE>system</CODE>, 
<A NAME="IDX7534"></A>
<CODE>read</CODE>, 
<A NAME="IDX7535"></A>
<CODE>write</CODE>, 
<A NAME="IDX7536"></A>
<CODE>dynamic</CODE>, 
<A NAME="IDX7537"></A>
<CODE>lists</CODE>, 
<A NAME="IDX7538"></A>
<CODE>format</CODE>, 
<A NAME="IDX7539"></A>
<CODE>compiler/compiler</CODE>, 
<A NAME="IDX7540"></A>
<CODE>atom2term</CODE>, 
<A NAME="IDX7541"></A>
<CODE>javall/javasock</CODE>, 
<A NAME="IDX7542"></A>
<CODE>prolog_sys</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC672" HREF="ciao_toc.html#TOC672">Documentation on exports (<CODE>jtopl</CODE>)</A></H2>
<P>
<A NAME="IDX7543"></A>
<A NAME="IDX7544"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>prolog_server/0:</B>
<DD><A NAME="IDX7545"></A>


<P>
<STRONG>Usage:</STRONG> 

<UL>
<LI><EM>Description:</EM> Prolog server entry point. Reads from the standard input the node name and port number where the java client resides, and starts the prolog server listening at the jp socket. This predicate acts as a server: it includes an endless read-process loop until the <CODE>prolog_halt</CODE> command is received.

However, from the low-level communication point of view, this Prolog server actually works as a client of the Java side. This means that Java side waits at the given port to a Prolog server trying to create a socket; Prolog side connects to that port, and then waits for Java requests (acting as a 'logical' server). To use this Prolog server as a real server waiting for connections at a given port, use <CODE>prolog_server/1</CODE>. 

<A NAME="IDX7546"></A>
<A NAME="IDX7547"></A>
 
</UL>

</DL>

<P>
<A NAME="IDX7548"></A>
<A NAME="IDX7549"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>prolog_server/1:</B>
<DD><A NAME="IDX7550"></A>


<P>
<STRONG>Usage:</STRONG> 

<UL>
<LI><EM>Description:</EM> Waits for incoming Java connections to act as a Prolog goal server for Java requests.This is the only <CODE>prolog_server/*</CODE> predicate that works as a true server: given a port number, waits for a connection from Java and then serves Java requests. When a termination request is received, finishes the connection to Java and waits next Java connection request. This behaviour is different with respect to previous versions of this library. To work as before, use <CODE>prolog_server/2</CODE>.

Although it currently does not support simultaneous Java connections, some work is being done in that direction. 
<A NAME="IDX7551"></A>
<A NAME="IDX7552"></A>
 
<LI><EM>Call and exit should be <EM>compatible</EM> with:</EM>

<CODE>Arg1</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX7553"></A>
<A NAME="IDX7554"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>prolog_server/2:</B>
<DD><A NAME="IDX7555"></A>


<P>
<STRONG>Usage:</STRONG> 

<UL>
<LI><EM>Description:</EM> Prolog server entry point. Given a network <CODE>node</CODE> and a <CODE>port</CODE> number, starts the prolog server trying to connect to Java side at that <CODE>node:port</CODE> address, and then waits for Java requests. This predicate acts as a server: it includes an endless read-process loop until the <CODE>prolog_halt</CODE> command is received.

However, from the low-level communication point of view, this Prolog server actually works as a client of the Java side. This means that Java side waits at the given port to a Prolog server trying to create a socket; Prolog side connects to that port, and then waits for Java requests (acting as a 'logical' server). To use this Prolog server as a real server waiting for connections at a given port, use <CODE>prolog_server/1</CODE>. 
<A NAME="IDX7556"></A>
<A NAME="IDX7557"></A>
 
<LI><EM>Call and exit should be <EM>compatible</EM> with:</EM>

<CODE>Arg1</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)

<CODE>Arg2</CODE> is an atom.
 (<CODE>basic_props:atm/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX7558"></A>
<A NAME="IDX7559"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>shell_s/0:</B>
<DD><A NAME="IDX7560"></A>


<P>
<STRONG>Usage:</STRONG> 

<UL>
<LI><EM>Description:</EM> Command execution loop. This predicate is called when the connection to Java is established, and performs an endless loop processing the commands received. This predicate is only intended to be used by the Prolog to Java interface and it should not be used by a user program.

</UL>

</DL>

<P>
<A NAME="IDX7561"></A>
<A NAME="IDX7562"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>query_solutions/2:</B>
<DD><A NAME="IDX7563"></A>


<P>
No further documentation available for this predicate.


<P>
The predicate is of type <EM>concurrent</EM>.


</DL>

<P>
<A NAME="IDX7564"></A>
<A NAME="IDX7565"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>query_requests/2:</B>
<DD><A NAME="IDX7566"></A>


<P>
No further documentation available for this predicate.


<P>
The predicate is of type <EM>concurrent</EM>.


</DL>

<P>
<A NAME="IDX7567"></A>
<A NAME="IDX7568"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>running_queries/2:</B>
<DD><A NAME="IDX7569"></A>


<P>
No further documentation available for this predicate.


<P>
The predicate is of type <EM>concurrent</EM>.


</DL>

<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_158.html">previous</A>, <A HREF="ciao_160.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>