kaos.core.csi
Class KAoSActorImpl

java.lang.Object
  extended by kaos.core.csi.KAoSActorImpl
All Implemented Interfaces:
KAoSActor
Direct Known Subclasses:
BLIKExample, BLIKNotifyEnforcerExample, HistoryAgent, LoginSimulationAgent

public class KAoSActorImpl
extends java.lang.Object
implements KAoSActor

$Revision: 1.14 $


Field Summary
protected  boolean _autoCommit
           
protected  Locator _lctr
           
protected static Logger _logger
           
protected  java.util.List _propertiesToModify
           
protected  boolean _registered
           
protected  Registration _registration
           
protected  java.util.Hashtable _transports
           
protected  TransportSupport _transportSupport
           
 
Constructor Summary
KAoSActorImpl(java.lang.String guid, java.lang.String name, java.util.Vector domainNames, Transport transport)
          Instantiates a new KAoS-aware agent using JAS services for transport, naming and agent directory.
 
Method Summary
 void addCapability(AgentCapability capability)
          Add an AgentCapability this KAoSActor offers.
 void addOntologicalType(java.lang.String type, java.lang.String owlDesc)
          Add an ontological type to the collection of types held by the KAoSActor.
 void addProperty(Property property, java.lang.Object value)
          Add the specified property, whose name and value are given to the collection of properties of this KAoSActor.
 void addPropertyValue(Property property, java.lang.Object value)
          Add the specified value to the list of values of the given property.
 void addTransport(Transport transport)
          Add the specified Transport to the collection of available Transports.
 void commitPropertyValues()
          Commit any property value changes that were not yet send to the Directory Service.
 boolean equals(java.lang.Object obj)
          Two agents are equal if their respective hash codes are equal.
 KAoSAgentDescription getAgentDescription()
           
 java.util.List getCapabilities()
          Obtain the collection of AgentCapabilities of this KAoSActor.
 java.lang.String getConceptMappingName()
          Get the name of the concept mapping between the entity system's ontological concepts and KAoS ontology.
 java.util.List getDomainNames()
          Returns a List of String containing the names of domains the actor is registered in.
 java.util.Enumeration getEntityOntologicalTypeNames()
          Obtain the collection of just names of ontological types of KAoS entity described by this KAoSActor.
 java.util.Map getEntityOntologicalTypes()
          Obtain the collection of ontological types of this KAoSActor.
 java.lang.String getGUID()
          Obtain the actor's globally unique identifier.
 java.lang.String getName()
          Obtain the actor's name.
 java.util.Hashtable getProperties()
          Returns a Hashtable containing a mapping of actor properties.
 Property getProperty(java.lang.String name)
          Return the property, whose name is specified
 java.lang.Object getPropertyValue(Property property)
          Return the value of the given property
 Transport getTransport(java.lang.String name)
          Return the Transport, whose name is specified.
 java.util.List getTransports()
          Return the List of valid Transports.
 int hashCode()
          Determines the hash code for the KAoSActor.
 boolean isAutoPropertyValueCommit()
          Indicates whether property value changes are automatically committed to the Directory Service (default = true).
 boolean isGuarded()
          Obtain guarded/unguarded status of this KAoSActor.
 boolean isRegistered()
          Obtain registered/unregistered status of this KAoSActor.
protected  void logMessage(java.lang.String msg, java.lang.Exception e, int logLevel)
           
protected  void logMessage(java.lang.String msg, int logLevel)
           
static void main(java.lang.String[] args)
           
protected  void printTransportMessage(TransportMessage tmsg)
           
 void receiveMessage(java.io.Serializable messageContent, KAoSActor sender)
          Receive the specified message content from the given KAoSActor.
 void receiveMessage(TransportMessage tmsg)
          Implements the receiveMessage method mandated by the MessageListener interface.
 boolean removeCapability(AgentCapability capability)
          Remove the specified AgentCapability from the collection of this KAoSActor's capabilities.
 boolean removeOntologicalType(java.lang.String type)
          Remove an ontological type from the collection of types held by the KAoSActor.
 void removeProperty(Property property)
          Remove the specified property from the collection of properties of this KAoSActor.
 void removePropertyValue(Property property, java.lang.Object value)
          Remove the specified value from the list of values of the given property.
 void removeTransport(Transport transport)
          Remove the specified Transport from the collection of actor's Transports.
 void sendMessage(java.io.Serializable messageContent, KAoSActor receiver)
          Send the specified message content to the given KAoSActor.
 void setAutoPropertyValueCommit(boolean autoCommit)
          Set the auto property value commit flag to true or false.
 void setCapabilities(java.util.List capabilities)
          Set the collection of AgentCapabilities of this KAoSActor.
 void setConceptMappingName(java.lang.String mappingName)
          Set the name of the concept mapping between the entity system's ontological concepts and KAoS ontology.
 void setGUID(java.lang.String actorGUID)
          Set the actor's globally unique identifier.
 void setName(java.lang.String name)
          Set the actor's name.
 void setOntologicalTypes(java.util.Map types)
          Set the ontological types of this KAoSActor.
 void setProperties(java.util.Hashtable properties)
          Set a Hashtable containing a mapping of actor properties.
 void setPropertyValue(Property property, java.lang.Object value)
          Replace the specified value with the given value of the given property
 void setRegistered(boolean registered)
          Set the registered/unregistered status of this KAoSActor.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logger

