public class TransientAgent extends AbstractProcess implements TransientAgentInterface, Observer
Base abstract class for all classes to exhibit Agent behavior. Contains basic methods for registering/unregistering Agents with a LAC or YellowPages, as well as the runnable functions to implement the perspectives necessary to accomplish these tasks.
The most important function of Transient agent is handling events coming out
of the even queue through the handleEvent(Event)
method (which
overrides AbstractProcess.handleEvent(Event)
). Equally important is
the implementation of the processCommitments()
which is called by
AbstractProcess
when there is nothing in the event queue to process
(and there's time to do other things).
The major methods that subclass might consider overriding for various
functions are as follows. There are others that you can override to deal with
activity you want to occur during idle periods or periodically - see the
top-level documentation of AbstractProcess
.
The following table lists some of the methods a subclass may want to override
(be sure to call the super method). See AbstractProcess
for a others.
Method | Thread | Description |
---|---|---|
initializeThread(ParamsMap, AgentUI) |
agent | called just before the message loop begins; the agent is not fully
initialized at this point -- it's not yet registered with the LAC. You can
override this method to deal with qualifiers specific to your agent. See
AbstractProcess.initializeThread(ParamsMap, AgentUI) and the
top-level documentation of AbstractProcess for more detail.
|
initializeAfterRegistered(boolean) |
agent | called just after the agent is registered with the LAC -- the agent is now fully initialized. |
This class gets its conversational definitions from a lisp definition in /dataFiles/casa.TransientAgent.init.lisp, and it's ontology definition from /dataFiles/casa.TransientAgent.ont.lisp.
All subclasses of TransientAgent must statically call
createCasaLispOperators(java.lang.Class<? extends casa.TransientAgent>)
to create automatically
CasaLispOperator
s for methods annotated with
LispAccessible
.
AbstractProcess
Modifier and Type | Class and Description |
---|---|
private class |
TransientAgent.abclEvalInAgentThread
LISP OPERATORS, ETC.
|
(package private) class |
TransientAgent.Conversations
This class assures that conversations in the list of conversations will
eventually be released to free memory.
|
protected static class |
TransientAgent.NewAgentLispCommand
Class to implement the (OPTIONS ...) lisp command.
|
private class |
TransientAgent.UIStarter |
AbstractProcess.Subthread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
private static CasaLispOperator |
ADD__SINGLE__NUM__VALUE__KBFILTER |
private static CasaLispOperator |
AGENT__ASYNC
Lisp operator: (AGENT.ASYNC command)
Sends a EXECUTE message to agent-name. |
private static CasaLispOperator |
AGENT__CREATE_EVENT_OBSERVER_EVENT
Lisp operator: (AGENT.CREATE-EVENT-OBSERVER-EVENT)
Create an EventObserverEvent |
private static CasaLispOperator |
AGENT__DELETE_POLICY
Lisp operator: (AGENT.DELETE-POLICY)
Deletes a policy if it has one. |
private static CasaLispOperator |
AGENT__EXIT
Lisp operator: (EXIT)
List the current event queue. |
private static CasaLispOperator |
AGENT__FIND_FILE_RESOURCE_PATH
Lisp operator: (Find {property-name})
Sets the string value of a system property\. Lambda List: &OPTIONAL (PROPERTY "all") PROPERTY [optional def=all] string name of the system property to show (or 'all' to display and return NIL) |
private static CasaLispOperator |
AGENT__GET_AGENT
Lisp operator: (GET-URL)
Returns the agent's url as a string |
private static CasaLispOperator |
AGENT__GET_AGENTS_REGISTERED
Lisp operator: (GET-AGENTS-REGISTERED)
Sends a message to the LAC requesting the registered agents. |
private static CasaLispOperator |
AGENT__GET_AGENTS_RUNNING
Lisp operator: (GET-AGENTS-RUNNING)
Sends a message to the LAC requesting the running agents. |
private static CasaLispOperator |
AGENT__GET_CLASS_NAME
Lisp operator: (AGENT.GET-CLASS-NAME)
Return the class name of the agent. |
private static CasaLispOperator |
AGENT__GET_MSG_OBJ
Lisp operator: (EVENT.GET-MSG-OBJ)
Return the message object |
private static CasaLispOperator |
AGENT__GET_POLICIES
Lisp operator: (AGENT.GET-POLICIES)
Returns the agent's policies formated as a string |
private static CasaLispOperator |
AGENT__GET_URL
Lisp operator: (AGENT__GET-URL)
Returns the agent's url as a string |
private static CasaLispOperator |
AGENT__GETUSEACKPROTOCOL
Lisp operator: (GETUSEACKPROTOCOL)
Return T if the agent is using the ACK parotocol, otherwise return Nil. |
private static CasaLispOperator |
AGENT__INSTANTIATE_CONVERSATION |
private static CasaLispOperator |
AGENT__ISA
Lisp operator: (AGENT.ISA)
Add a policy to the agent's global policy repetoire |
private static CasaLispOperator |
AGENT__JOIN
Lisp operator: (AGENT.JOIN CD-url)
Attempt to join the cooperation domain specified by the parameter URL. |
private static CasaLispOperator |
AGENT__LOAD_FILE_RESOURCE
Lisp operator: (AGENT.LOAD-FILE-RESOURCE)
Ping another agent given by URL, waiting up to TIMEOUT milliseconds for the response if it doesn't come sooner. |
private static CasaLispOperator |
AGENT__MAKE_CONVERSATION_ID
Lisp operator: make-conversation-id
Returns a unique String conversation identifier |
private static CasaLispOperator |
AGENT__MESSAGE |
private static TransientAgent.NewAgentLispCommand |
AGENT__NEW_AGENT |
private static CasaLispOperator |
AGENT__NEW_INTERFACE
Lisp operator: (NEW-INTERFACE)
|
private static CasaLispOperator |
AGENT__OPTIONS
Lisp operator: (OPTIONS ...)
Show or set options. |
private static CasaLispOperator |
AGENT__PAUSE
Lisp operator: (PAUSE)
Pause the agent just after processing a message. |
private static CasaLispOperator |
AGENT__PING
Lisp operator: (AGENT.PING)
Ping another agent given by URL, waiting up to TIMEOUT milliseconds for the response if it doesn't come sooner. |
private static CasaLispOperator |
AGENT__PRINTLN
Lisp operator: (PAUSE)
Pause the agent just after processing a message. |
private static CasaLispOperator |
AGENT__PUT_POLICY
Lisp operator: (PUT-POLICY)
Add a policy to the agent's global policy repetoire |
private static CasaLispOperator |
AGENT__REPLY
Lisp operator: (AGENT.REPLY MLMessage {PerformDescriptor} :[{*}key] [value]
...)
|
private static CasaLispOperator |
AGENT__RESET_DEF_FILE_SYSTEM_LOCATIONS
Lisp operator: (Find {property-name})
Sets the string value of a system property\. Lambda List: &OPTIONAL (PROPERTY "all") PROPERTY [optional def=all] string name of the system property to show (or 'all' to display and return NIL) |
private static CasaLispOperator |
AGENT__RESUME
Lisp operator: (RESUME)
Resume the agent from a pause state. |
private static CasaLispOperator |
AGENT__SEND
Lisp operator: (SEND agent-url ...)
Sends a EXECUTE message to agent-name. |
private static CasaLispOperator |
AGENT__SEND_QUERY_AND_WAIT
Lisp operator: (AGENT.SEND-QUERY-AND-WAIT)
Create an EventObserverEvent |
private static CasaLispOperator |
AGENT__SEND_REQUEST_AND_WAIT
Lisp operator: (AGENT.SEND-REQUEST-AND-WAIT)
Create an EventObserverEvent |
private static CasaLispOperator |
AGENT__SHOW_COMMITMENTS
Lisp operator: (SHOW-COMMITMENTS)
Show the agent's current social commitments. |
private static CasaLispOperator |
AGENT__SHOW_CONVERSATIONS
Lisp operator: (SHOW-CONVERSATIONS)
Show the agent's current conversations. |
private static CasaLispOperator |
AGENT__SHOW_EVENTQUEUE
Lisp operator: (SHOW-EVENTQUEUE)
List the current event queue. |
private static CasaLispOperator |
AGENT__STEP
Lisp operator: (STEP)
Resume the agent from a pause state until just after processing the next message. |
private static CasaLispOperator |
AGENT__STOP_EVENT_OBSERVER_EVENT
Lisp operator: (AGENT.STOP-EVENT-OBSERVER-EVENT)
Stop an existing EventObserverEvent |
private static CasaLispOperator |
AGENT__TELL
Lisp operator: (TELL agent-url ...)
Sends a REQUEST/EXECUTE message to the given agent-url. |
private static CasaLispOperator |
AGENT__TRANSFORM
Lisp operator: (AGENT.TRANSFORM)
Returns the transformed object, or the argument argument if no transformation is applicable |
private static CasaLispOperator |
AGENT__TRANSFORM_STRING
Lisp operator: (AGENT.TRANSFORM-STRING)
Returns the transformed string, or the argument string if no transformation is applicable |
private static ThreadLocal<TransientAgent> |
agentForThread
Should be used only by
#abclEval(String, Map to allow Lisp operator access to thread-local data
through getUIForThread() . |
private static CasaLispOperator |
ASSERT |
private String |
banner |
static CasaKB |
cacheKB |
private static CasaLispOperator |
CALL_GC |
URLDescriptor |
CDInvitedTo |
URLDescriptor |
CDinvitee |
private CommitmentProcessor |
commitmentProcessor
The IdleProcessor who's doIdle() method is called in doIdle(); created by
the MHFactory factory.
|
private static CasaLispOperator |
COMPARETO
Lisp operator: (COMPARETO)
List the current event queue. |
protected ConcurrentSkipListMap<String,Object> |
conversationData |
private TransientAgent.Conversations |
conversations |
private Hashtable<URLDescriptor,Vector<URLDescriptor>> |
cooperationDomainMembers
A
Hashtable linking the URLDescriptor of a
cooperation domain to a Vector of the participants (
URLDescriptor s) of that cooperation domain. |
static String |
defaultOntologyClassName |
static int |
DEFER_ACTION
Used by consider_*(), verify_*(), perform_*(), release_*(), conclude_*(),
etc-type methods to signal that the action is not yet ready to be executed,
and that the method should be called again later.
|
private static String[] |
defFileSystemLocations
To be used only by
getDefFileSystemLocations() and
resetDefFileSystemLocations() . |
static int |
DROP_ACTION
Used by consider_*(), verify_*(), perform_*(), release_*(), conclude_*(),
etc-type methods to signal that the action should be discarded -- ie: no
action should be taken and the message should be allowed by timeout when
the REPLY-BY expires.
|
private static CasaLispOperator |
EVENT__GET
Lisp operator: (EVENT.GET)
Return the event object. |
private static CasaLispOperator |
EVENT__GET_MSG
Lisp operator: (EVENT.GET-MSG)
Return the value. |
private static CasaLispOperator |
EVENT__GET_OWNER_CONVERSATION_ID
Lisp operator: (EVENT.GET-OWNER-CONVERSATION-ID)
Return the event's owner conversation ID, if it has one |
private static CasaLispOperator |
GET_OBJECT
Deprecated.
|
private static CasaLispOperator |
GET_SYSTEM
Lisp operator: (GET-SYSTEM {property-name})
Either return the string value of a system property, or display all system properties (returning NIL). Lambda List: &OPTIONAL (PROPERTY "all") PROPERTY [optional def=all] string name of the system property to show (or 'all' to display and return NIL) |
private static CasaLispOperator |
GET_THREAD
Lisp operator: (GET-THREAD)
Returns the agent's url as a string |
private StatusURLDescriptorList |
instancesFound |
private ConcurrentSkipListSet<URLDescriptor> |
joinedCooperationDomains
A
Vector of all of the cooperation domains (
URLDescriptor s) that this agent has successfully joined. |
private static CasaLispOperator |
KB__QUERY_IF |
private static CasaLispOperator |
KB_ARG_DESC |
private static CasaLispOperator |
KB_DEFINE_ONTOLOGY_FILTER |
private static CasaLispOperator |
KB_SHOW |
CasaKB |
kBase |
private byte[] |
key |
private static int |
KEY_LENGTH |
(package private) static Interpreter |
lisp |
(package private) Environment |
lispEnvironment
Can be used to store Symbols in the lisp environment specifically for this
agent.
|
protected static List<OntologyFilterArgument> |
ListOfArgs |
(package private) Map<String,Method> |
methodMap |
private static ThreadLocal<Map<String,Object>> |
objectsForThread
Should be used only by
#abclEval(String, Map allow Lisp operator access to thread-local data
through getUIForThread() . |
(package private) String |
ontologyEngine |
protected Method |
ontologyEngineCreateMethod |
protected Method |
ontologyEngineLoadMethod |
private TreeSet<MLMessage> |
outstandingRequests
Used to record all outgoing
requests to match against
incomming reply-requests (and then remove them). |
protected PolicyContainer |
policies
strategy object chain for dealing with 'reactive' or 'socialcommitments'
protocol agents.
|
protected PolicyContainer |
policiesAlwaysApply |
protected PolicyContainer |
policiesLastResort |
protected AgentUI |
primaryUI
Although there may be several observing UIs, this one is the first
registered and will be considered the primary one which the agent may use.
|
private static Set<String> |
privateTerms |
protected AgentProxy |
proxy |
private int |
proxyPort |
private static CasaLispOperator |
QUERYREF |
private int |
realPort |
private URLDescriptor |
registeredWithLAC |
private static CasaLispOperator |
SERIALIZE
Lisp operator: (SERIALIZE object)
Return the casa serialization string for the object |
private static CasaLispOperator |
SET_SYSTEM
Lisp operator: (SET-SYSTEM {property-name})
Sets the string value of a system property\. Lambda List: &OPTIONAL (PROPERTY "all") PROPERTY [optional def=all] string name of the system property to show (or 'all' to display and return NIL) |
private ArrayList<Event> |
subscribeEvents |
private static ThreadLocal<AgentUI> |
uiForThread
Should be used only by
#abclEval(String, Map allow Lisp operator access to thread-local data
through getUIForThread() . |
protected Vector<AgentUI> |
UIs |
private long |
uniqueNumber |
protected boolean |
usingProxy |
private boolean |
usingSecureProxy |
private TreeMap<URLDescriptor,String> |
watchedCooperationDomains
A
TreeMap of all of the cooperation domains (
URLDescriptor s) that this agent is "watching" to the
conversation IDs that "remember" the subscription. |
eventQueue, exitWaitCounter, heartbeat, huntForPort, initParams, ontology, ontologyShared, options, securityFilter, trace, TRACE_MONITOR, TRACE_OFF, TRACE_ON, TRACE_TO_FILE, TRACE_UNDEFINED, transformations, uniqueThreadName, waitingForAgentToStart, waitingForEvent, waitingForSocketServerToStart
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
TransientAgent(ParamsMap params,
AgentUI ui)
Calls the parent constructor
AbstractProcess.AbstractProcess(ParamsMap, AgentUI, int) with the
port (2nd) argument modified: iff proxies are specified in
quals then the port is decremented to make room for the proxies. |
Modifier and Type | Method and Description |
---|---|
Status |
abclEval(Cons cons,
Map<String,LispObject> lispBindings) |
Status |
abclEval(String c,
Map<String,LispObject> lispBindings) |
Status |
abclEval(String c,
Map<String,LispObject> newEnvBindings,
AgentUI ui)
Executes lisp code and returns a result.
|
protected PerformDescriptor |
accept_deleteCD(MLMessage msg)
Called when a CD this agent is a member of is in the process of exiting:
the behaviour is to withdraw from that CD.
|
PerformDescriptor |
accept_exit(MLMessage msg)
Process an incoming inform message for a exit act.
|
protected PerformDescriptor |
accept_forward_message(MLMessage m)
Responds to a received forward.message inform message by passing on the
message encapsulated in the content part of the message.
|
protected PerformDescriptor |
accept_LAC_closing(MLMessage m)
Responds to a received
inform / LAC_closing inform message by passing on the message encapsulated in the
content part of the message. |
protected PerformDescriptor |
accept_new_MenuItem(MLMessage message)
The code for responding to an
inform message. |
protected PerformDescriptor |
accept_update(MLMessage message) |
protected PerformDescriptor |
acceptDefault(MLMessage message)
The default code for responding to an outging
agree
message. |
void |
addConversation(String convID,
Conversation conv) |
void |
addJoinedCooperationDomain(URLDescriptor url) |
Vector<URLDescriptor> |
addMembers(URLDescriptor cd,
Vector<URLDescriptor> urls) |
private void |
addRequest(MLMessage msg)
Inserts msg input this list of outstanding requests.
Precondition: msg needs to be a subtype of ML.REQUEST or ML.ACCEPT_PROPOSAL . |
void |
addSubscribeEvents(Event event) |
protected PerformDescriptor |
assembleDefault(MLMessage message)
The default code for dealing with a
proxy message. |
Formula |
assert_(String formula) |
Formula |
assert_(String formula,
CasaKB cacheKB) |
protected boolean |
authorizedByProxy(MLMessage msg) |
boolean |
authorizeMessage(MLMessage msg)
Determines whether the given message should be handled by receiveMessage,
or if it should be thrown out.
|
private static int |
calculatePortAccountingForProxies(ParamsMap params,
AgentUI ui) |
private PerformDescriptor |
callHandlerMethod(MLMessage message,
String methodName)
Calls a method on
this with the specified name, passing it the
given MLMesssage, and returning a PerformDescriptor. |
private void |
callInitializeAfterRegistered(boolean isRegistered)
Utility method to be sure to call
initializeAfterRegistered(boolean) from the agent's thread. |
SocialCommitment |
chooseSC(Collection<SocialCommitment> SocialCommitments) |
protected PerformDescriptor |
concludeDefault(MLMessage message)
The default code for responding to a
reply-proposal message. |
PerformDescriptor |
consider_execute(MLMessage message)
The code for responding to an
request message. |
protected PerformDescriptor |
consider_invite_to_cd(MLMessage message)
The code for responding to an
request message. |
protected PerformDescriptor |
consider_new_MenuItem(MLMessage message)
|
protected PerformDescriptor |
consider_ping(MLMessage message)
The code for responding to an
request message. |
PerformDescriptor |
consider_query_if(MLMessage m)
Responds to a query-ref message by interpreting the act field, attempting
to execute it, and returning a message with the result.
|
PerformDescriptor |
consider_query_ref(MLMessage m)
Responds to a query-ref message by interpreting the act field, attempting
to execute it, and returning a message with the result.
|
protected PerformDescriptor |
considerDefault(MLMessage message)
The default code for responding to an
request message or
a ML#PROPOSE_DISCHARGE message. |
static void |
createCasaLispOperators(Class<? extends TransientAgent> aClass)
Scan self for
LispAccessible methods. |
private AgentUI |
createNewInterface(TransientAgentInterface agent,
String agentInterfaceName) |
PerformDescriptor |
dispatchMsgHandlerMethod(String consider,
Act act,
MLMessage message)
This method is called (directly or indirectly) in response to a
request -type message. |
Status |
doAddObserver(URLDescriptor observableAgentUrl,
String... types)
Creates a new add_observer request.
|
Status |
doAdvertise(URLDescriptor yp,
ServiceDescriptor service)
This method is called when this agent wishes to advertises a service.
|
StatusMLMessageList |
doCDGetHistory_sync(URLDescriptor cdURL)
Retrieves the history list from a cooperation domain.
|
Status |
doCDGetMembers(URLDescriptor cdURL)
Sends a message to retrieve the list of participants in a the specified
coopertation domain.
|
Status |
doCDPutData(URLDescriptor cdURL,
DataStorageDescriptor dsd)
Attempts to store data with a cooperation domain.
|
Status |
doCDSubscribeMembership(URLDescriptor cdURL,
boolean sense)
Sends a subscribe message to start/stop the observation of membership in a
cooperation domain.
|
StatusURLDescriptorList |
doFindInstances_sync(String pattern)
Attempts to retrieve the list of registered agents that have a path
matching the given regex.
|
Vector<URLDescriptor> |
doGetCooperationDomains(URLDescriptor lac)
Retrieves the list of URLDescriptor's from a LAC.
|
Status |
doGetOnology(URLDescriptor url,
String GET_PERFORMATIVESorGET_ACTS,
String typeName)
Sends a message to retrieve information about the performatives in the
performative type library of another agent.
|
Status |
doInviteToCD(URLDescriptor agent,
URLDescriptor cd,
boolean sense)
Requests an agent to join a particular cooperation domain.
|
Status |
doJoinCD(URLDescriptor cdURL)
Join a cooperation domain.
|
URLDescriptor |
doPing_sync(URLDescriptor agent,
long timeout)
Pings another agent synchronously.
|
Status |
doPing(URLDescriptor agent,
long timeout)
Pings another agent.
|
Status |
doRegisterAgentInstance(int lacPort) |
Status |
doRegisterAgentInstance(int lacPort,
RunnableWithParameter<MLMessage> successAction,
RunnableWithParameter<MLMessage> failureAction)
Registers this Agent with the LAC.
|
Status |
doResolveURL(URLDescriptor url,
long timeout,
Runnable1<String,Status> cmd)
Sends a the request to the appropriate LAC to resolve the URL.
|
StatusURLDescriptorList |
doSearchYP(URLDescriptor yp,
ServiceDescriptor service)
Attempts to search a yellow pages service for a agents matching a
particular service descriptor.
|
Status |
doUnadvertise(URLDescriptor yp,
ServiceDescriptor service)
This method is called when this agent wishes to withdraw a previously
advertised service from a yellow pages service.
|
Status |
doUnregisterAgentInstance(boolean request)
Unregisters this Agent from the LAC.
|
Status |
doUnregisterAgentType(int LACport)
Unregisters this Agent with the LAC.
|
Status |
doWithdrawCD(URLDescriptor cdURL,
boolean request)
Withdraw from a cooperation domain.
|
protected PerformDescriptor |
evaluateDefault(Act act,
MLMessage message) |
PerformDescriptor |
evesdrop(MLMessage msg)
This is the catch-all method called when
ProcessOptions.observeMessages is set true and the handler method
(the regular method concatonated with "_evesdrop") is not found. |
Status |
executeCommand(String command,
AgentUI ui)
Used to execute a command string at runtime.
|
static String |
findFileResourcePath(String fileNameOnly) |
static String |
findFileResourcePath(String fileNameOnly,
String[] dirs)
Attempts to locate the file resource fileNameOnly from the
following places (in this order):
each of the paths specified by
getDefFileSystemLocations() (be
careful of caching here -- call resetDefFileSystemLocations() if
you change system properties "casa.home" or "user.home"). |
private Method |
findMethod(Object object,
String methodName)
Find a method by first looking in the cache, and if it isn't there by
deferring to
getMethodRobustly(Object, String, Class...) to find
it in object using reflection. |
static TransientAgent |
getAgentForThread()
Used by Lisp operators defined as subclasses of
CasaLispOperator to
access thread-local data. |
Policy[] |
getAlwaysApplyPolicies() |
String |
getBanner()
Can be used by UI windows to get a title text
|
CasaKB |
getCachedKnowledgeBase() |
protected SocialCommitment |
getChosenCommitment() |
protected CommitmentProcessor |
getCommitmentProcessor() |
LinkedList<Conversation> |
getConversation(String convID) |
ConcurrentSkipListMap<String,LinkedList<Conversation>> |
getConversations() |
Pair<Integer,String> |
getConversationsReport(boolean current,
int verbose)
Report on this agent's conversations.
|
String |
getDefaultBanner() |
private Ontology |
getDefaultImportOntology() |
static String[] |
getDefFileSystemLocations()
Returns an ordered array of directories to look in when locating system
resources:
the directory specified in the system property "casa.home" (if
"casa.home" is defined)
the directory specified in the system property "casa.home",
subdirectroy "dataFiles" (if "casa.home" is defined)
the directory specified in the system property "user.home",
subdirectory "casa/dataFiles"
the current working directory (".")
This method is used by
findFileResourcePath(String) , which uses
these directories as well as project and system resource paths to find a
file. |
static Event |
getEventForThread()
Used by Lisp operators defined as subclasses of
CasaLispOperator to
access thread-local data. |
static Object |
getField(Object object,
Field field)
Attempts to get the field by first trying to access it through a getter of
the form "get"+name(value) (or "is"+name(value) if the type of the field is
boolean) where the name is the same name as the field, but the first letter
is capitolized.
|
StatusURLDescriptorList |
getInstancesFound() |
Set<URLDescriptor> |
getJoinedCooperationDomain() |
Set<URLDescriptor> |
getJoinedCooperationDomains() |
CasaKB |
getKnowledgeBase()
Returns the default (null) knowledge base.
|
URLDescriptor |
getLACURL()
Returns the URL of the LAC the agent is registered to.
|
Policy[] |
getLastResortPolicies() |
Vector<URLDescriptor> |
getMembers(URLDescriptor cd) |
private Method |
getMethod(String agentParamName,
String methodName,
Class[] params,
String defaultTargetClassName,
Class<?> baseClass,
Class<?> returnType) |
private Method |
getMethodRobustly(Object object,
String methodName,
Class<?>... parameters)
This method retrieves a method from
this even if it is
protected. |
static MLMessage |
getMsgForThread()
Deprecated.
|
static Map<String,Object> |
getObjectsForThread()
Used by Lisp operators defined as subclasses of
CasaLispOperator to
access thread-local data. |
Ontology |
getOntology()
Returns the agent's current ontology.
|
String |
getOntologyEngine() |
private Method |
getOntologyEngineCreateMethod() |
private Method |
getOntologyEngineLoadMethod() |
String |
getOntologyFileSuffix() |
private static Set<String> |
getPermutations(Set<String> a,
Set<String> b) |
Policy[] |
getPolicies() |
AgentUI |
getPrimaryUI() |
private static Class<AgentProxy>[] |
getProxies(ParamsMap params,
AgentUI ui) |
AgentProxy |
getProxy() |
SocialCommitmentsStore |
getSCStore() |
String |
getSerializedOntology()
Returns the String (persistent) representation of the performatives
hiearchy for this agent.
|
String |
getStrategy()
Returns the strategy that this agent uses to interpret messages.
|
JComponent |
getStrategyGUI()
Returns a GUI that can be used to interact with the stategy of this agent.
|
Event[] |
getSubscribeEvents(Event event) |
Event |
getSubscribeEvents(String conversationID) |
static Collection<Term> |
getTermsFromContent(Content cont) |
AgentUI |
getUI() |
static AgentUI |
getUIForThread()
Used by Lisp operators defined as subclasses of
CasaLispOperator to
access thread-local data. |
AgentUI[] |
getUIs() |
Collection<SocialCommitment> |
getUnfulfilledSocialCommitments()
Retrieve all unfulfilled SocialCommitments
|
Collection<SocialCommitment> |
getUnfulfilledSocialCommitments(String id)
Used by Conversations to track their respective SocialCommitments
|
protected Status |
handleErrorReplies(MLMessage msg,
String requestType)
Deal with the various error subtypes of reply by constructing an
appropriate Status (with explanation String).
|
void |
handleEvent(Event event)
Overrides
AbstractProcess.handleEvent(Event) by:
if this is a message event and the CONVERSATION-ID matches one of the
current conversations listed in conversations , pass the event to
that conversation and collect the policies. |
protected Status |
handleLACClosing()
Called when the LAC informs the agent that it is closing.
|
boolean |
hasActiveCommitments() |
boolean |
hasConversation(String convID)
Abstract classes for managing agent conversations.
|
boolean |
hasStrategyGUI()
Used to determine if the agent's strategy has a GUI.
|
void |
initializeAfterRegistered(boolean registered)
Called by handleReply_registerAgentInstance().
|
protected void |
initializePolicies(ParamsMap params,
AgentUI ui)
This method creates and loads the policies for this agent.
|
private void |
initializeProxy(ParamsMap params,
AgentUI ui) |
protected void |
initializeThread(ParamsMap params,
AgentUI ui)
Subclasses may override this method to initialize before the message loop
is called, after the constructor is finished but before control is returned
to the thread that called the constructor.
|
protected void |
initJADE() |
void |
initUI()
Deprecated.
|
protected boolean |
isEventQueueReady()
Determines if the event queue has an event ready to process.
|
boolean |
isRegistered()
If the Agent is registered to a LAC returns true.
|
boolean |
isRegisteredWithLAC() |
boolean |
isStoppable()
determines if this process can be stopped.
|
boolean |
isTrusted(URLDescriptor url,
Node node) |
boolean |
isTrusted(URLDescriptor url,
String node) |
boolean |
isUsingProxy() |
LispObject |
kb_get_value(String attrName) |
private String |
loadFileResource(String fileNameOnly,
boolean reportFailure)
attempts to read fileNameOnly from the following places (in this
order):
the directory specified in the system property "casa.home"
the directory specified in the system property "user.home",
subdirectory "casa/dataFiles"
the current working directory
as a resource included in the casa distribution
|
protected AgentUI |
makeDefaultGUI(String[] args)
Returns a default AgentUI as a window.
|
AgentUI |
makeDefaultInterface(String[] args,
boolean GUI)
Returns a default AgentUI (in this case, a
TransientAgentInternalFrame instance or a TextInterface instance --
depending on the GUI argument).
|
protected TransientAgentInternalFrame |
makeDefaultInternalFrame(TransientAgent agent,
String title,
Container aFrame)
Create the default internal Frame (usually) with tabs for this agent type.
|
protected AgentUI |
makeDefaultTextInterface(String[] args)
Returns a default AgentUI as a window.
|
private MLMessage |
matchRequest(MLMessage replyRequestMsg)
Finds a request matching (in the
ML.IN_REPLY_TO and
ML.REPLY_WITH fields) and returns the matching message. |
private MLMessage |
matchRequestAndDelete(MLMessage replyRequestMsg)
Finds a request matching (in the
ML.IN_REPLY_TO and
ML.REPLY_WITH fields), deletes the request from the internal list
of requests and returns the matching message. |
protected PerformDescriptor |
monitorDefault(MLMessage message)
The default code for responding to an outging
contract message. |
protected void |
notifySendingMessage(MLMessage message)
This method is to be overridden by any subclasses that wish to be informed
whenever a message is actually sent out.
|
static String |
optionsToString(String prefix,
Object obj) |
Node |
parseJADENode(String node) |
protected void |
pendingFinishRun_unregisterAgentInstance()
If this agent is registered with the lack (
isRegistered() ) then
unregister it by calling doUnregisterAgentInstance(false) . |
protected void |
pendingFinishRun_withdrawFromAllCDs()
Unsubscribes from an any watched CDs (
watchedCooperationDomains )
by calling doCDSubscribeMembership(URLDescriptor, false) and withdraws from any
joined CDs (joinedCooperationDomains ) by calling
doWithdrawCD(URLDescriptor,
false) . |
protected void |
pendingFinishRun()
Adds withdrawing from CDs (
pendingFinishRun_withdrawFromAllCDs() )
and unregistering with the LAC (
pendingFinishRun_unregisterAgentInstance() ) the the superclass's
actions. |
PerformDescriptor |
perform_execute(MLMessage message)
The code for responding to an outgoing
agree message. |
PerformDescriptor |
perform_FIPAStyle(MLMessage message) |
protected PerformDescriptor |
perform_get_name(MLMessage msg)
Responds to a request from another agent to get this agent's name.
|
protected PerformDescriptor |
perform_get_ontology(MLMessage message)
The code for responding to an outgoing
agree message. |
protected PerformDescriptor |
perform_invite_to_cd(MLMessage message)
The code for responding to an outgoing
agree
message. |
protected PerformDescriptor |
perform_method_call(MLMessage m)
Responds to a received proxy request message by interpreting the content
field, attempting to execute it, and returning a message with the result.
|
PerformDescriptor |
perform_query_if(MLMessage m)
Responds to a query-ref message by interpreting the act field, attempting
to execute it, and returning a message with the result.
|
protected boolean |
perform_query_if(String item) |
PerformDescriptor |
perform_query_ref(MLMessage m)
Responds to a query-ref message by interpreting the act field, attempting
to execute it, and returning a message with the result.
|
protected Object |
perform_query_ref(String item) |
protected PerformDescriptor |
performDefault(MLMessage message)
The default code for responding to an outging
agree
message. |
private Vector<PairComparable<Conversation,AbstractPolicy>> |
pols2convs2pol(Vector<AbstractPolicy> ps,
Conversation conv) |
private static int |
printKBexpressions(AgentUI ui,
String pattern,
String text,
boolean regex,
boolean strict) |
protected SocialCommitment |
processCommitment(SocialCommitment sc) |
protected SocialCommitment |
processCommitments()
If the parent classes
AbstractProcess.processCommitments() doesn't
do anything (returns false), and there is a commitmentProcessor
with outstanding commitments, calls the #processCommitments() method. |
protected void |
processObserverNotification(ObserverNotification notification)
TODO: rkyee: figure out why EVENT_WITHDRAW_CD is never invoked
|
private void |
processPolicies(AbstractProcess creator,
Event event,
AbstractCollection<Pair<Conversation,AbstractPolicy>> collectedPolicies,
Conversation conversation,
String conversationsDoc,
Map<String,LispObject> map)
Applies the policies using
PolicyContainer.applyPolicies(casa.interfaces.PolicyAgentInterface, AbstractCollection, Event, Map) . |
Status |
putExtendedOntology(String spec)
Deprecated.
|
void |
putPolicy(AbstractPolicy p) |
void |
putPolicyAlwaysApply(AbstractPolicy p) |
void |
putPolicyLastResort(AbstractPolicy p) |
Status |
putReplacementOntology(String types)
Deprecated.
|
void |
putUI(AgentUI ui)
A creating process should call this to let the agent know of any user
interface it has attached to the agent.
|
SimpleString |
query_ref(String formula) |
String |
query_toString(String formula) |
QueryResult |
query(String formula) |
boolean |
queryIf(URLDescriptor url,
String expression,
long timeout) |
List<Integer> |
queryRef_toIntegerList(String formula) |
String |
queryRef_toString(String formula) |
List<String> |
queryRef_toStringList(String formula) |
List<Term> |
queryRef_toTermList(String formula) |
ListOfTerm |
queryRef(String formula) |
Collection<Term> |
queryRef(URLDescriptor url,
String expression,
long timeout)
Sends a synchronous query ref the url and returns the
reply.
|
Collection<AID> |
queryRefAIDs(URLDescriptor url,
String expression,
long timeout) |
Collection<URLDescriptor> |
queryRefURLs(URLDescriptor url,
String expression,
long timeout) |
boolean |
querywithFilter(String formula,
TransientAgent a) |
void |
realizeAgentBehaviourFromOptions()
Refresh agent behaviour from the options object.
|
static Set<String> |
recursiveParent(TransientAgent a,
String x,
Set<String> SI)
This filter is actually trying to find some relations present between types
in the ontology.
|
static Set<String> |
recursivePermutations(List<Set<String>> sets) |
PerformDescriptor |
release_execute(MLMessage message)
The code for responding to an
propose /
ML.DISCHARGE |... |
PerformDescriptor |
release_FIPAStyle(MLMessage message) |
PerformDescriptor |
release_get_agents_registered(MLMessage msg)
Process an incoming propose-discharge or cancel message
for a get_agents_registered act-type request conversation.
|
PerformDescriptor |
release_get_agents_running(MLMessage msg)
Process an incoming propose-discharge or cancel message
for a getAgentsRunning act-type request conversation.
|
PerformDescriptor |
release_get_members(MLMessage msg)
Handles get.members replies from a CD.
|
PerformDescriptor |
release_get_ontology(MLMessage msg)
Handles get.performative replies from another agent.
|
PerformDescriptor |
release_join_cd(MLMessage msg)
Handles join-cd replies from a CD.
|
protected PerformDescriptor |
release_ping(MLMessage m)
Responds to a received ping request message by constructing a complimentary
ping reply message and returning it to the sender.
|
PerformDescriptor |
release_query_if(MLMessage m)
Retrieves the response to an earlier query-ref message by interpreting the
act field and content field.
|
PerformDescriptor |
release_query_ref(MLMessage m)
Retrieves the response to an earlier query-ref message by interpreting the
act field and content field.
|
PerformDescriptor |
release_resolve_url(MLMessage msg)
An empty placeholder tof the resolve_url conversation.
|
PerformDescriptor |
release_unregister_agentType(MLMessage msg) |
PerformDescriptor |
release_unregister_instance(MLMessage msg)
If this messsage is from this agent's LAC (valid :sender field, I'm registered,
getLACURL() .equals :sender field),
then unregister with the LAC by:
setting setRegisteredWithLAC(false)
setting this agent's URL's LACport to 0
setting the proxy's LACPort to 0
notifying observers ML.EVENT_UNREGISTER_INSTANCE
Setting setBanner(null)
|
PerformDescriptor |
release_withdraw_cd(MLMessage msg) |
protected PerformDescriptor |
releaseDefault(MLMessage message)
The default code for responding to a
propose
message. |
Conversation |
removeConversation(Conversation conv) |
void |
removeCooperationDomains(URLDescriptor url) |
void |
removeJoinedCooperationDomain(URLDescriptor url) |
void |
removeSubscribeEvents(Event event) |
Status |
requestInstances(String pattern) |
private void |
resetDefFileSystemLocations()
reset the cache for the default resource locations to look in.
|
protected Status |
resolveConnectException(MLMessage msg,
Runnable1<String,Status> cmd)
Attempts to resolve the url of the reciever field of a message.
|
Object |
retrieveReturnedData(String act) |
void |
saveReturnedData(String act,
Object o) |
static boolean |
searchOntology(TransientAgent agent,
ParamsMap params,
AgentUI ui,
Environment env,
String expr) |
static boolean |
searchOntology1(TransientAgent agent,
ParamsMap params,
AgentUI ui,
Environment env,
String expr) |
void |
setBanner(String banner)
Sets a banner string that may be used by UI windows, etc.
|
protected void |
setCommitmentProcessor(CommitmentProcessor cp) |
static Object |
setField(Object object,
Field field,
Object value)
Attempts to set the field by first trying to access it through a setter of
the form "set"+name(value) where the name is the same name as the field,
but the first letter is capitolized.
|
protected Status |
setInstancesFound(MLMessage message) |
void |
setOntology(Ontology ont) |
private void |
setRegisteredWithLAC(URLDescriptor r) |
Boolean |
shouldDoExecuteRequest(MLMessage message)
Determines if we should execute the contents of a request/execute incomming
message.
|
private void |
startPrimaryInterface() |
protected Status |
template_handleNewOntologyInfo(MLMessage msg,
String types)
Template method called by handleReply_GetTypes() to do whatever the agent
wants to do with the new type information.
|
void |
update(Observable o,
Object arg) |
protected void |
updateConversationProtocolType(String strat)
Deprecated.
|
protected boolean |
verifyCD(URLDescriptor url) |
protected PerformDescriptor |
verifyDefault(MLMessage message)
The default code for responding to an non-
request
reply message. |
StatusObject<Object> |
verifyMessage(MLMessage msg,
String[] list)
Verifies that a message comforms to specification in list.
|
addObserver, addObserver, addObserver, addObserver, addTraceTags, addTransformation, bump, clearAllTraceTags, closePort, compareTo, countObservers, defer, defer, deleteObserver, deleteObserver, deleteObservers, dequeueEvent, equals, eventBufferLoopBody, eventBufferLoopPeriodic, eventQueuePeek, existed, exit, finalize, finishRun, fixupMessage, getAgent, getAgentName, getEventQueue, getInitParams, getNewMessage, getNewMessage, getOptions, getPort, getSocketServer, getTrace, getTraceTags, getTransformationFor, getUniqueRequestID, getURL, getUseAckProtocol, getUsePriority, hasChanged, hasOpenPort, in, initializeConstructor, initializeURL, isA, isA, isA, isA, isAAct, isAAct, isAgentThread, isAPerformative, isAPerformative, isExiting, isInitialized, isLoggingTag, isObserveMessages, isPaused, isThisMyAddress, isTracing, loadClass, makeOptions, makeSubthread, makeSubthread, makeTraceParam, notifyObservers, notifyObservers, notifyObserversWithNoArg, notifyObserversWithTop, out, println, println, println, println, println, queueEvent, queueEventIf, removeTraceTags, resetRuntimeOptionsFromCommandLine, resetSecurityPackage, resetTraceOptions, revTransform, revTransform, run, sendMessage_primitive, sendMessage, sendMessage, sendMessageAndWait, sendQueryAndWait, sendRequestAndWait, sendRequestAndWait, setAllTraceTags, setObserveMessages, setOptions, setPause, setTraceTags, setTracing, setURL, setUseAckProtocol, setUsePriority, startSocketServer, startTraceMonitor, step, transform, transform, unhandledMessage, updateOptions
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
getClass, hashCode, notify, notifyAll, wait, wait, wait
getOptions, isAAct, isInitialized, setOptions, updateOptions
addObserver, addObserver, closePort, deleteObserver, deleteObserver, exit, getAgentName, getName, getNewMessage, getPort, getTrace, getUniqueRequestID, getURL, getUseAckProtocol, hasOpenPort, isA, isAPerformative, isExiting, isLoggingTag, isTracing, println, println, println, sendMessage, setTracing, setUseAckProtocol, startTraceMonitor
addObserver, addObserver, countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers, notifyObserversWithNoArg, notifyObserversWithTop
addTransformation, bump, defer, dequeueEvent, getName, getTransformationFor, getUniqueRequestID, getURL, getUseAckProtocol, isA, isA, isA, isA, isAPerformative, isAPerformative, isLoggingTag, notifyObservers, println, println, println, queueEvent, queueEventIf, revTransform, revTransform, sendMessage, transform, transform
static Interpreter lisp
private ConcurrentSkipListSet<URLDescriptor> joinedCooperationDomains
Vector
of all of the cooperation domains (
URLDescriptor
s) that this agent has successfully joined.private TreeMap<URLDescriptor,String> watchedCooperationDomains
TreeMap
of all of the cooperation domains (
URLDescriptor
s) that this agent is "watching" to the
conversation IDs that "remember" the subscription. In other words, all of
the cooperation domains that we have requested to learn about new members.private Hashtable<URLDescriptor,Vector<URLDescriptor>> cooperationDomainMembers
Hashtable
linking the URLDescriptor
of a
cooperation domain to a Vector
of the participants (
URLDescriptor
s) of that cooperation domain.private CommitmentProcessor commitmentProcessor
protected AgentUI primaryUI
public static CasaKB cacheKB
protected static List<OntologyFilterArgument> ListOfArgs
protected PolicyContainer policies
protected PolicyContainer policiesAlwaysApply
protected PolicyContainer policiesLastResort
private TransientAgent.Conversations conversations
protected ConcurrentSkipListMap<String,Object> conversationData
protected AgentProxy proxy
protected boolean usingProxy
private boolean usingSecureProxy
private byte[] key
private static int KEY_LENGTH
private long uniqueNumber
private int realPort
private int proxyPort
public URLDescriptor CDinvitee
public URLDescriptor CDInvitedTo
private static String[] defFileSystemLocations
getDefFileSystemLocations()
and
resetDefFileSystemLocations()
.private URLDescriptor registeredWithLAC
private StatusURLDescriptorList instancesFound
public static final int DEFER_ACTION
public static final int DROP_ACTION
public static final String defaultOntologyClassName
String ontologyEngine
protected Method ontologyEngineLoadMethod
protected Method ontologyEngineCreateMethod
private TreeSet<MLMessage> outstandingRequests
requests
to match against
incomming reply-requests
(and then remove them).
This allows us to detect an unrequested reply.private String banner
Environment lispEnvironment
private static final ThreadLocal<AgentUI> uiForThread
#abclEval(String, Map,
AgentUI, Object...)
allow Lisp operator access to thread-local data
through getUIForThread()
.private static final ThreadLocal<TransientAgent> agentForThread
#abclEval(String, Map,
AgentUI, Object...)
to allow Lisp operator access to thread-local data
through getUIForThread()
.private static final ThreadLocal<Map<String,Object>> objectsForThread
#abclEval(String, Map,
AgentUI, Object...)
allow Lisp operator access to thread-local data
through getUIForThread()
.private static final CasaLispOperator AGENT__GET_URL
private static final CasaLispOperator AGENT__GET_POLICIES
private static final CasaLispOperator AGENT__DELETE_POLICY
private static final CasaLispOperator AGENT__GET_AGENT
private static final CasaLispOperator GET_THREAD
private static final CasaLispOperator GET_SYSTEM
private static final CasaLispOperator SET_SYSTEM
private static final CasaLispOperator AGENT__FIND_FILE_RESOURCE_PATH
private static final CasaLispOperator AGENT__RESET_DEF_FILE_SYSTEM_LOCATIONS
private static final CasaLispOperator AGENT__GET_AGENTS_RUNNING
private static final CasaLispOperator AGENT__GET_AGENTS_REGISTERED
private static final CasaLispOperator AGENT__OPTIONS
private static final TransientAgent.NewAgentLispCommand AGENT__NEW_AGENT
private static final CasaLispOperator AGENT__TELL
private static final CasaLispOperator AGENT__ASYNC
private static final CasaLispOperator AGENT__REPLY
A reply message is sent in response to the MLMessage
in the first
argument. This reply is constructured as follows:
MLMessage
has
MLMessage.constructReplyTo(MLMessage, String, URLDescriptor)
applied to it to produce a legitimate ML.AGREE
-type reply message.
PerformDescriptor
exists, its key/value
pairs are overlayed the key/value pairs in the reply message (replacing or
adding to them).
private static final CasaLispOperator AGENT__SEND
private static final CasaLispOperator AGENT__MESSAGE
private static final CasaLispOperator AGENT__JOIN
private static final CasaLispOperator AGENT__GETUSEACKPROTOCOL
private static final CasaLispOperator AGENT__GET_MSG_OBJ
private static final CasaLispOperator EVENT__GET_MSG
private static final CasaLispOperator EVENT__GET
private static final CasaLispOperator EVENT__GET_OWNER_CONVERSATION_ID
@Deprecated private static final CasaLispOperator GET_OBJECT
private static final CasaLispOperator AGENT__PRINTLN
private static final CasaLispOperator AGENT__PAUSE
private static final CasaLispOperator AGENT__RESUME
private static final CasaLispOperator AGENT__STEP
private static final CasaLispOperator AGENT__NEW_INTERFACE
private static final CasaLispOperator AGENT__SHOW_EVENTQUEUE
private static final CasaLispOperator AGENT__EXIT
private static final CasaLispOperator AGENT__MAKE_CONVERSATION_ID
private static final CasaLispOperator COMPARETO
private static final CasaLispOperator AGENT__SHOW_CONVERSATIONS
private static final CasaLispOperator AGENT__SHOW_COMMITMENTS
private static final CasaLispOperator AGENT__INSTANTIATE_CONVERSATION
private static final CasaLispOperator AGENT__ISA
private static final CasaLispOperator SERIALIZE
private static final CasaLispOperator AGENT__PUT_POLICY
private static final CasaLispOperator AGENT__CREATE_EVENT_OBSERVER_EVENT
private static final CasaLispOperator AGENT__STOP_EVENT_OBSERVER_EVENT
private static final CasaLispOperator AGENT__SEND_REQUEST_AND_WAIT
private static final CasaLispOperator AGENT__SEND_QUERY_AND_WAIT
private static final CasaLispOperator AGENT__PING
private static final CasaLispOperator AGENT__LOAD_FILE_RESOURCE
private static final CasaLispOperator AGENT__GET_CLASS_NAME
private static final CasaLispOperator AGENT__TRANSFORM
private static final CasaLispOperator AGENT__TRANSFORM_STRING
public CasaKB kBase
private static final CasaLispOperator ASSERT
private static final CasaLispOperator KB_SHOW
private static final CasaLispOperator KB_DEFINE_ONTOLOGY_FILTER
private static final CasaLispOperator KB_ARG_DESC
private static final CasaLispOperator KB__QUERY_IF
private static final CasaLispOperator QUERYREF
private static final CasaLispOperator ADD__SINGLE__NUM__VALUE__KBFILTER
private static final CasaLispOperator CALL_GC
public TransientAgent(ParamsMap params, AgentUI ui) throws Exception
AbstractProcess.AbstractProcess(ParamsMap, AgentUI, int)
with the
port (2nd) argument modified: iff proxies are specified in
quals then the port is decremented to make room for the proxies.
Thus, the top proxy can be allocated the target port.params
- ui
- Exception
AbstractProcess.AbstractProcess(ParamsMap, AgentUI, int)
public void addJoinedCooperationDomain(URLDescriptor url)
public void removeJoinedCooperationDomain(URLDescriptor url)
public Set<URLDescriptor> getJoinedCooperationDomain()
public AgentUI getPrimaryUI()
public void putPolicy(AbstractPolicy p)
public Policy[] getPolicies()
public void putPolicyAlwaysApply(AbstractPolicy p)
public Policy[] getAlwaysApplyPolicies()
public void putPolicyLastResort(AbstractPolicy p)
public Policy[] getLastResortPolicies()
public Conversation removeConversation(Conversation conv)
removeConversation
in class AbstractProcess
public boolean hasConversation(String convID)
AbstractProcess
hasConversation
in class AbstractProcess
public LinkedList<Conversation> getConversation(String convID)
getConversation
in class AbstractProcess
public ConcurrentSkipListMap<String,LinkedList<Conversation>> getConversations()
public void addConversation(String convID, Conversation conv)
addConversation
in class AbstractProcess
public boolean isUsingProxy()
public AgentProxy getProxy()
private static int calculatePortAccountingForProxies(ParamsMap params, AgentUI ui) throws Exception
Exception
private static Class<AgentProxy>[] getProxies(ParamsMap params, AgentUI ui) throws Exception
Exception
private String loadFileResource(String fileNameOnly, boolean reportFailure) throws IOException, IllegalOperationException
fileNameOnly
- reportFailure
- In the event that findFileResourcePath(String)
fails,
then if this is true throw a detailed exception, otherwise just
return null.IllegalOperationException
Exception
IOException
public static String findFileResourcePath(String fileNameOnly) throws IOException
IOException
public static String findFileResourcePath(String fileNameOnly, String[] dirs) throws IOException
getDefFileSystemLocations()
(be
careful of caching here -- call resetDefFileSystemLocations()
if
you change system properties "casa.home" or "user.home").
fileNameOnly
- IOException
public static String[] getDefFileSystemLocations()
findFileResourcePath(String)
, which uses
these directories as well as project and system resource paths to find a
file. If you are looking for a file, you should probably use
findFileResourcePath(String)
, but you may find this method useful
to report an error in find that resource. resetDefFileSystemLocations()
.private void resetDefFileSystemLocations()
public void initializeAfterRegistered(boolean registered)
doGetOnology(URLDescriptor, String, String)
.registered
- Will be set to true if the agent has sucessfully registered with
the LAC; false otherwiseprotected void initializeThread(ParamsMap params, AgentUI ui)
initializeProxy(ParamsMap, AgentUI)
initializePolicies(ParamsMap, AgentUI)
initializeThread
in class AbstractProcess
private void callInitializeAfterRegistered(boolean isRegistered)
initializeAfterRegistered(boolean)
from the agent's thread.isRegistered
- used to tell initializeAfterRegistered(boolean)
if the
agent is actually registered or not.protected void initializePolicies(ParamsMap params, AgentUI ui)
commitmentProcessor
is
also initialized here.params
- ui
- the UI that represents this agentprotected void setCommitmentProcessor(CommitmentProcessor cp)
protected CommitmentProcessor getCommitmentProcessor()
public Collection<SocialCommitment> getUnfulfilledSocialCommitments(String id)
public Collection<SocialCommitment> getUnfulfilledSocialCommitments()
public SocialCommitmentsStore getSCStore()
getSCStore
in interface PolicyAgentInterface
@Deprecated protected void updateConversationProtocolType(String strat)
PolicyContainer
). It instantiates casa.policy.
strat.MHConcretePolicyContainer and uses it as its policy factory.strat
- the strategy package to usepublic String getStrategy()
AbstractProcess
getStrategy
in interface ProcessInterface
getStrategy
in class AbstractProcess
public JComponent getStrategyGUI()
null
value if hasStrategyGUI() returns
false
.getStrategyGUI
in interface TransientAgentInterface
JPanel
that is the GUI responsible for interacting
with this agent's strategy.public boolean hasStrategyGUI()
hasStrategyGUI
in interface TransientAgentInterface
public CasaKB getKnowledgeBase()
getKnowledgeBase
in interface PolicyAgentInterface
public CasaKB getCachedKnowledgeBase()
private Method getMethodRobustly(Object object, String methodName, Class<?>... parameters)
this
even if it is
protected. This means that the method may not be callable. If getMethod()
is used, only public methods are returned.object
- The object who's method is to be obtained (only used for it's
class).methodName
- The name of the method to return.parameters
- The parameters that must exist in the returned method.null
if it does not exist.private PerformDescriptor callHandlerMethod(MLMessage message, String methodName) throws NoSuchMethodException
this
with the specified name, passing it the
given MLMesssage, and returning a PerformDescriptor. Throws
NoSuchMethodException if no such method exists.evesdrop(MLMessage)
as a catch-all.message
- The message to pass.theMethodName
- The name of the method to call.NoSuchMethodException
- If any exception occurs during the call.private Method findMethod(Object object, String methodName)
getMethodRobustly(Object, String, Class...)
to find
it in object using reflection.object
- the Object to look for the method inmethodName
- the name of the method to returnpublic PerformDescriptor evesdrop(MLMessage msg)
ProcessOptions.observeMessages
is set true and the handler method
(the regular method concatonated with "_evesdrop") is not found. Subclasses
should override this to implement the desired behaviour. This implemenation
does nothing but return a PerformDescriptor
with a
DROP_ACTION
Status, which indicates no action should be taken.evesdrop
in interface PolicyAgentInterface
msg
- An incomming message that is not addressed to this agent.public PerformDescriptor dispatchMsgHandlerMethod(String consider, Act act, MLMessage message)
request
-type message. This implementation uses the
sun.reflect
package to look for a method with the signature
consider_*(MLMessage) (where * is the name of the performative in the
message) and calls that method if it exists, otherwise it calls
#considerDefault(Act, MLMessage)
. If the message is just an
inform
type and the called method returns a performative
in it's return of a subtype of negative-reply
then a reply
message is constructed and returned
to the sender (even though inform
messages usually don't
get a reply).dispatchMsgHandlerMethod
in interface PolicyAgentInterface
act
- the Act object of the message (should be the same as that
described in the act
field of message).message
- the request
-type performative message that
percipitated the call to the methodcasa.interfaces.PolicyAgentInterface#consider(casa.Act,
casa.MLMessage)
protected PerformDescriptor considerDefault(MLMessage message)
request
message or
a ML#PROPOSE_DISCHARGE
message. Subclasses may override this method
to change the default behavior. In this case, if this is a
ML.REQUEST
-type message, we check to make sure there is a
perform_*(MLMessage) handler; if there is, this method sortcuts to omit the
agree
message; otherwise it constructs a return indicating
a not-understood
message should be returned
(since we have no handler for it).inform
-type
message, and we got here, the agent obviously doesn't have a handler for
it, so a message is constructed and sent back indicating
not-understood
. ML.PERFORMATIVE
=ML.SUCCESS
, inserting a
ML.ACT
=ML.DISCHARGE
|message
- the message that precipitated this actionStatus
object and any changes to the default return message (a null return
indicates "success" and no changes).protected PerformDescriptor verifyDefault(MLMessage message)
request
reply
message. Subclasses may override this method
to change the default behavior. In this case, it's just returns null, which
indicates doing nothing.message
- the message that precipitated this actionnull
alwaysprotected PerformDescriptor performDefault(MLMessage message)
agree
message. Subclasses may override this method to change the default
behavior. In this case, since this method does not know how to do anything,
the return is set up with the status of -55 and the fields are built with
the performative failure
and a proper explanation.act
- The act of the message.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).protected PerformDescriptor monitorDefault(MLMessage message)
contract
message. Subclasses may override this method to change the
default behavior. In this case, since this method does not know how to do
anything, the return is set up with the status of -55 and the fields are
built with the performative failure
and a proper
explanation.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).protected PerformDescriptor acceptDefault(MLMessage message)
agree
message. Subclasses may override this method to change the default
behavior. In this case, since this method does not know how to do anything,
the return is set up with the status of -55 and the fields are built with
the performative failure
and a proper explanation.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).public Event[] getSubscribeEvents(Event event)
getSubscribeEvents
in interface PolicyAgentInterface
event
- casa.interfaces.PolicyAgentInterface#getSubscribeEvents(casa.MLMessage)
public void addSubscribeEvents(Event event)
event
- public void removeSubscribeEvents(Event event)
event
- protected PerformDescriptor releaseDefault(MLMessage message)
propose
message. Subclasses may override this method to change the default
behavior. In this case, it just returns null, which indicates doing
nothing.message
- the message that precipitated this actionnull
alwaysprotected PerformDescriptor evaluateDefault(Act act, MLMessage message)
protected PerformDescriptor concludeDefault(MLMessage message)
reply-proposal
message. Subclasses may override this method to change the
default behavior. In this case, it just returns null, which indicates doing
nothing.message
- the message that precipitated this actionnull
alwaysprotected PerformDescriptor assembleDefault(MLMessage message)
proxy
message.
Subclasses may override this method to change the default behavior. In this
case, it just returns a StatusObjectmessage
- the message that precipitated this actionnull
always@Deprecated public void initUI()
public Status executeCommand(String command, AgentUI ui)
abclEval(String, Map, AgentUI)
method to do the actual work.executeCommand
in interface PolicyAgentInterface
executeCommand
in interface TransientAgentInterface
command
- a command stringui
- an AgentUI
object (may be null).Status
object with the result of the attempted execution.public AgentUI makeDefaultInterface(String[] args, boolean GUI)
makeDefaultInterface
in interface TransientAgentInterface
args
- The command line argumentsuserName
- The name of the userGUI
- set to true if you want a window interface (made by
makeDefaultGUI()); false if you want to text interface (made by
makeDefaultTextInterface())protected AgentUI makeDefaultGUI(String[] args)
args
- The command line argumentsprotected TransientAgentInternalFrame makeDefaultInternalFrame(TransientAgent agent, String title, Container aFrame)
agent
- the owner agenttitle
- the title of the windowaFrame
- the owner frame in which this window is to be embeddedprotected AgentUI makeDefaultTextInterface(String[] args)
args
- The command line argumentspublic void putUI(AgentUI ui)
primaryUI
, and call
notifyObservers(ML.EVENT_BANNER_CHANGED,getBanner())
since the interface
could work via the Observer interface and various set*()
and get*() calls on the agent.putUI
in interface TransientAgentInterface
ui
- the user interface to be attached to the agent.public AgentUI getUI()
public AgentUI[] getUIs()
private void initializeProxy(ParamsMap params, AgentUI ui) throws Exception
Exception
protected SocialCommitment getChosenCommitment()
getChosenCommitment
in class AbstractProcess
public boolean hasActiveCommitments()
hasActiveCommitments
in class AbstractProcess
protected SocialCommitment processCommitment(SocialCommitment sc)
processCommitment
in class AbstractProcess
protected SocialCommitment processCommitments()
AbstractProcess.processCommitments()
doesn't
do anything (returns false), and there is a commitmentProcessor
with outstanding commitments, calls the #processCommitments()
method.processCommitments
in class AbstractProcess
protected boolean isEventQueueReady()
AbstractProcess
isEventQueueReady
in class AbstractProcess
public void handleEvent(Event event)
AbstractProcess.handleEvent(Event)
by:
conversations
, pass the event to
that conversation and collect the policies.
AbstractProcess#options#threadedEvents
is true, execute the
policies in their own thread, otherwise, execute them in this (the agent's)
thread. In either case, polices are executed by calling
processPolicies(AbstractProcess, Event, AbstractCollection, Conversation, String, Map)
.
Event.fireEvent()
method is called.
Unsupported conversations should be handled by agent-global policies listed
in policies
. Supported conversations are created by policies in
policies
, and continued by the policies in the current
conversations listed in conversations
. Note that default behaviour
for conversation-specific policies can be specified by policies in the
agent-global policies due the fact that policy filtering allows all
subtypes of performatives, but only the most specific act
.
handleEvent
in class AbstractProcess
event
- the event to handleAbstractProcess.handleEvent(Event)
,
processPolicies(AbstractProcess, Event,
AbstractCollection, Conversation, String, Map)
private void processPolicies(AbstractProcess creator, Event event, AbstractCollection<Pair<Conversation,AbstractPolicy>> collectedPolicies, Conversation conversation, String conversationsDoc, Map<String,LispObject> map)
PolicyContainer.applyPolicies(casa.interfaces.PolicyAgentInterface, AbstractCollection, Event, Map)
.
StatusObject
with a null object or an empty list, the
event is considered to be "not handled". In this case, if the event is not
a subtype of ML.EVENT_DEFERRED_EXECUTION
or
ML.EVENT_SC_PERFORM_ACTION
then log it in the agent's log file.
Event.fireEvent()
).
AbstractEvent.delete()
, if applicable, to give the event a
chance to clean up.
creator
- The calling agentevent
- The event being processed by the policescollectedPolicies
- The list of collected applicable policiesconversation
- The conversation iin the context of which this even is being
processed (or null if none)conversationsDoc
- Any doc string associated with the conversationmap
- A key/value map to form additional context for the policy
execution.private Vector<PairComparable<Conversation,AbstractPolicy>> pols2convs2pol(Vector<AbstractPolicy> ps, Conversation conv)
protected void notifySendingMessage(MLMessage message)
notifySendingMessage
in class AbstractProcess
message
- protected Status handleLACClosing()
public void realizeAgentBehaviourFromOptions()
realizeAgentBehaviourFromOptions
in interface ProcessInterface
realizeAgentBehaviourFromOptions
in class AbstractProcess
protected PerformDescriptor perform_get_name(MLMessage msg)
msg
- the message that percipitated this callcontent
fieldprotected PerformDescriptor accept_new_MenuItem(MLMessage message)
inform
message. Subclasses
may override this method to change the behavior. In this case, it calls
consider_new_MenuItem(MLMessage)
which handles both the
inform
- and the request
-type messages.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).protected void processObserverNotification(ObserverNotification notification)
notification
- the event to consider for join/exit agentprotected PerformDescriptor accept_update(MLMessage message)
protected PerformDescriptor consider_new_MenuItem(MLMessage message)
inform
or
request
message. Subclasses may override this method to
change the behavior. In this case, adds the new command described in the
content
field to it's list of commands. However, if this
message is a request
performative, then it shortcuts the
normal request/agree/propoase-discharge/reply-proposal-discharge sequence
by immediatly sending a propose
/
discharge
(skipping the agree
step).message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).public boolean authorizeMessage(MLMessage msg)
AbstractProcess
authorizeMessage
in class AbstractProcess
msg
- contains the message to authorizetrue
if the message is authorized to be processed;
false
otherwiseprotected boolean authorizedByProxy(MLMessage msg)
protected void pendingFinishRun()
pendingFinishRun_withdrawFromAllCDs()
)
and unregistering with the LAC (
pendingFinishRun_unregisterAgentInstance()
) the the superclass's
actions.pendingFinishRun
in class AbstractProcess
AbstractProcess.pendingFinishRun()
protected void pendingFinishRun_withdrawFromAllCDs()
watchedCooperationDomains
)
by calling doCDSubscribeMembership(URLDescriptor, false)
and withdraws from any
joined CDs (joinedCooperationDomains
) by calling
doWithdrawCD(URLDescriptor,
false)
.protected void pendingFinishRun_unregisterAgentInstance()
isRegistered()
) then
unregister it by calling doUnregisterAgentInstance(false)
.protected Status resolveConnectException(MLMessage msg, Runnable1<String,Status> cmd)
resolveConnectException
in class AbstractProcess
msg
- the message to be updated.public Status doResolveURL(URLDescriptor url, long timeout, Runnable1<String,Status> cmd)
url
- The URL to be resolved. Note that this URLDescriptor object will
be updated to reflect the resolution.timeout
- milliseconds to wait before returning if something goes wrongcmd
- A Command
object to execute when the LAC returns with an
successful or failed resolutionprotected boolean verifyCD(URLDescriptor url)
public Set<URLDescriptor> getJoinedCooperationDomains()
getJoinedCooperationDomains
in interface TransientAgentInterface
public void removeCooperationDomains(URLDescriptor url)
removeCooperationDomains
in interface TransientAgentInterface
public Vector<URLDescriptor> getMembers(URLDescriptor cd)
getMembers
in interface TransientAgentInterface
public Vector<URLDescriptor> addMembers(URLDescriptor cd, Vector<URLDescriptor> urls)
public URLDescriptor getLACURL()
getLACURL
in interface TransientAgentInterface
public boolean isRegistered()
isRegistered
in interface TransientAgentInterface
public boolean isStoppable()
ProcessInterface.isStoppable()
and
commitmentProcessor
.MessageProcessor#isStoppable()
.isStoppable
in interface ProcessInterface
isStoppable
in class AbstractProcess
ProcessInterface.isStoppable()
public Status doPing(URLDescriptor agent, long timeout)
URLDescriptor
agent by sending a message of the format:
performative | request |
act |
ping |
release_ping(MLMessage)
to do the actual processing of the
returned reply.doPing
in interface TransientAgentInterface
agent
- URLDescriptor of the agent to pingtimeout
- maxiumum time (in milliseconds) to wait for the ping responsecasa.interfaces.TransientAgentInterface#doPing(casa.channels.URLDescriptor,
long)
public URLDescriptor doPing_sync(URLDescriptor agent, long timeout)
URLDescriptor
agent by sending a REQUEST message for
the agent's URL, and returning that URL.doPing_sync
in interface TransientAgentInterface
agent
- URLDescriptor of the agent to pingtimeout
- maxiumum time (in milliseconds) to wait for the ping responsecasa.interfaces.TransientAgentInterface#doPing_sync(casa.channels.URLDescriptor,
long)
protected PerformDescriptor release_ping(MLMessage m)
m
- The MLMessage received.protected PerformDescriptor accept_forward_message(MLMessage m)
m
- The MLMessage received.protected PerformDescriptor accept_LAC_closing(MLMessage m)
inform
/ LAC_closing
inform message by passing on the message encapsulated in the
content part of the message.m
- The MLMessage received.public PerformDescriptor perform_query_ref(MLMessage m)
m
- The MLMessage received.public PerformDescriptor consider_query_ref(MLMessage m)
m
- The MLMessage received.public boolean isTrusted(URLDescriptor url, Node node)
public boolean isTrusted(URLDescriptor url, String node)
public PerformDescriptor release_query_ref(MLMessage m)
m
- The MLMessage received.public Collection<Term> queryRef(URLDescriptor url, String expression, long timeout) throws Throwable
url
- The URL to send teh query-ref message to.expression
- The expression to querytimeout
- The max time (ms) to wait for a reponse.Throwable
- if the query reply is not the expected inform-ref.public static Collection<Term> getTermsFromContent(Content cont)
public Collection<AID> queryRefAIDs(URLDescriptor url, String expression, long timeout) throws Throwable
Throwable
public Collection<URLDescriptor> queryRefURLs(URLDescriptor url, String expression, long timeout) throws Throwable
Throwable
protected boolean perform_query_if(String item) throws IllegalOperationException
IllegalOperationException
public PerformDescriptor perform_query_if(MLMessage m)
m
- The MLMessage received.public PerformDescriptor consider_query_if(MLMessage m)
m
- The MLMessage received.public PerformDescriptor release_query_if(MLMessage m)
m
- The MLMessage received.public boolean queryIf(URLDescriptor url, String expression, long timeout) throws Throwable
Throwable
protected PerformDescriptor perform_method_call(MLMessage m)
m
- The MLMessage received.public Status doRegisterAgentInstance(int lacPort)
doRegisterAgentInstance
in interface TransientAgentInterface
public Status doRegisterAgentInstance(int lacPort, RunnableWithParameter<MLMessage> successAction, RunnableWithParameter<MLMessage> failureAction)
performative | request |
act |
register.instance |
language | casa. URLDescriptor |
content | a URLDescriptor object for this
agent followed by either true or false
indicating
whether this agent is in the local process of the LAC or not
|
#release_register_instance(MLMessage)
to do the actual processing of
the returned reply.doRegisterAgentInstance
in interface TransientAgentInterface
lacPort
- URLDescriptor for the LAC to register with. Since an agent can
only register with a LAC on the same host, the LAC address is
calculated using port and this agent's URL.sendMessage()
) or a Status object of value 5 if the agent is
already registered.private void setRegisteredWithLAC(URLDescriptor r)
r
- The URL to set registeredWithLAC
to (null means "not registered").public boolean isRegisteredWithLAC()
public Status doUnregisterAgentInstance(boolean request)
doUnregisterAgentInstance
in interface TransientAgentInterface
request
- true
if the message will be a request;
false
if it is to be an inform.public PerformDescriptor release_unregister_instance(MLMessage msg)
getLACURL()
.equals :sender field),
then unregister with the LAC by:
setRegisteredWithLAC(false)
ML.EVENT_UNREGISTER_INSTANCE
setBanner(null)
msg
- The incoming messagepublic Status doUnregisterAgentType(int LACport)
doUnregisterAgentType
in interface TransientAgentInterface
LACport
- the port number of the LAC to unregister withpublic PerformDescriptor release_unregister_agentType(MLMessage msg)
public StatusURLDescriptorList getInstancesFound()
getInstancesFound
in interface TransientAgentInterface
public Status requestInstances(String pattern)
requestInstances
in interface TransientAgentInterface
public StatusURLDescriptorList doFindInstances_sync(String pattern)
doFindInstances_sync
in interface TransientAgentInterface
pattern
- The Pattern
of the agents to be found.public Vector<URLDescriptor> doGetCooperationDomains(URLDescriptor lac)
doGetCooperationDomains
in interface TransientAgentInterface
lac
- The LAC to ask for it's list of CDspublic Status doJoinCD(URLDescriptor cdURL)
URLDescriptor
cdURL by sending a
message of the format:
performative | request |
act |
join.cd |
language | casa. URLDescriptor |
content | a URLDescriptor object for this agent |
release_join_cd(MLMessage)
to do the actual processing of the
returned reply and do the functionality of registering the join.doJoinCD
in interface TransientAgentInterface
cdURL
- URLDescriptor of the cooperation domain to joinpublic PerformDescriptor release_join_cd(MLMessage msg)
performative | reply |
act |
join.cd |
language | casa.Status |
content | a Status object |
verifyMessage(MLMessage,String[])
), this method
behaves according to the Status's value in the content field:
println()
with the "warning" tag.msg
- the incoming reply messagepublic Status doWithdrawCD(URLDescriptor cdURL, boolean request)
If this agent is already in the cooperation domain, observers are notified of this.
doWithdrawCD
in interface TransientAgentInterface
cdURL
- URLDescriptor of the cooperation domain to withdraw fromrequest
- true
if the message will be a request;
false
if it is to be an inform.public PerformDescriptor release_withdraw_cd(MLMessage msg)
msg
- public Status doCDPutData(URLDescriptor cdURL, DataStorageDescriptor dsd)
performative | request |
act |
put.data |
language | casa .DataStorageDescriptor |
content | a DataStorageDescriptor object |
doCDPutData
in interface TransientAgentInterface
dsd
- The data to storecdURL
- The URLDescriptor of the cooperation domain.AbstractProcess.sendMessage(MLMessage)
call.public StatusMLMessageList doCDGetHistory_sync(URLDescriptor cdURL)
performative | request |
act |
get.history |
performative | reply |
act |
get.history |
language | casa. StatusMLMessageList |
content | a StatusMLMessageList object |
doCDGetHistory_sync
in interface TransientAgentInterface
cdURL
- The URLDescriptor of the CD from which to retrieve the history
listpublic Status doCDGetMembers(URLDescriptor cdURL)
performative | request |
act |
get.members |
release_get_members(MLMessage)
.doCDGetMembers
in interface TransientAgentInterface
cdURL
- The URLDescriptor of the CD.public PerformDescriptor release_get_members(MLMessage msg)
performative | reply |
act |
get.members |
language | casa .StatusURLDescriptorList |
content | a StatusURLDescriptorList object |
cooperationDomainMembers
with the list from the contents.msg
- the incoming get.members request messagepublic Status doGetOnology(URLDescriptor url, String GET_PERFORMATIVESorGET_ACTS, String typeName)
performative | request | |
act |
get.performatives | |
language | identifier | may be missing if performativeName is null |
content | performativeName|null | blank or missing requests all performative information |
release_get_ontology(MLMessage)
.doGetOnology
in interface TransientAgentInterface
url
- The URLDescriptor of an agent to request performative information
fromGET_PERFORMATIVESorGET_ACTS
- either the act name GET_PERFORMATIVES or GET_ACTStypeName
- the name of the performative, or null to request a complete
description of url's performativesprotected PerformDescriptor perform_get_ontology(MLMessage message)
agree
message.
Subclasses may override this method to change the behavior. In this case,
if the content
field of messsage is empty, it
sets the return content
field to a description of this
agent's Ontology
, AbstractProcess.ontology
. If the content
field of messsage contains a type name that this agent
knows, it sets the return content
field to a description
of this agent's concept of that type.message
- the message the percipitated this actionPerformDescriptor
object and
any changes to the default return message (a null return indicates
"success" and no changes).protected PerformDescriptor consider_ping(MLMessage message)
request
message.
Subclasses may override this method to change the behavior.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).public PerformDescriptor consider_execute(MLMessage message)
request
message.
Subclasses may override this method to change the behavior. In this case,
this method checks to see if the command is an exit command, and
marks the return to send a refuse
message back. Otherwise
it returns null, which indicates sending an agree
message.message
- the message the percipitated this actionStatus
object and any changes to the default return message (a null return
indicates "success" and no changes).public Boolean shouldDoExecuteRequest(MLMessage message)
message
- public PerformDescriptor perform_execute(MLMessage message)
agree
message.
Subclasses may override this method to change the behavior. In this case,
it executes the command in the content
field.message
- the message the precipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).public PerformDescriptor release_execute(MLMessage message)
propose
/
ML.DISCHARGE
|... message. Subclasses may override this method to
change the behavior. In this case, this method notifies observers with a
STATE_POST_STRING.message
- the message the precipitated this actionpublic PerformDescriptor release_get_agents_registered(MLMessage msg)
ML.SUCCESS
or
ML.FAILURE
. You should use this method the process the either
the client's or server's response. A client should be the only role getting
the propose-discharge form. Either could receive a cancel. This method is
required.msg
- The incoming messageML.REJECT_PROPOSAL
, otherwise the reply will be
ML.ACCEPT_PROPOSAL
), and the key/value part will be
overlaid on the return message.public PerformDescriptor release_get_agents_running(MLMessage msg)
ML.SUCCESS
or
ML.FAILURE
. You should use this method the process the either
the client's or server's response. A client should be the only role getting
the propose-discharge form. Either could receive a cancel. This method is
required.msg
- The incoming messageML.REJECT_PROPOSAL
, otherwise the reply will be
ML.ACCEPT_PROPOSAL
), and the key/value part will be
overlaid on the return message.public PerformDescriptor release_resolve_url(MLMessage msg)
AbstractProcess.sendRequestAndWait(MLMessage, long, MessageEventDescriptor...)
call when AbstractProcess.sendMessage(MLMessage)
tries to resove an unresolved
URL.msg
- The messagepublic PerformDescriptor release_get_ontology(MLMessage msg)
performative | reply |
act |
get.performatives |
language | casa. TypeHierarchy |
content | a description of the requested performative(s) conforming to casa.TypeHierarchy |
template_handleNewOntologyInfo(MLMessage, String)
release_get_ontology
in interface TransientAgentInterface
msg
- the incoming get.members request messageprotected Status template_handleNewOntologyInfo(MLMessage msg, String types)
msg
- the message (it's already been processed to get types.
Only provided here to disabiguate if necessarytypes
- The type information that resulted from the above request/reply.public String getSerializedOntology()
getSerializedOntology
in interface TransientAgentInterface
public String getOntologyEngine()
private Method getOntologyEngineLoadMethod()
private Method getOntologyEngineCreateMethod()
private Method getMethod(String agentParamName, String methodName, Class[] params, String defaultTargetClassName, Class<?> baseClass, Class<?> returnType)
public Ontology getOntology()
getOntology
in interface PolicyAgentInterface
getOntology
in interface TransientAgentInterface
private Ontology getDefaultImportOntology()
public void setOntology(Ontology ont)
public String getOntologyFileSuffix()
@Deprecated public Status putExtendedOntology(String spec)
TransientAgentInterface
putExtendedOntology
in interface TransientAgentInterface
spec
- A String containing the persistent for of a TypeHierarchy@Deprecated public Status putReplacementOntology(String types)
putReplacementOntology
in interface TransientAgentInterface
types
- A String constaining the persisent for of a TypeHierarchypublic Status doCDSubscribeMembership(URLDescriptor cdURL, boolean sense)
performative | subscribe |
act |
observe.membership |
timeout | 0 |
sense | positive | negative |
language | casa. URLDescriptor |
content | a URLDescriptor object |
#accept_membership_change(MLMessage)
.cdURL
- URLDescriptor of the cooperation domain to observe the membership
ofsense
- true to set observation; false to cancelprotected PerformDescriptor accept_deleteCD(MLMessage msg)
msg
- The INFORM message that the CD sentpublic PerformDescriptor accept_exit(MLMessage msg)
PerformDescriptor
.
getStatusValue()
of 0 or
positive for success, or a negative value to indicate failure. It may
influence any return value by calling
PerformDescriptor.put(messageKey,value)
on the return
PerformDescriptor
.msg
- The incoming messagepublic Status doAdvertise(URLDescriptor yp, ServiceDescriptor service)
doAdvertise
in interface TransientAgentInterface
yp
- URLDescriptor of the agent advertising the serviceservice
- ServiceDescriptor of the service being advertisedpublic Status doUnadvertise(URLDescriptor yp, ServiceDescriptor service)
doUnadvertise
in interface TransientAgentInterface
yp
- URLDescriptor of the agent advertising the serviceservice
- ServiceDescriptor of the service being withdrawnpublic StatusURLDescriptorList doSearchYP(URLDescriptor yp, ServiceDescriptor service)
doSearchYP
in interface TransientAgentInterface
yp
- The URLDescriptor of the YP to searchservice
- A (perhaps partial) ServiceDescriptor description of a service
that the YP should match its advertisements againstpublic Status doInviteToCD(URLDescriptor agent, URLDescriptor cd, boolean sense)
doInviteToCD
in interface TransientAgentInterface
agent
- Agent this agent is requesting the join the CD.cd
- The CD the agent should join.protected PerformDescriptor perform_invite_to_cd(MLMessage message)
agree
message. Subclasses may override this method to change the behavior. In
this case, the consider_invite_to_cd(MLMessage)
method should have
already started the process of joining the CD, so this method only has to
wait around until the CD is jointed as reflected in
joinedCooperationDomains
. If this method is called before the CD
in the content
field appears in
joinedCooperationDomains
, then it just returns a status of
DEFER_ACTION
which causes nothing to happen but this method is
called again later. However, if we're within 400ms of the timeout in the
message, this method will set the appropate elements of the return to cause
a failure
reply.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).protected PerformDescriptor consider_invite_to_cd(MLMessage message)
request
message.
Subclasses may override this method to change the behavior. In this case,
it calls doJoinCD(URLDescriptor)
with the URL in the
content
field. If the send message done by
doJoinCD(URLDescriptor)
goes well, it causes an agree
reply by returning null. Otherwise, it causes either a
not-understood
or a ML.REFUSE
(already
joined) reply by setting the appropriate elements in the return.message
- the message the percipitated this actionStatus
object and any changes
to the default return message (a null return indicates "success"
and no changes).public PerformDescriptor release_FIPAStyle(MLMessage message)
public PerformDescriptor perform_FIPAStyle(MLMessage message)
protected Status handleErrorReplies(MLMessage msg, String requestType)
msg
- the MLMessage to interpretrequestType
- a string to prefix to the error message in the returned Status
(usually an act)public StatusObject<Object> verifyMessage(MLMessage msg, String[] list)
CASAUtil.unserialize(String, String)
(the most general way of
passing an object (polymorphic [subtypes]) objects can be passed). But it's
possible the object is not the object expected by the caller.
TokenParser
) method
msg
- a MLMessage to examinelist
- an array of key/values alternating.handleErrorReplies(MLMessage,String)
)
private AgentUI createNewInterface(TransientAgentInterface agent, String agentInterfaceName)
private void addRequest(MLMessage msg)
ML.REQUEST
or ML.ACCEPT_PROPOSAL
. In addition, this method
will add a reply_with field to the message if it isn't there already (since
outstanding request checking depends on it).msg
- private MLMessage matchRequestAndDelete(MLMessage replyRequestMsg)
ML.IN_REPLY_TO
and
ML.REPLY_WITH
fields), deletes the request from the internal list
of requests and returns the matching message. Precondition:
msg needs to be a subtype of ML.REPLY
.replyRequestMsg
- private MLMessage matchRequest(MLMessage replyRequestMsg)
ML.IN_REPLY_TO
and
ML.REPLY_WITH
fields) and returns the matching message.
Precondition: msg needs to be a subtype of ML.REPLY
.replyRequestMsg
- public String getBanner()
public void setBanner(String banner)
banner
- A banner string; if null, then it will be the result of
getDefaultBanner()
.public String getDefaultBanner()
public Status abclEval(String c, Map<String,LispObject> newEnvBindings, AgentUI ui)
TransientAgent
).
AgentUI
).
Map
) with parameterized
type String and Object). An important object listed in this map is the
"event" object which is used by getEventForThread()
and
getMsgForThread()
to get the current event and message objects
respectively.
abclEval
in interface PolicyAgentInterface
c
- The lisp codeui
- The lisp code may or may not write to or read from this ui objectStatusObject
containing an appropriate result object.public Status abclEval(String c, Map<String,LispObject> lispBindings)
abclEval
in interface PolicyAgentInterface
public Status abclEval(Cons cons, Map<String,LispObject> lispBindings)
abclEval
in interface PolicyAgentInterface
public SocialCommitment chooseSC(Collection<SocialCommitment> SocialCommitments)
chooseSC
in interface PolicyAgentInterface
unmarked
- a set of SocialCommitments to choose one frompublic static AgentUI getUIForThread()
CasaLispOperator
to
access thread-local data. The thread-local values are set by #abclEval(String, Map, AgentUI, Object...)
, so all
these calls must be called (directly or indirectly) though that method.public static TransientAgent getAgentForThread()
CasaLispOperator
to
access thread-local data. The thread-local values are set by #abclEval(String, Map, AgentUI, Object...)
, so all
these calls must be called (directly or indirectly) though that method.@Deprecated public static MLMessage getMsgForThread()
CasaLispOperator
to
access thread-local data. The thread-local values are set by #abclEval(String, Map, AgentUI, Object...)
, so all
these calls must be called (directly or indirectly) though that method.public static Event getEventForThread()
CasaLispOperator
to
access thread-local data. The thread-local values are set by #abclEval(String, Map, AgentUI, Object...)
, so all
these calls must be called (directly or indirectly) though that method.public static Map<String,Object> getObjectsForThread()
CasaLispOperator
to
access thread-local data. The thread-local values are set by #abclEval(String, Map, AgentUI, Object...)
, so all
these calls must be called (directly or indirectly) though that method.public static void createCasaLispOperators(Class<? extends TransientAgent> aClass)
LispAccessible
methods. All subclasses of
TransientAgent
must statically call this method to create
operators.aClass
- the class to scanpublic static Object getField(Object object, Field field) throws IllegalArgumentException, IllegalAccessException
object
- The object containing the field (and value)field
- The field that is assumed to be defined in the objectIllegalArgumentException
- This actually should never be thrownIllegalAccessException
- If the field in object is unaccessable by the agent (having
failed the setter method)public static Object setField(Object object, Field field, Object value) throws IllegalArgumentException, IllegalAccessException
getField(Object, Field)
to return a
value.object
- The object containing the field (and value)field
- The field that is assumed to be defined in the objectvalue
- The value to be assigned to the fieldgetField(Object, Field)
IllegalArgumentException
- If the value type cannot be applied to the fieldIllegalAccessException
- If the field in object is unaccessable by the agent (having
failed the setter method)private void startPrimaryInterface()
public void update(Observable o, Object arg)
update
in interface Observer
update
in class AbstractProcess
public Status doAddObserver(URLDescriptor observableAgentUrl, String... types)
observableAgentUrl
- the agent to observetypes
- the event typespublic Pair<Integer,String> getConversationsReport(boolean current, int verbose)
current
- Set to true for the current conversations, false for known
(template) conversations.verbose
- 0=brief, 1=without-policies, 2=full-detailprotected void initJADE()
public Formula assert_(String formula) throws ParseException
ParseException
public Formula assert_(String formula, CasaKB cacheKB) throws ParseException
ParseException
private static int printKBexpressions(AgentUI ui, String pattern, String text, boolean regex, boolean strict)
public QueryResult query(String formula) throws ParseException
ParseException
public boolean querywithFilter(String formula, TransientAgent a) throws ParseException
ParseException
public String query_toString(String formula) throws ParseException
ParseException
public static Set<String> recursiveParent(TransientAgent a, String x, Set<String> SI)
public static boolean searchOntology1(TransientAgent agent, ParamsMap params, AgentUI ui, Environment env, String expr)
public static boolean searchOntology(TransientAgent agent, ParamsMap params, AgentUI ui, Environment env, String expr)
public ListOfTerm queryRef(String formula) throws ParseException
ParseException
public SimpleString query_ref(String formula)
public LispObject kb_get_value(String attrName)
public String queryRef_toString(String formula) throws ParseException
ParseException
public List<Term> queryRef_toTermList(String formula) throws ParseException
ParseException
public List<String> queryRef_toStringList(String formula) throws ParseException
ParseException
public List<Integer> queryRef_toIntegerList(String formula) throws ParseException
ParseException