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
start(
+Options)
start/[0,1]
will not return until a server shutdown
occurs. Options should be a list of zero or more of:
port(
?Val)
get_server_property/1
, typically from a
server_started
event listener.
accepted_hosts(
+Val)
['127.0.0.1']
).
session_timeout(
+Val)
0
).
session_gc_timeout(
+Val)
0
).
For example:
:- start([port(7500), accepted_hosts(['127.0.0.1','99.8.7.6'])]).
shutdown
shutdown(+Mode)
now
no_sessions
no_connections
register_query(
+Query,
:PredicateToCall,
+SessionVar)
Query
will be removed (as if unregister_query(Query)
was called). The predicate,
PredicateToCall
will be called, as if by
once(PredicateToCall)
, when a query matching
Query
is received. 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.
unregister_query(
+Query)
session_get(
+SessionID,
+ParameterName,
+DefaultValue,
-Value)
session_put(
+SessionID,
+ParameterName,
+Value)
session_put/3
will not be undone when backtracking (the current
implementation is based on assert
). Arguments:
register_event_listener(
+Event,
:PredicateToCall,
-Id)
register_event_listener(
+Event,
:PredicateToCall)
once(
PredicateToCall)
) 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_error
but the failure
or exception is otherwise ignored. Arguments:
unregister_event_listener/1
to remove this event listener.
The predefined events are as follows:
session_started(
+SessionID)
session_ended(
+SessionID)
server_started
server_shutdown
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_event_listener(
+Id)
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.