protected static Logger _logger

_registration

protected Registration _registration

_transportSupport

protected TransportSupport _transportSupport

_autoCommit

protected boolean _autoCommit

_registered

protected boolean _registered

_transports

protected java.util.Hashtable _transports

_propertiesToModify

protected java.util.List _propertiesToModify

_lctr

protected Locator _lctr
Constructor Detail

KAoSActorImpl

public KAoSActorImpl(java.lang.String guid,
                     java.lang.String name,
                     java.util.Vector domainNames,
                     Transport transport)
              throws java.lang.Exception
Instantiates a new KAoS-aware agent using JAS services for transport, naming and agent directory.

Throws:
java.lang.Exception
Method Detail

getConceptMappingName

public java.lang.String getConceptMappingName()
Get the name of the concept mapping between the entity system's ontological concepts and KAoS ontology.

Specified by:
getConceptMappingName in interface KAoSActor
Returns:
String specifying the name of the mapping to be used to translate ontological names from the entity system to KAoS ontologies. The default name is "KAoS" indicating KAoS ontologies to be used, no translation necessary.

setConceptMappingName

public void setConceptMappingName(java.lang.String mappingName)
Set the name of the concept mapping between the entity system's ontological concepts and KAoS ontology.

Parameters:
mappingName - The name of the mapping to be used to translate ontological names from the entity system to KAoS ontologies.

getDomainNames

public java.util.List getDomainNames()
Returns a List of String containing the names of domains the actor is registered in. Note: When the actor first registers with the DS, this List is checked and, if not empty, the actor will be registered in the specified domains. Subsequently, if the actor wants to register in additional domains, then the actor has to lookup the desired domain and register in it via the Domain.registerAgent() method, which will update this List after successful registration.

Specified by:
getDomainNames in interface KAoSActor
Returns:
List of domain names contained by this KAoSActor.

getGUID

public java.lang.String getGUID()
Obtain the actor's globally unique identifier.

Specified by:
getGUID in interface KAoSActor
Returns:
String representing the actor's guid.

setGUID

public void setGUID(java.lang.String actorGUID)
Set the actor's globally unique identifier.

Parameters:
actorGUID - String containing actor's globally unique identifier.

getName

public java.lang.String getName()
Obtain the actor's name.

Specified by:
getName in interface KAoSActor
Returns:
String representing the actor's name.

setName

public void setName(java.lang.String name)
Set the actor's name.

Parameters:
name - String containing the actor's name.

addOntologicalType

public void addOntologicalType(java.lang.String type,
                               java.lang.String owlDesc)
Add an ontological type to the collection of types held by the KAoSActor. The default for an agent is http://ontology.ihmc.us/Actor.owl#Agent.

Parameters:
type - String containing the name of ontological type of this actor.
owlDesc - String containing OWL description of the corresponding ontological type.

removeOntologicalType

public boolean removeOntologicalType(java.lang.String type)
Remove an ontological type from the collection of types held by the KAoSActor.

Parameters:
type - The name of the ontological type to be removed from the collection of ontological types.
Returns:
true if the collection of ontological types contained the specified type; otherwise return false.

setOntologicalTypes

public void setOntologicalTypes(java.util.Map types)
Set the ontological types of this KAoSActor. NOTE: The new types replace existing ones, if there were any set!

Parameters:
types - Map containing type name -> OWL description mapping of ontological types of the entity this description is associated with.

getEntityOntologicalTypes

public java.util.Map getEntityOntologicalTypes()
Obtain the collection of ontological types of this KAoSActor. Presently, the types are defined by constants in kaos.ontology.vocabulary.ActorConcepts.

