The Prolog interface is based on the idea of a Prolog server that provides its service by answering queries from external applications (typically Java applications). The Prolog interface in PrologBeans is defined in library(prologbeans), which implements the Prolog server and exports the following predicates:
start/[0,1]will not return until a server shutdown occurs. Options should be a list of zero or more of:
get_server_property/1, typically from a
:- start([port(7500), accepted_hosts(['127.0.0.1','126.96.36.199'])]).
)). The goal PredicateToCall will be called when a query matching Query is received.
Typically, Query and PredicateToCall share variables that
are instantiated by the call, and the instantiated Query
is passed back to the client. In general, variable bindings can be
arbitrary Prolog terms, including terms containing unbound variables.
However, any unbound variables with attributes or blocked goals
attached to them will be replaced by plain, brand new variables. This
is analogous to the way attributed variables are handled in terms that are
written, copied, asserted, gathered as solutions to
and friends, or raised as exceptions. If the attributes must be passed
to the client, the Prolog code can obtain them by using
copy_term/3 (see ref-lte-cpt).
The goal is called determinately, i.e. it is never backtracked into.
If it fails, the term
no is passed to the client instead of the
instantiated Query. If it raises an exception E,
) is passed to the client instead of the
Before calling the query, the variable SessionVar, if
given, is bound to the id of the current session. Session ids are
typically generated in web applications that track users and mark all
consecutive web-accesses with the same session id.
session_put/3will not be undone when backtracking (the current implementation is based on
)) when the event matching Event occurs (event matching is on principal functor only). If the goal fails or raises an exception a warning is written to
user_errorbut the failure or exception is otherwise ignored. Arguments:
unregister_event_listener/1to remove this event listener.
The predefined events are as follows:
Attempt to register an event listener for other events than the predefined events will throw an exception.
More than one listeners can be defined for the same event. They will be
called in some unspecified order when the event occurs.
Unregister a previously registered event listener. The Id is the
value returned by the corresponding call to
register_event_listener/3. It is an error to attempt to
unregister an event listener more than once.