public class Conversation extends BoundSymbolObject implements Comparable<Conversation>
BoundSymbolObject.Symbols
Modifier and Type | Field and Description |
---|---|
(package private) TransientAgent |
agent |
private static CasaLispOperator |
CONVERSATION
(Conversation ...)
|
private static CasaLispOperator |
CONVERSATION__EXECUTE_ACTION
Lisp operator: (conversation.set-state)
Sets the state of the current specified |
private static CasaLispOperator |
CONVERSATION__GET_STATE
Lisp operator: (conversation.get-state)
Gets the state of the conversation specified |
private static CasaLispOperator |
CONVERSATION__SET_ACTION
Lisp operator: (conversation.set-state)
Sets the state of the current specified |
private static CasaLispOperator |
CONVERSATION__SET_STATE
Lisp operator: (conversation.set-state)
Sets the state of the current specified |
private Action |
failureAction |
private String |
id |
static Conversations |
knownConversations
All conversations known in the current process -- not necessarily supported by any agent in the process.
|
ReentrantLock |
lock |
private PolicyContainer |
policies
The list of all policies for the Conversation
|
(package private) String |
sourceFile |
private Action |
successAction |
children, name, symbols
Modifier | Constructor and Description |
---|---|
|
Conversation(String name)
Creates a top-level conversation template.
|
|
Conversation(String name,
Conversation parent)
Creates a child conversation template.
|
protected |
Conversation(String name,
TransientAgent ownerAgent,
MLMessage message,
Pair<String,Object>... bindings)
Constructor for a conversation instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(BoundSymbolObject child)
Add a child to the child conversation list
|
void |
addPolicy(AbstractPolicy policy) |
void |
addSubConversation(Conversation conv)
adds a conversation as a sub conversation to this one
|
protected StatusObject<List<Object>> |
applyPolicies(Event event)
***Warning: It's not very efficient to call this method.
|
void |
bindVar(String sym,
Object val)
This method adds two functionalities to
BoundSymbolObject.bindVar(String, Object) :
if sym is "STATE" and val is "terminated", queue this conversation for deletion. |
void |
bindVarExpression(String sym,
LispObject exp)
Create a local binding for this symbols sym.
|
void |
bindVarTo(String sym,
String parentSym)
Bind the value of sym to the parent's local
symbol sym.
|
int |
compareTo(Conversation o) |
protected BoundSymbolObject |
copyTo(BoundSymbolObject x) |
private static int |
count(Boolean... b) |
protected void |
deleteSelf() |
void |
destroy()
Desperate attempt to get the gc to clear objects when we think this one is dead.
|
static Conversation |
findConversation(String conv) |
Vector<Pair<Conversation,AbstractPolicy>> |
getApplicablePolicies(PolicyAgentInterface agent,
Event event)
Note that there is not "isApplicable(Event)" method in this class.
|
Conversation |
getChild(String childName) |
Collection<Conversation> |
getChildConversations() |
String |
getId() |
static Collection<Conversation> |
getKnownConversations() |
protected Conversation |
getParent() |
PolicyContainer |
getPolicies()
getter method for the conversation's policies
|
String |
getSourceFile() |
String |
getState() |
Map<String,LispObject> |
getSymbolMap() |
Object |
getVar(String sym)
Resolve the value of symbols sym.
|
Conversation |
instantiate(TransientAgent ownerAgent,
MessageEvent event,
Object overRideSuccessHandler,
Object overRideFailureHandler) |
private void |
instantiateHelper(TransientAgent ownerAgent,
MessageEvent event,
Conversation template)
fix up all the children (that have already been cloned by
BoundSymbolObject.clone() )
evaluates symbols
sets the state to "init"
|
boolean |
isTemplate() |
void |
setName(String newName) |
protected void |
setParent(Conversation parent) |
protected void |
setSourceFile(String sourceFile) |
void |
setState(String state)
Conversation state
|
String |
toString() |
String |
toString(int indent,
boolean brief) |
bindValue, bindVarTo, clearChildren, clone, extendEnv, getChildren, getMap, getName, setParent
TransientAgent agent
public ReentrantLock lock
private PolicyContainer policies
private Action successAction
private Action failureAction
public static Conversations knownConversations
private String id
private static final CasaLispOperator CONVERSATION
private static final CasaLispOperator CONVERSATION__SET_STATE
private static final CasaLispOperator CONVERSATION__SET_ACTION
private static final CasaLispOperator CONVERSATION__EXECUTE_ACTION
String sourceFile
private static final CasaLispOperator CONVERSATION__GET_STATE
public Conversation(String name)
name
- public Conversation(String name, Conversation parent)
name
- parent
- protected Conversation(String name, TransientAgent ownerAgent, MLMessage message, Pair<String,Object>... bindings) throws IllegalOperationException
instantiate(TransientAgent, MessageEvent, Object, Object)
, which is the correct way
to instantiate a conversation instance from a conversation template.name
- the name of the lisp function defining the type of conversation we wantownerAgent
- the name of the registered agent that wants to have this conversationmessage
- the constructed KQML message containing the relevant databindings
- string object pairs (Ex. ,['to',URL] and ['from',URL] information)IllegalOperationException
public static Conversation findConversation(String conv)
conv
- the name of the conversation to return.knownConversations
, or null
if the named conv can't be found.public static Collection<Conversation> getKnownConversations()
knownConversations
.public String getId()
public void setName(String newName)
setName
in class BoundSymbolObject
public void setState(String state)
protected void deleteSelf()
public Object getVar(String sym) throws IllegalOperationException
BoundSymbolObject
getVar
in class BoundSymbolObject
IllegalOperationException
- if the sym is not evaluatedpublic void bindVar(String sym, Object val)
BoundSymbolObject.bindVar(String, Object)
:
bindVar
in class BoundSymbolObject
sym
- the symbol to bindval
- the object to bind to symBoundSymbolObject.bindVar(java.lang.String, java.lang.Object)
public void bindVarExpression(String sym, LispObject exp)
BoundSymbolObject
bindVarExpression
in class BoundSymbolObject
public void bindVarTo(String sym, String parentSym) throws IllegalOperationException
BoundSymbolObject
bindVarTo
in class BoundSymbolObject
IllegalOperationException
- if childName isn't the name of a child of this conversationpublic String getState()
public Conversation instantiate(TransientAgent ownerAgent, MessageEvent event, Object overRideSuccessHandler, Object overRideFailureHandler) throws IllegalOperationException
IllegalOperationException
protected BoundSymbolObject copyTo(BoundSymbolObject x) throws CloneNotSupportedException
copyTo
in class BoundSymbolObject
CloneNotSupportedException
private void instantiateHelper(TransientAgent ownerAgent, MessageEvent event, Conversation template) throws IllegalOperationException
BoundSymbolObject.clone()
)
ownerAgent
- event
- template
- IllegalOperationException
protected void setParent(Conversation parent)
protected Conversation getParent()
getParent
in class BoundSymbolObject
protected void addChild(BoundSymbolObject child)
BoundSymbolObject
addChild
in class BoundSymbolObject
public Conversation getChild(String childName)
getChild
in class BoundSymbolObject
public Collection<Conversation> getChildConversations()
public boolean isTemplate()
public void addPolicy(AbstractPolicy policy)
public void addSubConversation(Conversation conv)
conv
- the conversation to add as a child of this conversationpublic Vector<Pair<Conversation,AbstractPolicy>> getApplicablePolicies(PolicyAgentInterface agent, Event event)
applyPolicies(Event)
, so the information should be cached
as in the following pattern:
...
Vector < AbstractPolicy > applicable = conv.getApplicablePolicies(event)
;
if (applicable!=null) result = conv.applyPolicies(event,applicable)
;
...
event
- public PolicyContainer getPolicies()
protected StatusObject<List<Object>> applyPolicies(Event event) throws Exception
...
Vector < AbstractPolicy > applicable = conv.getApplicablePolicies(event)
;
if (applicable!=null) result = applyPolicies(event,applicable)
;
...
event
- Exception
public Map<String,LispObject> getSymbolMap()
public String toString(int indent, boolean brief)
public int compareTo(Conversation o)
compareTo
in interface Comparable<Conversation>
public void destroy()
destroy
in class BoundSymbolObject
private static int count(Boolean... b)
protected void setSourceFile(String sourceFile)
public String getSourceFile()