Specified by:
getEntityOntologicalTypes in interface KAoSActor
Returns:
Map containing mappings of ontological type names -> OWL descriptions of the types or null, if ontological types have not been set.

getEntityOntologicalTypeNames

public java.util.Enumeration getEntityOntologicalTypeNames()
Obtain the collection of just names of ontological types of KAoS entity described by this KAoSActor. Presently, the types are defined by constants in kaos.ontology.jena.ActorConcepts.

Specified by:
getEntityOntologicalTypeNames in interface KAoSActor
Returns:
Enumeration containing names of ontological types or null, if there no types specified in the KAoSActor.

isGuarded

public boolean isGuarded()
Obtain guarded/unguarded status of this KAoSActor.

Specified by:
isGuarded in interface KAoSActor
Returns:
boolean indicating whether the KAoSActor is guarded.

isRegistered

public boolean isRegistered()
Obtain registered/unregistered status of this KAoSActor.

Specified by:
isRegistered in interface KAoSActor
Returns:
boolean indicating whether the KAoSActor has been registered in the KAoS DS.

setRegistered

public void setRegistered(boolean registered)
Set the registered/unregistered status of this KAoSActor.

Specified by:
setRegistered in interface KAoSActor
Parameters:
registered - boolean indicating whether the KAoSActor has been registered in the KAoS DS.

addCapability

public void addCapability(AgentCapability capability)
                   throws ModificationException
Add an AgentCapability this KAoSActor offers.

Parameters:
capability - AgentCapability describing individual capability of this KAoSActor.
Throws:
ModificationException

removeCapability

public boolean removeCapability(AgentCapability capability)
                         throws ModificationException
Remove the specified AgentCapability from the collection of this KAoSActor's capabilities.

Parameters:
capability - The AgentCapability to be removed from the collection of this KAoSActor's capabilities.
Returns:
true if the collection of capabilities contained the specified capability; otherwise return false.
Throws:
ModificationException

setCapabilities

public void setCapabilities(java.util.List capabilities)
                     throws ModificationException
Set the collection of AgentCapabilities of this KAoSActor.

Parameters:
capabilities - List containing the AgentCapabilities of this KAoSActor.
Throws:
ModificationException

getCapabilities

public java.util.List getCapabilities()
Obtain the collection of AgentCapabilities of this KAoSActor.

Specified by:
getCapabilities in interface KAoSActor
Returns:
List of AgentCapability describing the capabilities of the actor.

setProperties

public void setProperties(java.util.Hashtable properties)
Set a Hashtable containing a mapping of actor properties. These properties will be stored as part of the actor registration info in the Directory Service under the specified keys.

Parameters:
properties - Hashtable containing properties this KAoSActor.

getProperties

public java.util.Hashtable getProperties()
Returns a Hashtable containing a mapping of actor properties. These properties will be stored as part of the actor registration info in the Directory Service under the specified keys. After registration properties can be modified via methods add/remove/setProperty methods.

Specified by:
getProperties in interface KAoSActor
Returns:
Hashtable of actor's properties.

isAutoPropertyValueCommit

public boolean isAutoPropertyValueCommit()
Indicates whether property value changes are automatically committed to the Directory Service (default = true). Calls to addPropertyValue, removePropertyValue and setPropertyValue will, when true, result in the immediate update of these value changes in the Directory Service. When false these value changes will not occur in the Directory Service until commitPropertyValues is called.

Returns:
booelan setting the auto commit flag.

setAutoPropertyValueCommit

public void setAutoPropertyValueCommit(boolean autoCommit)
Set the auto property value commit flag to true or false.

Parameters:
autoCommit - boolean specifying the auto commit flag.

addProperty

public void addProperty(Property property,
                        java.lang.Object value)
Add the specified property, whose name and value are given to the collection of properties of this KAoSActor.

Parameters:
property - Property to be added.
value - Object specifying the property value.

removeProperty

public void removeProperty(Property property)
Remove the specified property from the collection of properties of this KAoSActor.

Parameters:
property - Property to be removed.

commitPropertyValues

public void commitPropertyValues()
                          throws ModificationException
Commit any property value changes that were not yet send to the Directory Service. The use of this method allows the developer to make multiple property changes before sending these changes to the Directory Service to allow for a more optimized use of network bandwidth

Throws:
ModificationException - when one or more property changes failed to be committed to the Directory Service. The exception lists the properties for which the modification failed.

getProperty

