public class LAC extends CASAProcess implements LACInterface
TransientAgent
, this agent can originate the following
messages types:
performative | act | see | reply handler |
---|---|---|---|
inform | LAC.closing | informTerminateProcess() | - |
TransientAgent
, this agent responds
to the following messages types:
performative | act | see |
---|---|---|
request | register.instance | #respondToRegisterAgentInstance(MLMessage) |
request | register.agentType | #respondToRegisterAgentType(MLMessage) |
request | unregister.instance | #respondToUnregisterAgentInstance(MLMessage) |
request | unregister.agentType | #respondToUnregisterAgentType(MLMessage) |
request | resolve.url | #respondToResolveURL(MLMessage) |
request | find.instance | #respondToFindInstances(MLMessage) |
request | run.agent | #respondToRunAgent(MLMessage) |
inform | register.instance | #handleUnregisterAgentInstance(MLMessage) |
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
CASAProcess.ProcessInfo
TransientAgent.Conversations, TransientAgent.NewAgentLispCommand
AbstractProcess.Subthread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
(package private) CASAFile |
casaFile |
private static int |
cdIndex |
(package private) CASAFileLACKnownUsersMap |
knownUserMap |
private static int |
otherIndex |
(package private) CASAFilePropertiesMap |
properties
The CASAFilePropertiesMap associated with this LAC for persistence (LAC is not a (persistent) Agent, so it needs to implement it's own persistence)
|
protected Hashtable<String,RunDescriptor> |
registeredAgents
Don't confuse "runningAgents" with "registeredAgents".
|
Vector<URLDescriptor> |
removedVector |
protected String |
rootDirectory
The directory used as the root of all information about casa agents: where
all the .casa files are stored.
|
protected ConcurrentSkipListMap<String,URLDescriptor> |
runningAgents
Don't confuse "runningAgents" with "registeredAgents".
|
(package private) Hashtable<?,?> |
tempUserTable |
(package private) int |
userCounter |
(package private) Hashtable<String,String> |
validUsers |
instance, lacWindow, strategy
agentConstructorComplete
cacheKB, CDInvitedTo, CDinvitee, conversationData, defaultOntologyClassName, DEFER_ACTION, DROP_ACTION, kBase, lisp, lispEnvironment, ListOfArgs, methodMap, ontologyEngine, ontologyEngineCreateMethod, ontologyEngineLoadMethod, policies, policiesAlwaysApply, policiesLastResort, primaryUI, proxy, UIs, usingProxy
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
Modifier and Type | Method and Description |
---|---|
protected PerformDescriptor |
accept_UnregisterAgentInstance(MLMessage message)
Handler for an unregister.instance message that has an
inform performative.
|
private void |
addToListofKnownUsers(URLDescriptor newURL)
TODO set the userCounter variable in order to have knowledge of how many times does this user
sign in to the system
|
PerformDescriptor |
consider_new_MenuItem(MLMessage message)
|
private void |
createDirectories()
Creates all sub directories needed to write the
CASAFile for
this agent. |
protected LinkedList<URLDescriptor> |
createPriorityQueue(LinkedList<URLDescriptor> lList)
Since there is a specific order to follow during the event LAC.LAC_CLOSING, this function organizes
all the URLDescriptors of the running agents (under this process) in a PriorityQueue.
|
void |
deleteFile(String path) |
protected void |
exit2(CASAProcess agent) |
String |
file2path(String file)
Returns a complete a path name (that is,
the agent list and agent name (eg.
|
StatusURLDescriptorList |
findInstances(String pattern) |
Hashtable<String,RunDescriptor> |
getAgentsRegistered()
getAgentsRegistered()
|
ConcurrentSkipListMap<String,URLDescriptor> |
getAgentsRunning()
getAgentsRunning()
|
Vector<String> |
getAgentsRunningVector(URLDescriptor relativeTo) |
String |
getCASAFilename()
Returns the filename of the
CASAFile that will be used by
this LAC to store its properties and data either temporarily or
persistently. |
Vector<?> |
getRegisteredAgentsVector() |
String |
getRoot()
Returns the root directory for this LAC.
|
RunDescriptor |
getRunDescriptor(String path)
Looks up a RunDesciptor, given a type-path
|
Vector<URLDescriptor> |
getRunningAgentDescriptors() |
boolean |
informTerminateProcess()
Once the PriorityQueue has been created, this method iterates through the PriorityQueue and sends
a message informing each agent (running under this process) that the LAC is closing.
|
private void |
initializeFile()
This initializes both the
CASAFile that will be used to store
the data, and the properties object. |
protected void |
initializeThread(ParamsMap params,
AgentUI ui)
This method is safe as it called from the thread of the agent (not the constructor)
|
private void |
initRunningAgents() |
AgentUI |
makeDefaultGUI(String[] args)
Perform the action for an incoming request message for a getAgentsRunning act-type request conversation.
|
protected ProcessOptions |
makeOptions()
Factory method to make a new options object.
|
String |
path2file(String path)
Returns a complete file spec string corresponding to an agent path name (that is,
the agent list and agent name (eg.
|
protected void |
pendingFinishRun_unregisterAgentInstance()
If this agent is registered with the lack (
TransientAgent.isRegistered() ) then
unregister it by calling doUnregisterAgentInstance(false) . |
protected void |
pendingFinishRun()
This is called when the agent is shutting down.
|
protected PerformDescriptor |
perform_FindInstances(MLMessage message) |
PerformDescriptor |
perform_get_agents_registered(MLMessage msg)
Perform the action for an incoming request message for a getAgentsRegistered act-type request conversation.
|
PerformDescriptor |
perform_get_agents_running(MLMessage msg)
Perform the action for an incoming request message for a
get_agents_running act-type request conversation.
|
PerformDescriptor |
perform_register_instance(MLMessage msg) |
protected PerformDescriptor |
perform_RegisterAgentType(MLMessage message)
Handler for a register.agentType message.
|
PerformDescriptor |
perform_resolve_url(MLMessage message)
Handler for a resolve-url message.
|
protected PerformDescriptor |
perform_run_agent(MLMessage message) |
protected PerformDescriptor |
perform_UnregisterAgentInstance(MLMessage message)
Handler for an unregister.instance message that has a
request performative.
|
protected PerformDescriptor |
perform_UnregisterAgentType(MLMessage message)
Handler for an unregister.agentType message.
|
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.
|
StatusURLandFile |
registerAgentInstance(URLDescriptor newURL)
Registers an agent instance according to
LACInterface.registerAgentInstance(URLDescriptor) . |
Status |
registerAgentType(String path,
RunDescriptor r)
Registers an agent type according to
LACInterface.registerAgentType(String RunDescriptor).
|
Status |
resolveURL(URLDescriptor url)
Attempts to resolve a URL by the following method:
checks for matching registered agent instances and updates url
and returns if a match is found.
|
Status |
runAgent(URLDescriptor url)
Run an agent based on the parameter URL.
|
Status |
unregisterAgentInstance(URLDescriptor newURL)
Unregisters an agent instance according to LACInterface.unregisterAgentInstance(URLDescriptor).
|
Status |
unregisterAgentType(String path)
Unregisters an agent instance according to
LACInterface.unregisterAgentType(String).
|
String |
url2file(URLDescriptor url)
Returns a complete file spec string corresponding to the URL.
|
exit, getDefaultBanner, getInstance, getProcessOptions, getRootDirectoryDefault, getStrategy, informAgent_GUIOperationRequest, isObserveMessages, main, setStrategy, staticPath2file, staticUrl2file
destroyDataObject, finalize, getAgentOptions, getBooleanProperty, getCreateDate, getDataObject, getDataObjectInputStream, getDataObjectOutputStream, getDoubleProperty, getFloatProperty, getIntegerProperty, getLongProperty, getOptions, getStringProperty, hasProperty, initializeAfterRegistered, isPersistent, makeDefaultInternalFrame, putDataObject, putDataObject, readPersistent, ready, realizeAgentBehaviourFromOptions, removeProperty, setBooleanProperty, setDoubleProperty, setFloatProperty, setIntegerProperty, setLongProperty, setOptions, setPersistent, setStringProperty, updateOptions, writePersistent
abclEval, abclEval, abclEval, accept_deleteCD, accept_exit, accept_forward_message, accept_LAC_closing, accept_new_MenuItem, accept_update, acceptDefault, addConversation, addJoinedCooperationDomain, addMembers, addSubscribeEvents, assembleDefault, assert_, assert_, authorizedByProxy, authorizeMessage, chooseSC, concludeDefault, consider_execute, consider_invite_to_cd, consider_ping, consider_query_if, consider_query_ref, considerDefault, createCasaLispOperators, dispatchMsgHandlerMethod, doAddObserver, doAdvertise, doCDGetHistory_sync, doCDGetMembers, doCDPutData, doCDSubscribeMembership, doFindInstances_sync, doGetCooperationDomains, doGetOnology, doInviteToCD, doJoinCD, doPing_sync, doPing, doRegisterAgentInstance, doRegisterAgentInstance, doResolveURL, doSearchYP, doUnadvertise, doUnregisterAgentInstance, doUnregisterAgentType, doWithdrawCD, evaluateDefault, evesdrop, executeCommand, findFileResourcePath, findFileResourcePath, getAgentForThread, getAlwaysApplyPolicies, getBanner, getCachedKnowledgeBase, getChosenCommitment, getCommitmentProcessor, getConversation, getConversations, getConversationsReport, getDefFileSystemLocations, getEventForThread, getField, getInstancesFound, getJoinedCooperationDomain, getJoinedCooperationDomains, getKnowledgeBase, getLACURL, getLastResortPolicies, getMembers, getMsgForThread, getObjectsForThread, getOntology, getOntologyEngine, getOntologyFileSuffix, getPolicies, getPrimaryUI, getProxy, getSCStore, getSerializedOntology, getStrategyGUI, getSubscribeEvents, getSubscribeEvents, getTermsFromContent, getUI, getUIForThread, getUIs, getUnfulfilledSocialCommitments, getUnfulfilledSocialCommitments, handleErrorReplies, handleEvent, handleLACClosing, hasActiveCommitments, hasConversation, hasStrategyGUI, initializePolicies, initJADE, initUI, isEventQueueReady, isRegistered, isRegisteredWithLAC, isStoppable, isTrusted, isTrusted, isUsingProxy, kb_get_value, makeDefaultInterface, makeDefaultTextInterface, monitorDefault, notifySendingMessage, optionsToString, parseJADENode, pendingFinishRun_withdrawFromAllCDs, perform_execute, perform_FIPAStyle, perform_get_name, perform_get_ontology, perform_invite_to_cd, perform_method_call, perform_query_if, perform_query_if, perform_query_ref, perform_query_ref, performDefault, processCommitment, processCommitments, processObserverNotification, putExtendedOntology, putPolicy, putPolicyAlwaysApply, putPolicyLastResort, putReplacementOntology, query_ref, query_toString, query, queryIf, queryRef_toIntegerList, queryRef_toString, queryRef_toStringList, queryRef_toTermList, queryRef, queryRef, queryRefAIDs, queryRefURLs, querywithFilter, recursiveParent, recursivePermutations, release_execute, release_FIPAStyle, release_get_agents_registered, release_get_agents_running, release_get_members, release_get_ontology, release_join_cd, release_ping, release_query_if, release_query_ref, release_resolve_url, release_unregister_agentType, release_unregister_instance, release_withdraw_cd, releaseDefault, removeConversation, removeCooperationDomains, removeJoinedCooperationDomain, removeSubscribeEvents, requestInstances, resolveConnectException, retrieveReturnedData, saveReturnedData, searchOntology, searchOntology1, setBanner, setCommitmentProcessor, setField, setInstancesFound, setOntology, shouldDoExecuteRequest, template_handleNewOntologyInfo, update, updateConversationProtocolType, verifyCD, verifyDefault, verifyMessage
addObserver, addObserver, addObserver, addObserver, addTraceTags, addTransformation, bump, clearAllTraceTags, closePort, compareTo, countObservers, defer, defer, deleteObserver, deleteObserver, deleteObservers, dequeueEvent, equals, eventBufferLoopBody, eventBufferLoopPeriodic, eventQueuePeek, existed, finishRun, fixupMessage, getAgent, getAgentName, getEventQueue, getInitParams, getNewMessage, getNewMessage, 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, isPaused, isThisMyAddress, isTracing, loadClass, 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, setPause, setTraceTags, setTracing, setURL, setUseAckProtocol, setUsePriority, startSocketServer, startTraceMonitor, step, transform, transform, unhandledMessage
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
doAdvertise, doCDGetHistory_sync, doCDGetMembers, doCDPutData, doFindInstances_sync, doGetCooperationDomains, doGetOnology, doInviteToCD, doJoinCD, doPing_sync, doPing, doRegisterAgentInstance, doRegisterAgentInstance, doSearchYP, doUnadvertise, doUnregisterAgentInstance, doUnregisterAgentType, doWithdrawCD, executeCommand, getInstancesFound, getJoinedCooperationDomains, getLACURL, getMembers, getOntology, getOptions, getSerializedOntology, getStrategyGUI, hasStrategyGUI, isAAct, isInitialized, isRegistered, makeDefaultInterface, putExtendedOntology, putReplacementOntology, release_get_ontology, removeCooperationDomains, requestInstances, setOptions, updateOptions
addObserver, addObserver, closePort, deleteObserver, deleteObserver, exit, getAgentName, getName, getNewMessage, getPort, getStrategy, getTrace, getUniqueRequestID, getURL, getUseAckProtocol, hasOpenPort, isA, isAPerformative, isExiting, isLoggingTag, isStoppable, isTracing, println, println, println, realizeAgentBehaviourFromOptions, sendMessage, setTracing, setUseAckProtocol, startTraceMonitor
addObserver, addObserver, countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers, notifyObserversWithNoArg, notifyObserversWithTop
abclEval, abclEval, abclEval, addTransformation, bump, chooseSC, defer, dequeueEvent, dispatchMsgHandlerMethod, evesdrop, getKnowledgeBase, getName, getSCStore, getSubscribeEvents, getTransformationFor, getUniqueRequestID, getURL, getUseAckProtocol, isA, isA, isA, isA, isAPerformative, isAPerformative, isLoggingTag, notifyObservers, println, println, println, queueEvent, queueEventIf, revTransform, revTransform, sendMessage, transform, transform
protected ConcurrentSkipListMap<String,URLDescriptor> runningAgents
forall x:URLDescriptor.(x.getPath(), x)
protected Hashtable<String,RunDescriptor> registeredAgents
forall x:URLDescriptor. (String path, RunDescriptor)
protected String rootDirectory
CASAFile casaFile
CASAFilePropertiesMap properties
CASAFileLACKnownUsersMap knownUserMap
private static int cdIndex
private static int otherIndex
public Vector<URLDescriptor> removedVector
Hashtable<?,?> tempUserTable
int userCounter
protected ProcessOptions makeOptions()
AbstractProcess
makeOptions
in class Agent
public String getRoot()
public String url2file(URLDescriptor url)
url
- to compute the file spec frompublic String path2file(String path)
path
- path to compute the file spec frompublic String file2path(String file)
file
- to compute the file spec frompublic String getCASAFilename()
CASAFile
that will be used by
this LAC to store its properties and data either temporarily or
persistently.getCASAFilename
in interface AgentInterface
getCASAFilename
in class Agent
CASAFile
that will be used by
this agent to store its properties and data.private void createDirectories() throws IOException
CASAFile
for
this agent.IOException
- If one of the directories could not be created.private void initializeFile()
CASAFile
that will be used to store
the data, and the properties object.protected void initializeThread(ParamsMap params, AgentUI ui)
initializeThread
in class CASAProcess
protected void pendingFinishRun()
Agent
CASAFile
.pendingFinishRun
in class Agent
AbstractProcess.pendingFinishRun()
protected void pendingFinishRun_unregisterAgentInstance()
TransientAgent
TransientAgent.isRegistered()
) then
unregister it by calling doUnregisterAgentInstance(false)
.pendingFinishRun_unregisterAgentInstance
in class TransientAgent
protected void exit2(CASAProcess agent)
exit2
in class CASAProcess
private void initRunningAgents()
public StatusURLandFile registerAgentInstance(URLDescriptor newURL)
LACInterface.registerAgentInstance(URLDescriptor)
.registerAgentInstance
in interface LACInterface
newURL
- unregiserAgentInstance(URLDescriptor)
private void addToListofKnownUsers(URLDescriptor newURL)
newURL
- the users' URLDescriptorpublic PerformDescriptor perform_register_instance(MLMessage msg)
public Status registerAgentType(String path, RunDescriptor r)
registerAgentType
in interface LACInterface
path
- r
- unregiserAgentType(String), RunDescriptor
public RunDescriptor getRunDescriptor(String path)
path
- A path of the form x/y/zprotected PerformDescriptor perform_RegisterAgentType(MLMessage message)
message
- The incoming messagepublic Status unregisterAgentInstance(URLDescriptor newURL)
unregisterAgentInstance
in interface LACInterface
newURL
- regiserAgentInstance(URLDescriptor)
protected PerformDescriptor perform_UnregisterAgentInstance(MLMessage message)
message
- The incoming messageprotected PerformDescriptor accept_UnregisterAgentInstance(MLMessage message)
message
- The incoming messagepublic Status unregisterAgentType(String path)
unregisterAgentType
in interface LACInterface
path
- regiserAgentType(String)
protected PerformDescriptor perform_UnregisterAgentType(MLMessage message)
message
- The incoming messagepublic PerformDescriptor perform_get_agents_registered(MLMessage msg)
PerformDescriptor
.getStatusValue()
of 0 or positive to make the reply a SUCCESS, or a negative value to indicate FAILURE. It may influence
the reply by calling
PerformDescriptor.put(messageKey,value)
on the
return PerformDescriptor
. For example,
ret.put(ML.CONTENT
,"content"} will fill the content field with "content"
in the message to the client. The default return
message will be an SUCCESS. This method is required.msg
- The outgoing AGREE messagepublic PerformDescriptor perform_get_agents_running(MLMessage msg)
PerformDescriptor
.getStatusValue()
of 0 or positive to make the reply a SUCCESS, or a negative value to indicate FAILURE. It may influence
the reply by calling
PerformDescriptor.put(messageKey,value)
on the
return PerformDescriptor
. For example,
ret.put(ML.CONTENT
,"content"} will fill the content field with "content"
in the message to the client. The default return
message will be an SUCCESS. This method is required.msg
- The outgoing AGREE messagepublic StatusURLDescriptorList findInstances(String pattern)
protected PerformDescriptor perform_FindInstances(MLMessage message)
public Status resolveURL(URLDescriptor url)
resolveURL
in interface LACInterface
url
- the unresolved URL, which will be updated to a resolved URL if successfull.public PerformDescriptor perform_resolve_url(MLMessage message)
message
- The incoming messageprotected PerformDescriptor perform_run_agent(MLMessage message)
public Status runAgent(URLDescriptor url)
url
- public Vector<String> getAgentsRunningVector(URLDescriptor relativeTo)
public Vector<URLDescriptor> getRunningAgentDescriptors()
public Vector<?> getRegisteredAgentsVector()
public PerformDescriptor consider_new_MenuItem(MLMessage message)
TransientAgent
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).consider_new_MenuItem
in class TransientAgent
message
- PerformDescriptor
Calls {@link #lacWindow}.{@link LACWindow#createRequestedMenuItem(MLMessage)}
and then the parent implementation.
public boolean informTerminateProcess()
protected LinkedList<URLDescriptor> createPriorityQueue(LinkedList<URLDescriptor> lList)
lList
- is a LinkedList that is going to work as a PriorityQueuepublic void deleteFile(String path)
public Hashtable<String,RunDescriptor> getAgentsRegistered()
public ConcurrentSkipListMap<String,URLDescriptor> getAgentsRunning()
public AgentUI makeDefaultGUI(String[] args)
PerformDescriptor
.getStatusValue()
of 0 or positive to make the reply a SUCCESS, or a negative value to indicate FAILURE. It may influence
the reply by calling
PerformDescriptor.put(messageKey,value)
on the
return PerformDescriptor
. For example,
ret.put(ML.CONTENT
,"content"} will fill the content field with "content"
in the message to the client. The default return
message will be an SUCCESS. This method is required.makeDefaultGUI
in class CASAProcess
msg
- The outgoing AGREE messagepublic void putUI(AgentUI ui)
TransientAgent
TransientAgent.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
putUI
in class CASAProcess
ui
- the user interface to be attached to the agent.