public class ProvaCommunicatorImpl extends java.lang.Object implements ProvaCommunicator
| Modifier and Type | Field and Description |
|---|---|
static boolean |
ASYNC |
static boolean |
SYNC |
| Constructor and Description |
|---|
ProvaCommunicatorImpl(ProvaMiniService service,
java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async,
java.util.Map<java.lang.String,java.lang.Object> globals) |
ProvaCommunicatorImpl(java.lang.String agent,
java.lang.Object rules,
boolean async) |
ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async) |
ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async,
java.util.Map<java.lang.String,java.lang.Object> globals)
A preferred constructor for a Communicator.
|
ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async,
ProvaAgent esb,
java.util.Map<java.lang.String,java.lang.Object> globals) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMsg(ProvaList terms) |
void |
addMsg(java.lang.String xid,
java.util.Map<java.lang.String,java.lang.Object> msg) |
void |
addMsg(java.lang.String xid,
java.lang.String agent,
java.lang.String verb,
java.lang.Object payload) |
void |
consultAsync(java.io.BufferedReader in,
java.lang.String key,
java.lang.Object[] objects)
A wrapper for an asynchronous query to the rulebase
|
void |
consultAsync(java.lang.String src,
java.lang.String key,
java.lang.Object[] objects)
A wrapper for an asynchronous query to the rulebase
|
java.util.List<ProvaSolution[]> |
consultSync(java.io.BufferedReader in,
java.lang.String key,
java.lang.Object[] objects)
A wrapper for a synchronous query to the rulebase
|
java.util.List<ProvaSolution[]> |
consultSync(java.lang.String src,
java.lang.String key,
java.lang.Object[] objects)
A wrapper for a synchronous query to the rulebase
|
java.util.List<ProvaSolution[]> |
getInitializationSolutions() |
ProvaReagent |
getReagent() |
static void |
main(java.lang.String[] args)
The main Prova Reloaded runner.
|
java.lang.Object |
sendMsg(java.lang.String xid,
java.lang.String protocol,
java.lang.Object obj_receiver,
java.lang.String perf,
java.lang.String term,
java.lang.Object[] objs)
Send a message to an asynchronous Prova agent
(inluding a local
Communicator created in asynchronous mode) |
void |
setGlobalConstant(java.lang.String name,
java.lang.Object value) |
void |
setMessenger(ProvaMessenger messenger) |
void |
setPrintWriter(java.io.PrintWriter printWriter) |
void |
shutdown() |
void |
stop() |
void |
unconsultSync(java.lang.String src) |
public static final boolean ASYNC
public static final boolean SYNC
public ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async)
agent - A logical name of the Prova agent (must be unique on each machine)port - An external port used for JADE communications. If port is
null, JADE communication is not usedrules - There are three options to use here:
Object is a String, it must be a filename of
the file to be consulted.
StringBuffer or a BufferedReader,
from which the initial rulebase will be consulted.async - If it is ProvaCommunicator.ASYNC, the Communicator is started in a separate thread.
ProvaCommunicator.SYNC, it is started in the current thread.public ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async,
java.util.Map<java.lang.String,java.lang.Object> globals)
agent - A logical name of the Prova agent (must be unique on each machine)port - An external port used for JADE communications. If port is
null, JADE communication is not usedrules - There are three options to use here:
Object is a String, it must be a filename of
the file to be consulted.
StringBuffer or a BufferedReader,
from which the initial rulebase will be consulted.async - If it is ProvaCommunicator.ASYNC, the Communicator is started in a separate thread.
ProvaCommunicator.SYNC, it is started in the current thread.globals - map of arguments passed to the initialisation rulebasepublic ProvaCommunicatorImpl(java.lang.String agent,
java.lang.String port,
java.lang.Object rules,
boolean async,
ProvaAgent esb,
java.util.Map<java.lang.String,java.lang.Object> globals)
public ProvaCommunicatorImpl(java.lang.String agent,
java.lang.Object rules,
boolean async)
public ProvaCommunicatorImpl(ProvaMiniService service, java.lang.String agent, java.lang.String port, java.lang.Object rules, boolean async, java.util.Map<java.lang.String,java.lang.Object> globals)
public void stop()
stop in interface ProvaCommunicatorpublic java.util.List<ProvaSolution[]> getInitializationSolutions()
getInitializationSolutions in interface ProvaCommunicatorpublic java.util.List<ProvaSolution[]> consultSync(java.lang.String src, java.lang.String key, java.lang.Object[] objects) throws java.lang.Exception
consultSync in interface ProvaCommunicatorsrc - File name or URL with a rulebase to be consulted.
key - Unique key identifying the consulted code (useful in interactive environments)objects - Java objects embedded into the input parameter.org.provarules.kernel.ProvaResultSet objects,
where each result set corresponds to one goal in the consulted code.
For one goal, each resultset contains zero or more solutions with instantiations of all
free variables in that goal.java.lang.Exception - Any exception from running the rulebasepublic java.util.List<ProvaSolution[]> consultSync(java.io.BufferedReader in, java.lang.String key, java.lang.Object[] objects)
consultSync in interface ProvaCommunicatorin - BufferedReader wrapping access to the rulebase to be consulted.
key - Unique key identifying the consulted code (useful in interactive environments)objects - Java objects embedded into the input parameter.org.provarules.kernel.ProvaResultSet objects,
where each result set corresponds to one goal in the consulted code.
For one goal, each resultset contains zero or more solutions with instantiations of all
free variables in that goal.public void consultAsync(java.lang.String src,
java.lang.String key,
java.lang.Object[] objects)
throws java.lang.Exception
consultAsync in interface ProvaCommunicatorsrc - File name or URL with a rulebase to be consulted.
key - Unique key identifying the consulted code (useful in interactive environments)objects - Java objects embedded into the input parameter.java.lang.Exception - Any exception from running the rulebasepublic void consultAsync(java.io.BufferedReader in,
java.lang.String key,
java.lang.Object[] objects)
throws java.lang.Exception
consultAsync in interface ProvaCommunicatorin - BufferedReader wrapping access to the rulebase to be consulted.
key - Unique key identifying the consulted code (useful in interactive environments)objects - Java objects embedded into the input parameter.java.lang.Exception - Any exception from running the rulebasepublic void setPrintWriter(java.io.PrintWriter printWriter)
setPrintWriter in interface ProvaCommunicatorpublic java.lang.Object sendMsg(java.lang.String xid,
java.lang.String protocol,
java.lang.Object obj_receiver,
java.lang.String perf,
java.lang.String term,
java.lang.Object[] objs)
Communicator created in asynchronous mode)xid - Conversation-id for the message. Specifying null starts a new
conversation. Otherwise, it is assumed that the message is a follow-up to the conversation
with the specified conversation-id. Use %0 to pass an object here.protocol - Currently, "self", "jade", or "jms". For sending messages
to the Prova engine in this Communicator, specify "self".obj_receiver - The logical name of the target agent. Specifying "0" here results
in sending this message to the Prova agent in this Communicator (it is)
equivalent to specifying the protocol as "self".perf - Performative, i.e., speech act communicated by the message.
Broadly speaking, it is the "type" of the message. Examples include
standard FIPA performatives such as query-ref, ask-if, or inform.term - The message contents as a String. It is assumed to be
a comma-separated list with various tags and parameters to the message. Java objects
may be embedded by using placeholders in the format %N with N corresponding to an index
into the array with objects in objs.objs - Array with Java objects to be embedded in the locations specified by
placeholders in the message contents term.public static void main(java.lang.String[] args)
Example: prova3[.bat|.sh] agent password rules/rules/test001_args.prova anticoagulant
args - String[]public void shutdown()
shutdown in interface ProvaCommunicatorpublic ProvaReagent getReagent()
getReagent in interface ProvaCommunicatorpublic void addMsg(ProvaList terms)
addMsg in interface ProvaCommunicatorpublic void addMsg(java.lang.String xid,
java.util.Map<java.lang.String,java.lang.Object> msg)
addMsg in interface ProvaCommunicatorpublic void addMsg(java.lang.String xid,
java.lang.String agent,
java.lang.String verb,
java.lang.Object payload)
addMsg in interface ProvaCommunicatorpublic void unconsultSync(java.lang.String src)
unconsultSync in interface ProvaCommunicatorpublic void setGlobalConstant(java.lang.String name,
java.lang.Object value)
setGlobalConstant in interface ProvaCommunicatorpublic void setMessenger(ProvaMessenger messenger)
setMessenger in interface ProvaCommunicatorCopyright © 2019. All Rights Reserved.