public Property getProperty(java.lang.String name)
Return the property, whose name is specified

Specified by:
getProperty in interface KAoSActor
Parameters:
name - String containing the name of the property to be returned.

addPropertyValue

public void addPropertyValue(Property property,
                             java.lang.Object value)
                      throws ModificationException
Add the specified value to the list of values of the given property.

Parameters:
property - Property, whose value is to be added.
value - Object specifying the new value to be added to property values.
Throws:
ModificationException - when auto commit is true and when an error o ccurred trying to update the property in the directory service.

removePropertyValue

public void removePropertyValue(Property property,
                                java.lang.Object value)
                         throws ModificationException
Remove the specified value from the list of values of the given property.

Parameters:
property - Property, whose value is to be removed.
value - Object specifying the new value to be added to property values.
Throws:
ModificationException - when auto commit is true and when an error occurred trying to update the property in the Directory Service.

setPropertyValue

public void setPropertyValue(Property property,
                             java.lang.Object value)
                      throws ModificationException
Replace the specified value with the given value of the given property

Parameters:
property - Property, whose value is to be replaced.
value - Object specifying the new value to replace a property value.
Throws:
ModificationException - when auto commit is true and when an error occurred trying to update the property in the Directory Service.

getPropertyValue

public java.lang.Object getPropertyValue(Property property)
Return the value of the given property

Specified by:
getPropertyValue in interface KAoSActor
Parameters:
property - Property, whose value is to be returned.
Returns:
Object containing the given Property value.

sendMessage

public void sendMessage(java.io.Serializable messageContent,
                        KAoSActor receiver)
                 throws NotLocatableException,
                        TransportFailure
Send the specified message content to the given KAoSActor.

Specified by:
sendMessage in interface KAoSActor
Parameters:
messageContent - Serializable containing the message to be sent out.
receiverdesc - KAoSAgentDescription containing the description of the receiver.
Throws:
NotLocatableException - when the receiver cannot be located.
TransportFailureto - when the transport system fails.
TransportFailure

receiveMessage

public void receiveMessage(java.io.Serializable messageContent,
                           KAoSActor sender)
Receive the specified message content from the given KAoSActor.

Specified by:
receiveMessage in interface KAoSActor
Parameters:
messageContent - Serializable containing the received message.
senderDesc - KAoSAgentDescription containing the description of the sender.

getTransports

public java.util.List getTransports()
Return the List of valid Transports.

Specified by:
getTransports in interface KAoSActor
Returns:
List containing the supported Transports.

addTransport

public void addTransport(Transport transport)
                  throws NoSuchTransportException
Add the specified Transport to the collection of available Transports.

Parameters:
transport - Transport to be added to the collection of actor's Transports.
Throws:
NoSuchTransportException

removeTransport

public void removeTransport(Transport transport)
Remove the specified Transport from the collection of actor's Transports.

Parameters:
transport - Transport to be removed from the collection of actor's Transports.

getTransport

public Transport getTransport(java.lang.String name)
Return the Transport, whose name is specified.

Specified by:
getTransport in interface KAoSActor
Parameters:
name - String containing the Transport name to be retrieved.
Returns:
Transport whose name was specified.

receiveMessage

public void receiveMessage(TransportMessage tmsg)
Implements the receiveMessage method mandated by the MessageListener interface. This method prints the incoming TransportMessage to System.out.

See Also:
MessageListener, TransportMessage, "JAS Specification, Section(s) 3.4.2, 4.7.2"

equals

public boolean equals(java.lang.Object obj)
Two agents are equal if their respective hash codes are equal.

Overrides:
equals in class java.lang.Object
Returns:
true if obj equals this KAoSActor.
See Also:
hashCode(), "JAS Specification, Section(s) 4.7.2"

hashCode

public int hashCode()
Determines the hash code for the KAoSActor. The KAoSActor hash code is simply the hash code of the represented agents AgentName. If the AgentName field has not yet been set, then the hash code is found from super.hashCode() .

Overrides:
hashCode in class java.lang.Object
Returns:
int the hashCode for this KAoSActor.
See Also:
AgentName#hashCode, Object.hashCode(), "JAS Specification, Section(s) 4.7.2"

getAgentDescription

public KAoSAgentDescription getAgentDescription()

printTransportMessage

protected void printTransportMessage(TransportMessage tmsg)

logMessage

protected void logMessage(java.lang.String msg,
                          int logLevel)

logMessage

protected void logMessage(java.lang.String msg,
                          java.lang.Exception e,
                          int logLevel)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception