kaos.core.service.directory
Class KAoSAgentDirectoryServiceProxy

java.lang.Object
  extended by kaos.core.service.directory.KAoSAgentDirectoryServiceProxy
All Implemented Interfaces:
java.io.Serializable, KAoSObserver, DirectoryEventNotifier, KAoSOntologyQueryService, GuardSynchronization, OntologyInterfaces
Direct Known Subclasses:
CorbaAgentDirectoryServiceProxy, CougaarAgentDirectoryServiceProxy, GridAgentDirectoryServiceProxy, TCPAgentDirectoryServiceProxy

public abstract class KAoSAgentDirectoryServiceProxy
extends java.lang.Object
implements java.io.Serializable, OntologyInterfaces, KAoSOntologyQueryService, DirectoryEventNotifier, KAoSObserver, GuardSynchronization

See Also:
Serialized Form

Nested Class Summary
protected static class KAoSAgentDirectoryServiceProxy.OperationWaiter
          This class is used as a helper class to block Threads invoking the various Directory operations (register, deregister, modify, search).
 
Field Summary
protected  java.lang.String _directoryName
           
protected static Logger _logger
           
protected  Locator _myLocator
           
protected  java.lang.String _nickName
           
protected static java.lang.String _NICKNAME_ROOT
           
protected  Locator _remoteDirectoryLocator
           
protected  MessageSender _sender
           
protected  ServiceProperties _serviceProps
           
protected  java.util.Hashtable _waiters
           
static java.lang.String USE_COORDINATOR
           
 
Constructor Summary
KAoSAgentDirectoryServiceProxy()
           
KAoSAgentDirectoryServiceProxy(ServiceProperties serviceProps)
           
 
Method Summary
protected abstract  MessageTransportService acquireMessageTransportService()
           
protected abstract  Locator acquireRemoteDirectoryLocator()
          Return a Locator that will be used to communicate with the Domain Manager.
 void addEventListener(DirectoryEventListener listener)
          NOT IMPLEMENTED I don't think a DirectoryEventListener will necessarily be serializable See the other method, addRemoteEventListener
 void addRemoteEventListener(Locator l)
           
 java.lang.String analyzeWorkflow(java.lang.String owlsWorkflow)
          Modify the given OWL-S workflow based on policies that apply the actions in workflow.
 java.lang.String analyzeWorkflow(java.net.URL owlsWorkflow)
          Modify the given OWL-S workflow based on policies that apply the actions in workflow.
 java.util.Set askQuery(java.lang.String variableName, java.lang.String multiplyVariablesQuery)
          Get values of the selected variable satisfing the KIF query with possibly many variable.
protected  Locator bindToMessageTransportService(MessageTransportService mts)
          Private methods.
protected  java.lang.String callWorkflowMethod(java.lang.String methodName, java.util.Vector args)
          Remote invocation of a KAoSDirectoryService method.
 void checkPermission(java.security.Permission perm, java.lang.Object context)
          The method check if the given action is permitted according to the current set of policies
protected  void checkRegisterResult(MethodCallResultMsg result, AgentDescription desc)
           
 void cleanupVM()
          This is a call back from for the Runtime when the VM shutdown is in progress.
 AgentDescription createAgentDescription()
          Create a default KAoSAgentDescription.
protected  MethodCallRequestMsg createMessageToSend(AgentDescription adesc, java.lang.String requestedOperation, int parameterValue)
          Return an instance of the MethodCallRequestMsg specifying the requested Directory operation and the AgentDescription argument.
 void deregister(AgentDescription desc)
          Wrap the de-registration request into a TransportMessage to be sent to the Domain Manager to perform the actual de-registration with the following semantics: Remove the AgentDescription from the collection of domain entities registered in the directory.
 boolean equals(java.lang.Object obj)
           
 java.util.Set getActions(java.lang.String forActor)
          Get descriptions of the Action classes the specified Actor class or instance can perfom based on its class.
 KAoSAgentDescription getAgentDescriptionForAgentID(java.lang.String agentID)
          Search the directory containing agent descriptions for KAoSAgentDescription for the given agent ID.
 java.util.List getAllAgentsInDirectory()
          Get the descriptions of all the agents in the directory.
 java.util.Vector getAllAgentsInDomain(java.lang.String domainName)
          Get the descriptions of all the agents in the given domain
 java.util.List getAllGuardsInDirectory()
          Get the guard descriptions of all the guards in the directory.
 java.util.Set getClassesOfActors(java.lang.String baseActorClass)
          Get names of the Actors classes known to the ontology repository being a subclass of the specified base class.
 java.util.Set getClassesOfActorsCapableOfPerformingActions(java.lang.String actionClass)
          Get names of Actor classes capable to perform a given action, without taking into consideration policy restrictions
 java.util.Set getClassesOfGroups(java.lang.String baseGroupClass)
          Get names of the Group classes known to the ontology repository being a subclass of the specified base class.
 java.util.Set getClassesOfPlaces(java.lang.String basePlaceClass)
          Get names of the Places classes known to the ontology repository being a subclass of the specified base class.
 java.util.Set getClassesOfTargets(java.lang.String baseTargetClass)
          Get names of the targets (Actors or Entities) classes known to the ontology repository being a subclass of the specified base class.
 java.util.List getConstructedOntologyStructures()
          A method to get ontological definitions of all concepts stored in directory
 DomainDescription getDomainDescription(java.lang.String domainName)
          Get the description of a domain
 java.util.List getDomainDescriptionsForGuard(java.lang.String guardGUID)
          Partial implementation of kaos.domain.management.DomainDirectoryService interface implementation - begin
 java.util.Vector getDomainNames()
          Obtain a List of the names of all registered domains.
 java.util.Vector getGuardDescriptionsForEntity(java.lang.String entityID)
           
 java.lang.String getID()
          Return the unique identifier of this observer.
 java.util.Set getIndividualActors(java.lang.String baseActorClass)
          Get names of the individual Actors known to the ontology repository being an instance of the specified base class.
 java.util.Set getIndividualGroups(java.lang.String baseGroupClass)
          Get names of the individual Groups known to the ontology repository being an instance of the specified base class.
 java.util.Set getIndividualPlaces(java.lang.String basePlaceClass)
          Get names of the individual Places known to the ontology repository being an instance of the specified base class.
 java.util.Set getIndividualTargets(java.lang.String targetClass)
          kaos.ontology.management.KAoSOntologyQueryService interface implementation - begin
 java.util.Set getInstancesOf(java.lang.String conceptName)
          kaos.ontology.management.OntologyRepositoryService interface implementation - begin
 java.util.Set getOntologyDefinitionForConcept(java.lang.String conceptName)
          Curently it tries to match the concept name with the local name of the ontology definitions url
 java.util.List getPolicies()
           
 Msg getPolicy(java.lang.String policyId)
          kaos.policy.management.PolicyDirectory interface implementation - begin
 java.util.Vector getPropertiesApplicableTo(java.lang.String className)
          Get properties applicable to the given class
 java.lang.String getRangeOnPropertyForClass(java.lang.String className, java.lang.String propertyName)
          Get the name of the class defining the range of the specified property for the given class.
protected  MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
           
protected  MethodCallResultMsg getResult(MethodCallRequestMsg msgOut, java.lang.String operationName)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager.
 java.util.Vector getSchema(java.lang.String dataName)
          to retrieve the schema for the given data type.
 ServiceProperties getServiceProperties()
          javax.agent.service.Service interface implementation - begin
 java.util.Set getSubClassesOf(java.lang.String conceptName)
          Get set of subclasses of the given class.
 java.util.Vector getSubdomains(java.lang.String domainName)
          Obtain an Enumeration of the names of subdomains of a particular domain (returns immediate children only)
 java.util.Set getSubPropertiesOf(java.lang.String propertyName)
          Get set of subproperties of the given property.
 java.util.Set getSuperClassesOf(java.lang.String className)
          Get names of the superclasses of the given Action class.
 java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
          Get set of superproperties of the given property.
 java.util.Set getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
          Finds the ultimate Ontology type of the provided individual
 java.lang.String getUniqueValueForProperty(java.lang.String property, java.lang.String subject)
          Get a single value of the variable satisfing the KIF query: (property subject ?val).
 java.util.Set getValuesForProperty(java.lang.String property, java.lang.String subject)
          Get values of the variable satisfing the KIF query: (property subject ?val).
 int hashCode()
           
 boolean initialize(java.lang.String domainManagerName)
          Initialize variables and Message Transport Service infrastructure for sending/receiving messages.
 void instancesSetSynchronizationRequest(java.util.List myCurrentInstancesClassesURL, java.util.List myCurrentInstancesSetsTimeStamps)
          Send a list of the current classes for which instances set are stored in the Guard and associated with them timestamps in the second list.
 boolean isSynchronizationNeeded(java.lang.Long myLastUpdateTimeStamp)
          Check with DS if synchronization is needed by providing the timstamp of the last update.
 void loadOntology(SerializableOntModelImpl myDAMLModel, java.lang.Boolean recursiveLoad)
          Wrap the load ontology request into a TransportMessage to be sent to the Domain Manager to perform the loading of ontology with the following semantics: Adds ontology included in the provide objects into the ontology repository.
 void loadOntology(java.lang.String myURL, java.lang.Boolean recursiveLoad)
          Wrap the load ontology request into a TransportMessage to be sent to the Domain Manager to perform the loading of ontology with the following semantics: Adds ontology included in the provide objects into the ontology repository.
 void modify(AgentDescription desc)
          Wrap the modify request into a Grid message to be sent to the Domain Manager to perform the actual modify with the following semantics: Replace the AgentDescription in the collection of registered domain entities with the new AgentDescription.
 void modifyEntityProperties(java.lang.String entityGUID, java.util.List properties)
          Modify properties of the entity identified by the given entityGUID.
protected  JasBean obtainEntityEnv()
          Specify transport specific parameters that will be passed to the MessageTransportSystem.
 void policiesSynchronizationRequest(java.util.List myCurrentPoliciesIds, java.util.List myCurrentPoliciesTimeStamps)
          Send a list of the current policies ids and associated with them timestamps in the second list.
protected  void printDebugString(java.lang.String msg, int loggerDisplayLevel)
          A utility method to print a String.
 void receiveMessage(TransportMessage msg)
          Receive a TransportMessage message from the MessageReceiver.
 void register(AgentDescription desc)
          Wrap the registration request into a TransportMessage to be sent to the Domain Manager to perform the actual registration with the following semantics: Add the AgentDescription to the collection of domain entities registered in the directory.
protected  void registerForVMShutDown()
          Register as the shutdown hook with the runtime system.
 void removeEventListener(DirectoryEventListener listener)
          NOT IMPLEMENTED I don't think a DirectoryEventListener will necessarily be serializable See the other method, addRemoteEventListener
 void removePolicies(java.util.List policies)
           
 void removePolicy(Msg policy)
           
 void removeRemoteEventListener(Locator l)
           
protected  void removeWaiter(java.lang.String id)
           
 AgentDescription[] search(AgentDescription desc)
          Wrap the search request into a TransportMessage message to be sent to the Domain Manager to perform the actual search with the following semantics: Search the collection of AgentDescriptions for all matching descriptions.
 AgentDescription[] search(AgentDescription desc, int maxResults)
          Wrap the search request into a TransportMessage message to be sent to the Domain Manager to perform the actual search with the following semantics: Search the collection of AgentDescriptions for all matching descriptions.
 void sendDirectoryEvent(DirectoryEvent event)
           
 void setServiceProperties(ServiceProperties props)
           
 void subclassesSetSynchronizationRequest(java.util.List myCurrentSubclassesClassesURL, java.util.List myCurrentSubclassesSetsTimeStamps)
          Send a list of the current classes for which subclasses set are stored in the Guard and associated with them timestamps in the second list.
 void subpropertiesSetSynchronizationRequest(java.util.List myCurrentSubpropertiesPropertyURL, java.util.List myCurrentSubpropertiesSetsTimeStamps)
          Send a list of the current properties for which subproperties set are stored in the Guard and associated with them timestamps in the second list.
 void superclassesSetSynchronizationRequest(java.util.List myCurrentSuperclassesClassesURL, java.util.List myCurrentSuperclassesSetsTimeStamps)
          Send a list of the current classes for which superclasses set are stored in the Guard and associated with them timestamps in the second list.
 void superpropertiesSetSynchronizationRequest(java.util.List myCurrentSuperpropertiesPropertyURL, java.util.List myCurrentSuperpropertiesSetsTimeStamps)
          Send a list of the current properties for which superproperties set are stored in the Guard and associated with them timestamps in the second list.
 boolean testTrue(java.lang.String statement)
          Test if the KIF statemant is true according to the ontologies in the ontology repository.
 void update(java.lang.String observableID, java.lang.String updateType, java.lang.Object updateCondition, java.lang.Object update)
          Receive an update from the KAoSObservable when the KAoSObservable has a change or event to report.
 void updatePolicies(java.util.List addedPolicies, java.util.List changedPolicies, java.util.List removedPolicies)
           
protected  MethodCallResultMsg waitForReply(java.lang.String operationID, java.lang.String operationName)
          This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_COORDINATOR

public static final java.lang.String USE_COORDINATOR
See Also:
Constant Field Values

_NICKNAME_ROOT

protected static final java.lang.String _NICKNAME_ROOT
See Also:
Constant Field Values

_logger

protected static Logger _logger

_directoryName

protected java.lang.String _directoryName

_nickName

protected java.lang.String _nickName

_sender

protected MessageSender _sender

_myLocator

protected Locator _myLocator

_remoteDirectoryLocator

protected Locator _remoteDirectoryLocator

_waiters

protected java.util.Hashtable _waiters

_serviceProps

protected ServiceProperties _serviceProps
Constructor Detail

KAoSAgentDirectoryServiceProxy

public KAoSAgentDirectoryServiceProxy()

KAoSAgentDirectoryServiceProxy

public KAoSAgentDirectoryServiceProxy(ServiceProperties serviceProps)
Method Detail

getServiceProperties

public ServiceProperties getServiceProperties()
javax.agent.service.Service interface implementation - begin


setServiceProperties

public void setServiceProperties(ServiceProperties props)

createAgentDescription

public AgentDescription createAgentDescription()
Create a default KAoSAgentDescription.

Returns:
the default KAoSAgentDescriptionf.

register

public void register(AgentDescription desc)
              throws AlreadyRegisteredException,
                     DirectoryFailure
Wrap the registration request into a TransportMessage to be sent to the Domain Manager to perform the actual registration with the following semantics: Add the AgentDescription to the collection of domain entities registered in the directory.

Parameters:
desc - the AgentDescription to add.
Throws:
AlreadyRegisteredException - if the AgentDescription is already registered.
DirectoryFailure - if the directory service is not available.

deregister

public void deregister(AgentDescription desc)
                throws NotRegisteredException,
                       DirectoryFailure
Wrap the de-registration request into a TransportMessage to be sent to the Domain Manager to perform the actual de-registration with the following semantics: Remove the AgentDescription from the collection of domain entities registered in the directory.

Parameters:
desc - the AgentDescription to remove.
Throws:
NotRegisteredException - if the AgentDescription is not registered.
DirectoryFailure - if the directory service is not available.

modify

public void modify(AgentDescription desc)
            throws NotRegisteredException,
                   DirectoryFailure
Wrap the modify request into a Grid message to be sent to the Domain Manager to perform the actual modify with the following semantics: Replace the AgentDescription in the collection of registered domain entities with the new AgentDescription.

Parameters:
desc - the new AgentDescription to replace the old one.
Throws:
NotRegisteredException - if the AgentDescription is not registered.
DirectoryFailure - if the directory service is not available.

search

public AgentDescription[] search(AgentDescription desc)
                          throws SearchException,
                                 DirectoryFailure
Wrap the search request into a TransportMessage message to be sent to the Domain Manager to perform the actual search with the following semantics: Search the collection of AgentDescriptions for all matching descriptions. Return all results.

Parameters:
desc - the AgentDescription to use for matching.
Returns:
AgentDescription[] containing matching descriptions.
Throws:
SearchException - if an exception occurs during searching.
DirectoryFailure - if the directory service is unavailable.

search

public AgentDescription[] search(AgentDescription desc,
                                 int maxResults)
                          throws SearchException,
                                 DirectoryFailure
Wrap the search request into a TransportMessage message to be sent to the Domain Manager to perform the actual search with the following semantics: Search the collection of AgentDescriptions for all matching descriptions. Match on agent name, if agent name is null, then use agent nickname. Limit the returned results to the specified number.

Parameters:
desc - the AgentDescription to use for matching.
maxResults - the limit of returned results.
Returns:
AgentDescription[] containing the specified number, or less, of matching descriptions.
Throws:
SearchException - if an exception occurs during searching.
DirectoryFailure - if the directory service is not available.

modifyEntityProperties

public void modifyEntityProperties(java.lang.String entityGUID,
                                   java.util.List properties)
                            throws DirectoryFailure,
                                   NotRegisteredException,
                                   ModificationException
Modify properties of the entity identified by the given entityGUID.

Parameters:
entityGUID - String containing the entity GUID.
properties - List of Properties to be modified. Each Property contains the name, value, value description, modification type (add/remove/set, etc), modification result. Refer to the Property and ModificationResult interfaces for detailed description.
Throws:
DirectoryFailure - if the connection to the DS cannot be established.
NotRegisteredException - if the entity whose properties are to be modified has not been registered in the DS.
ModificationException - if one or more property update failed.

receiveMessage

public void receiveMessage(TransportMessage msg)
Receive a TransportMessage message from the MessageReceiver. Unwrap the TransportMessage to get the MethodCallResultMsg from the DomainManager. Notify the correct waiter object, blocking a Thread that invoked the Directory operation, whose results were just received in this receiveMessage call. Based on the result, the notification will unblock the waiting Thread, which will either deliver the DomainManager's reply to the correct invoker, or throw an exception, if the the DomainManager threw one as a reply.

Parameters:
msg - the TransportMessage containing DomainManager's reply to one of: register/deregister/modify/search/removeExecEnv requests.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

checkPermission

public void checkPermission(java.security.Permission perm,
                            java.lang.Object context)
                     throws KAoSSecurityException,
                            java.lang.NullPointerException,
                            DirectoryFailure
The method check if the given action is permitted according to the current set of policies

Parameters:
perm - Permission to be checked by the Guard in order to allow/disallow an action.
context - An Object describing the context of the action.
Throws:
KAoSSecurityException - if the action is not allowed.
java.lang.NullPointerException - if the Permission argument is null.
DirectoryFailure

getDomainDescriptionsForGuard

public java.util.List getDomainDescriptionsForGuard(java.lang.String guardGUID)
Partial implementation of kaos.domain.management.DomainDirectoryService interface implementation - begin


getDomainNames

public java.util.Vector getDomainNames()
Obtain a List of the names of all registered domains.

Returns:
Vector of Strings of the names of domains.

getAllAgentsInDomain

public java.util.Vector getAllAgentsInDomain(java.lang.String domainName)
Get the descriptions of all the agents in the given domain

Returns:
Vector of AgentDescriptions of all agents in the domain.

getAllAgentsInDirectory

public java.util.List getAllAgentsInDirectory()
                                       throws DirectoryFailure
Get the descriptions of all the agents in the directory.

Returns:
List of AgentDescriptions of all agents in the directory.
Throws:
DirectoryFailure

getAllGuardsInDirectory

public java.util.List getAllGuardsInDirectory()
                                       throws DirectoryFailure
Get the guard descriptions of all the guards in the directory.

Returns:
List of GuardDescriptions of all guards in the directory.
Throws:
DirectoryFailure

getGuardDescriptionsForEntity

public java.util.Vector getGuardDescriptionsForEntity(java.lang.String entityID)

getDomainDescription

public DomainDescription getDomainDescription(java.lang.String domainName)
Get the description of a domain

Parameters:
domainName - the name of the domain

getSubdomains

public java.util.Vector getSubdomains(java.lang.String domainName)
Obtain an Enumeration of the names of subdomains of a particular domain (returns immediate children only)

Returns:
Enumeration of Strings of the names of domains

getInstancesOf

public java.util.Set getInstancesOf(java.lang.String conceptName)
                             throws UnknownConceptException,
                                    DirectoryFailure
kaos.ontology.management.OntologyRepositoryService interface implementation - begin

Specified by:
getInstancesOf in interface OntologyInterfaces
Parameters:
conceptName - The name of the concept in the Jena format
Returns:
Set of instance ids in the Jena format
Throws:
UnknownConceptException
DirectoryFailure

getSubClassesOf

public java.util.Set getSubClassesOf(java.lang.String conceptName)
                              throws UnknownConceptException,
                                     DirectoryFailure
Description copied from interface: OntologyInterfaces
Get set of subclasses of the given class.

Specified by:
getSubClassesOf in interface OntologyInterfaces
Parameters:
conceptName - The name of the class in Jena format
Returns:
Set of subclasses names in Jena format
Throws:
UnknownConceptException
DirectoryFailure

getSuperPropertiesOf

public java.util.Set getSuperPropertiesOf(java.lang.String propertyName)
                                   throws UnknownConceptException,
                                          DirectoryFailure
Get set of superproperties of the given property.

Specified by:
getSuperPropertiesOf in interface OntologyInterfaces
Parameters:
propertyName - The name of the property in Jena format
Returns:
Set of superproperties names in Jena format
Throws:
java.lang.Exception - if propertyName is unknow for the ontology repository
UnknownConceptException
DirectoryFailure

getSubPropertiesOf

public java.util.Set getSubPropertiesOf(java.lang.String propertyName)
                                 throws UnknownConceptException,
                                        DirectoryFailure
Get set of subproperties of the given property.

Specified by:
getSubPropertiesOf in interface OntologyInterfaces
Parameters:
propertyName - The name of the property in Jena format
Returns:
Set of subproperties names in Jena format
Throws:
java.lang.Exception - if propertyName is unknow for the ontology repository
UnknownConceptException
DirectoryFailure

getUniqueValueForProperty

public java.lang.String getUniqueValueForProperty(java.lang.String property,
                                                  java.lang.String subject)
                                           throws ReasoningException,
                                                  DirectoryFailure
Get a single value of the variable satisfing the KIF query: (property subject ?val).

Parameters:
property - the name of the property in the Jena format
subject - the name of the subject in the Jena format
Returns:
a single value (as string in the Jena format) for the property on this subject
Throws:
ReasoningException - if reasoning failed.
DirectoryFailure

testTrue

public boolean testTrue(java.lang.String statement)
                 throws QueryFailure,
                        DirectoryFailure
Test if the KIF statemant is true according to the ontologies in the ontology repository.

Specified by:
testTrue in interface OntologyInterfaces
Parameters:
statement - the statement in KIF to be tested if true
Returns:
true if the statement is true and false in the opposite case
Throws:
QueryFailure - if reasoning failed.
DirectoryFailure

askQuery

public java.util.Set askQuery(java.lang.String variableName,
                              java.lang.String multiplyVariablesQuery)
                       throws DirectoryFailure,
                              QueryFailure
Get values of the selected variable satisfing the KIF query with possibly many variable.

Parameters:
variableName - the name of the selected variable
multiplyVariablesQuery - the query
Returns:
a set with values satisfing the query
Throws:
DirectoryFailure - if the connection to the DS cannot be established
QueryFailure - if query failed.

getValuesForProperty

public java.util.Set getValuesForProperty(java.lang.String property,
                                          java.lang.String subject)
                                   throws DirectoryFailure,
                                          QueryFailure
Get values of the variable satisfing the KIF query: (property subject ?val).

Parameters:
property - the name of the property
subject - the name of the subject
Returns:
a set with values for the property on this subject
Throws:
DirectoryFailure - if the connection to the DS cannot be established
QueryFailure - if query failed

getUltimateOntologyTypesOfIndividual

public java.util.Set getUltimateOntologyTypesOfIndividual(java.lang.String individualName)
                                                   throws DirectoryFailure,
                                                          UnknownConceptException
Finds the ultimate Ontology type of the provided individual

Parameters:
individualName - the name of the individual
Returns:
the set of names of the Ontology classes being the most narrow ones for the given individual
Throws:
individualName - if concept unknow or any problem with JTP approached
DirectoryFailure
UnknownConceptException

getPropertiesApplicableTo

public java.util.Vector getPropertiesApplicableTo(java.lang.String className)
                                           throws UnknownConceptException,
                                                  QueryFailure,
                                                  DirectoryFailure
Get properties applicable to the given class

Specified by:
getPropertiesApplicableTo in interface OntologyInterfaces
Parameters:
className - the name of the class
Returns:
vector of properties names
Throws:
QueryFailure - if reasoning failed.
UnknownConceptException
DirectoryFailure

getRangeOnPropertyForClass

public java.lang.String getRangeOnPropertyForClass(java.lang.String className,
                                                   java.lang.String propertyName)
                                            throws QueryFailure,
                                                   UnknownConceptException,
                                                   DirectoryFailure
Get the name of the class defining the range of the specified property for the given class.

Specified by:
getRangeOnPropertyForClass in interface OntologyInterfaces
Parameters:
className - the name of the class
propertyName - the name of the property
Returns:
the name of the class defining the range
Throws:
java.lang.Exception - if reasoning failed.
QueryFailure
UnknownConceptException
DirectoryFailure

analyzeWorkflow

public java.lang.String analyzeWorkflow(java.lang.String owlsWorkflow)
                                 throws DirectoryFailure,
                                        ReasoningException
Modify the given OWL-S workflow based on policies that apply the actions in workflow. Only works if the owls libraries are present, otherwise null is returned.

Parameters:
owlsWorkflow - - the OWL-S workflow to analyze/modify (xml text)
Returns:
- the OWL-S workflow (xml text) with policy information added (e.g. obliged actions inserted as processes)
Throws:
java.lang.Exception
DirectoryFailure
ReasoningException

analyzeWorkflow

public java.lang.String analyzeWorkflow(java.net.URL owlsWorkflow)
                                 throws DirectoryFailure,
                                        ReasoningException
Modify the given OWL-S workflow based on policies that apply the actions in workflow. Only works if the owls libraries are present, otherwise null is returned.

Parameters:
owlsWorkflow - - URL to an existing OWL-S workflow to analyze/modify
Returns:
- the OWL-S workflow (xml text) with policy information added (e.g. obliged actions inserted as processes)
Throws:
java.lang.Exception
DirectoryFailure
ReasoningException

callWorkflowMethod

protected java.lang.String callWorkflowMethod(java.lang.String methodName,
                                              java.util.Vector args)
                                       throws DirectoryFailure,
                                              ReasoningException
Remote invocation of a KAoSDirectoryService method.

Parameters:
methodName -
args -
Returns:
- String result of method invocation on the directory service
Throws:
DirectoryFailure
ReasoningException

getOntologyDefinitionForConcept

public java.util.Set getOntologyDefinitionForConcept(java.lang.String conceptName)
                                              throws DirectoryFailure
Curently it tries to match the concept name with the local name of the ontology definitions url

Specified by:
getOntologyDefinitionForConcept in interface OntologyInterfaces
Parameters:
conceptName - The name of the namespace in the Jena format
Returns:
Set of ontology definition url potentially matching the search concept
Throws:
DirectoryFailure

getConstructedOntologyStructures

public java.util.List getConstructedOntologyStructures()
                                                throws DirectoryFailure
A method to get ontological definitions of all concepts stored in directory

Returns:
A list of SerializableOnt models of the concepts.
Throws:
DirectoryFailure

getSchema

public java.util.Vector getSchema(java.lang.String dataName)
                           throws DirectoryFailure
to retrieve the schema for the given data type. please note that a derived data type can have as its parent a data type which is also dervied from some other data type. hence the method returns a vector, containing schema definitions for all such data types in the hierarchy.

Specified by:
getSchema in interface OntologyInterfaces
Parameters:
dataName - the name of the data type to be retrieved
Returns:
a vector containing all the data type definitions in the chain of inheritance.
Throws:
DirectoryFailure

getIndividualTargets

public java.util.Set getIndividualTargets(java.lang.String targetClass)
                                   throws UnknownConceptException,
                                          DirectoryFailure
kaos.ontology.management.KAoSOntologyQueryService interface implementation - begin

Specified by:
getIndividualTargets in interface KAoSOntologyQueryService
Parameters:
targetClass - The name of the targets (Actor or Entity) class which the return classes have to be a subclass of
Returns:
Set of names of individual targets (Actors or Entities)
Throws:
UnknownConceptException - if baseTargetClass is unknow for the ontology repository
DirectoryFailure

getActions

public java.util.Set getActions(java.lang.String forActor)
                         throws UnknownConceptException,
                                DirectoryFailure
Get descriptions of the Action classes the specified Actor class or instance can perfom based on its class.

Specified by:
getActions in interface KAoSOntologyQueryService
Parameters:
forActor - The name of the Actor class or instance
Returns:
Set of ActionDescription(s)
Throws:
UnknownConceptException - if forActor is unknown by the ontology repository
DirectoryFailure

getClassesOfActorsCapableOfPerformingActions

public java.util.Set getClassesOfActorsCapableOfPerformingActions(java.lang.String actionClass)
                                                           throws UnknownConceptException,
                                                                  DirectoryFailure
Get names of Actor classes capable to perform a given action, without taking into consideration policy restrictions

Specified by:
getClassesOfActorsCapableOfPerformingActions in interface KAoSOntologyQueryService
Parameters:
actionClass - The name of the Action class
Returns:
Set of Strings containg names of Actor classes
Throws:
UnknownConceptException - if actionClass is unknow for the ontology repository
DirectoryFailure

getSuperClassesOf

public java.util.Set getSuperClassesOf(java.lang.String className)
                                throws UnknownConceptException,
                                       DirectoryFailure
Get names of the superclasses of the given Action class.

Parameters:
className - The name of the Action class, whose superclasses are requested.
Returns:
Set of names of the superclasses of the given class.
Throws:
UnknownConceptException - if className is unknown by the ontology repository.
DirectoryFailure

getIndividualActors

public java.util.Set getIndividualActors(java.lang.String baseActorClass)
                                  throws UnknownConceptException,
                                         DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the individual Actors known to the ontology repository being an instance of the specified base class.

Specified by:
getIndividualActors in interface KAoSOntologyQueryService
Parameters:
baseActorClass - The name of the Actor class which the return elements have to be an instance of If the name is empty uses Actor as a base class
Returns:
Set of names of individual Actors
Throws:
UnknownConceptException - if baseActorClass is unknow for the ontology repository
DirectoryFailure

getClassesOfActors

public java.util.Set getClassesOfActors(java.lang.String baseActorClass)
                                 throws UnknownConceptException,
                                        DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the Actors classes known to the ontology repository being a subclass of the specified base class.

Specified by:
getClassesOfActors in interface KAoSOntologyQueryService
Parameters:
baseActorClass - The name of the Actor class which the return classes have to be a subclass of If the name is empty uses Actor as a base class
Returns:
Set of names of Actor subclasses
Throws:
UnknownConceptException - if baseActorClass is unknow for the ontology repository
DirectoryFailure

getIndividualPlaces

public java.util.Set getIndividualPlaces(java.lang.String basePlaceClass)
                                  throws UnknownConceptException,
                                         DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the individual Places known to the ontology repository being an instance of the specified base class.

Specified by:
getIndividualPlaces in interface KAoSOntologyQueryService
Parameters:
basePlaceClass - The name of the Place class which the return elements have to be an instance of If the name is empty uses Place as a base class
Returns:
Set of names of individual Places
Throws:
UnknownConceptException - if basePlaceClass is unknow for the ontology repository
DirectoryFailure

getClassesOfPlaces

public java.util.Set getClassesOfPlaces(java.lang.String basePlaceClass)
                                 throws UnknownConceptException,
                                        DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the Places classes known to the ontology repository being a subclass of the specified base class.

Specified by:
getClassesOfPlaces in interface KAoSOntologyQueryService
Parameters:
basePlaceClass - The name of the Place class which the return classes have to be a subclass of If the name is empty uses Place as a base class
Returns:
Set of names of Place subclasses
Throws:
UnknownConceptException - if basePlaceClass is unknow for the ontology repository
DirectoryFailure

getIndividualGroups

public java.util.Set getIndividualGroups(java.lang.String baseGroupClass)
                                  throws UnknownConceptException,
                                         DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the individual Groups known to the ontology repository being an instance of the specified base class.

Specified by:
getIndividualGroups in interface KAoSOntologyQueryService
Parameters:
baseGroupClass - The name of the Group class which the return elements have to be an instance of If the name is empty uses Group as a base class
Returns:
Set of names of individual Groups
Throws:
UnknownConceptException - if baseGroupClass is unknow for the ontology repository
DirectoryFailure

getClassesOfGroups

public java.util.Set getClassesOfGroups(java.lang.String baseGroupClass)
                                 throws UnknownConceptException,
                                        DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the Group classes known to the ontology repository being a subclass of the specified base class.

Specified by:
getClassesOfGroups in interface KAoSOntologyQueryService
Parameters:
baseGroupClass - The name of the Group class which the return elements have to be an instance of If the name is empty uses Group as a base class
Returns:
Set of names of individual Groups
Throws:
UnknownConceptException - if baseGroupClass is unknow for the ontology repository
DirectoryFailure

getClassesOfTargets

public java.util.Set getClassesOfTargets(java.lang.String baseTargetClass)
                                  throws UnknownConceptException,
                                         DirectoryFailure
Description copied from interface: KAoSOntologyQueryService
Get names of the targets (Actors or Entities) classes known to the ontology repository being a subclass of the specified base class.

Specified by:
getClassesOfTargets in interface KAoSOntologyQueryService
Parameters:
baseTargetClass - The name of the targets (Actor or Entity) class which the return classes have to be a subclass of
Returns:
Set of names of targets (Actors or Entities) subclasses
Throws:
UnknownConceptException - if baseTargetClass is unknow for the ontology repository
DirectoryFailure

loadOntology

public void loadOntology(SerializableOntModelImpl myDAMLModel,
                         java.lang.Boolean recursiveLoad)
                  throws ReasoningException,
                         java.io.IOException,
                         DirectoryFailure
Wrap the load ontology request into a TransportMessage to be sent to the Domain Manager to perform the loading of ontology with the following semantics: Adds ontology included in the provide objects into the ontology repository.

Parameters:
myDAMLModel - The object of type com.hp.hpl.jena.daml.DAMLModel (actually SerializableOntModelImpl) containing the added ontology
recursiveLoad - Indicates if the imported ontologies (by the ontology contained in myDAMLModel) should also be recursively loaded.
Throws:
jtp.InconsistencyException - when loading of the ontology failed.
ReasoningException
java.io.IOException
DirectoryFailure

loadOntology

public void loadOntology(java.lang.String myURL,
                         java.lang.Boolean recursiveLoad)
                  throws ReasoningException,
                         java.io.IOException,
                         DirectoryFailure
Wrap the load ontology request into a TransportMessage to be sent to the Domain Manager to perform the loading of ontology with the following semantics: Adds ontology included in the provide objects into the ontology repository. Loads ontology from the provided url.

Parameters:
myURL - The url to the ontology
recursiveLoad - Indicates if the imported ontologies (by the ontology depicted by myURL) should also be recursively loaded.
Throws:
jtp.InconsistencyException - when loading of the ontology failed.
ReasoningException
java.io.IOException
DirectoryFailure

getPolicy

public Msg getPolicy(java.lang.String policyId)
              throws java.lang.Exception
kaos.policy.management.PolicyDirectory interface implementation - begin

Throws:
java.lang.Exception

getPolicies

public java.util.List getPolicies()
                           throws java.lang.Exception
Throws:
java.lang.Exception

removePolicies

public void removePolicies(java.util.List policies)
                    throws java.lang.Exception
Throws:
java.lang.Exception

removePolicy

public void removePolicy(Msg policy)
                  throws java.lang.Exception
Throws:
java.lang.Exception

updatePolicies

public void updatePolicies(java.util.List addedPolicies,
                           java.util.List changedPolicies,
                           java.util.List removedPolicies)
                    throws java.lang.Exception
Throws:
java.lang.Exception

policiesSynchronizationRequest

public void policiesSynchronizationRequest(java.util.List myCurrentPoliciesIds,
                                           java.util.List myCurrentPoliciesTimeStamps)
                                    throws DirectoryFailure
Send a list of the current policies ids and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
policiesSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentPoliciesIds - The List of the current policies ids.
myCurrentPoliciesTimeStamps - The List of the current policies timestamps.
Throws:
DirectoryFailure

instancesSetSynchronizationRequest

public void instancesSetSynchronizationRequest(java.util.List myCurrentInstancesClassesURL,
                                               java.util.List myCurrentInstancesSetsTimeStamps)
                                        throws DirectoryFailure
Send a list of the current classes for which instances set are stored in the Guard and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
instancesSetSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentInstancesClassesURL - The List of the current classes for which instances set are stored in the Guard identified by URLs.
myCurrentInstancesSetsTimeStamps - The List of the current intances set timestamps.
Throws:
DirectoryFailure

subclassesSetSynchronizationRequest

public void subclassesSetSynchronizationRequest(java.util.List myCurrentSubclassesClassesURL,
                                                java.util.List myCurrentSubclassesSetsTimeStamps)
                                         throws DirectoryFailure
Send a list of the current classes for which subclasses set are stored in the Guard and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
subclassesSetSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentSubclassesClassesURL - The List of the current classes for which subclasses set are stored in the Guard identified by URLs.
myCurrentSubclassesSetsTimeStamps - The List of the current subclasses set timestamps.
Throws:
DirectoryFailure

superclassesSetSynchronizationRequest

public void superclassesSetSynchronizationRequest(java.util.List myCurrentSuperclassesClassesURL,
                                                  java.util.List myCurrentSuperclassesSetsTimeStamps)
                                           throws DirectoryFailure
Send a list of the current classes for which superclasses set are stored in the Guard and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
superclassesSetSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentSuperclassesClassesURL - The List of the current classes for which superclasses set are stored in the Guard identified by URLs.
myCurrentSuperclassesSetsTimeStamps - The List of the current superclasses set timestamps.
Throws:
DirectoryFailure

subpropertiesSetSynchronizationRequest

public void subpropertiesSetSynchronizationRequest(java.util.List myCurrentSubpropertiesPropertyURL,
                                                   java.util.List myCurrentSubpropertiesSetsTimeStamps)
                                            throws DirectoryFailure
Send a list of the current properties for which subproperties set are stored in the Guard and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
subpropertiesSetSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentSubpropertiesPropertyURL - The List of the current properties for which subproperties set are stored in the Guard identified by URLs.
myCurrentSubpropertiesSetsTimeStamps - The List of the current subproperties set timestamps.
Throws:
DirectoryFailure

superpropertiesSetSynchronizationRequest

public void superpropertiesSetSynchronizationRequest(java.util.List myCurrentSuperpropertiesPropertyURL,
                                                     java.util.List myCurrentSuperpropertiesSetsTimeStamps)
                                              throws DirectoryFailure
Send a list of the current properties for which superproperties set are stored in the Guard and associated with them timestamps in the second list. This should allow DS to determine if an update is needed.

Specified by:
superpropertiesSetSynchronizationRequest in interface GuardSynchronization
Parameters:
myCurrentSuperpropertiesPropertyURL - The List of the current properties for which superproperties set are stored in the Guard identified by URLs.
myCurrentSuperpropertiesSetsTimeStamps - The List of the current superproperties set timestamps.
Throws:
DirectoryFailure

isSynchronizationNeeded

public boolean isSynchronizationNeeded(java.lang.Long myLastUpdateTimeStamp)
                                throws DirectoryFailure
Check with DS if synchronization is needed by providing the timstamp of the last update.

Specified by:
isSynchronizationNeeded in interface GuardSynchronization
Parameters:
myLastUpdateTimeStamp - The timestamp of the last update
Throws:
DirectoryFailure

getAgentDescriptionForAgentID

public KAoSAgentDescription getAgentDescriptionForAgentID(java.lang.String agentID)
                                                   throws SearchException,
                                                          DirectoryFailure
Search the directory containing agent descriptions for KAoSAgentDescription for the given agent ID.

Parameters:
agentID - String containing the unique ID of the agent to search for.
Returns:
KAoSAgentDescription the description matching given agentID, or null, if description not found.
Throws:
SearchException - if an exception is thrown during the search.
DirectoryFailure - if the directory cannot be found/is not available.

addEventListener

public void addEventListener(DirectoryEventListener listener)
                      throws DirectoryFailure
NOT IMPLEMENTED I don't think a DirectoryEventListener will necessarily be serializable See the other method, addRemoteEventListener

Specified by:
addEventListener in interface DirectoryEventNotifier
Throws:
DirectoryFailure

removeEventListener

public void removeEventListener(DirectoryEventListener listener)
                         throws DirectoryFailure
NOT IMPLEMENTED I don't think a DirectoryEventListener will necessarily be serializable See the other method, addRemoteEventListener

Specified by:
removeEventListener in interface DirectoryEventNotifier
Throws:
DirectoryFailure

addRemoteEventListener

public void addRemoteEventListener(Locator l)
                            throws DirectoryFailure
Specified by:
addRemoteEventListener in interface DirectoryEventNotifier
Throws:
DirectoryFailure

removeRemoteEventListener

public void removeRemoteEventListener(Locator l)
                               throws DirectoryFailure
Specified by:
removeRemoteEventListener in interface DirectoryEventNotifier
Throws:
DirectoryFailure

sendDirectoryEvent

public void sendDirectoryEvent(DirectoryEvent event)
                        throws DirectoryFailure
Throws:
DirectoryFailure

initialize

public boolean initialize(java.lang.String domainManagerName)
Initialize variables and Message Transport Service infrastructure for sending/receiving messages. Register this KAoSAgentDirectoryServiceProxy with the VM shutdown mechanism, so in the event of VM shut down all registered entities and execution environments (this VM and containers) will be unregistered from the domain.

Parameters:
domainManagerName - the name of the DomainManager this Directory will be a proxy of.

update

public void update(java.lang.String observableID,
                   java.lang.String updateType,
                   java.lang.Object updateCondition,
                   java.lang.Object update)
            throws NotificationException
Receive an update from the KAoSObservable when the KAoSObservable has a change or event to report.

Specified by:
update in interface KAoSObserver
Parameters:
observableID - String identifying the KAoSObservable sending the update.
updateType - String indicating type of update.
update - Object containing the update.
Throws:
NotificationException

getID

public java.lang.String getID()
Return the unique identifier of this observer.

Specified by:
getID in interface KAoSObserver
Returns:
String containing the unique ID of this observer.

cleanupVM

public void cleanupVM()
This is a call back from for the Runtime when the VM shutdown is in progress. Before the VM terminates, all registered entities and the VM/containers should be deregistered from the Domain Manager's registry.


acquireRemoteDirectoryLocator

protected abstract Locator acquireRemoteDirectoryLocator()
Return a Locator that will be used to communicate with the Domain Manager. The Locator must be supported by DomainManager's platform and this KAoSAgentDirectoryServiceProxy platform. Since the instance of the created Locator will contain transport-specific params, this method must be implemented by a subclass.


acquireMessageTransportService

protected abstract MessageTransportService acquireMessageTransportService()

obtainEntityEnv

protected JasBean obtainEntityEnv()
Specify transport specific parameters that will be passed to the MessageTransportSystem.


registerForVMShutDown

protected void registerForVMShutDown()
Register as the shutdown hook with the runtime system. Just before the VM exits, deregister all agents still running in this VM and the VM itself from the domain directory.


bindToMessageTransportService

protected Locator bindToMessageTransportService(MessageTransportService mts)
                                         throws java.lang.Exception
Private methods. /****************************************************************************************** /** Obtain transport specific parameters, if any, obtain the Locator and MessageReceiver for this KAoSAgentDirectoryServiceProxy, and bind the Locator to the MessageReceiver.

Throws:
java.lang.Exception

createMessageToSend

protected MethodCallRequestMsg createMessageToSend(AgentDescription adesc,
                                                   java.lang.String requestedOperation,
                                                   int parameterValue)
Return an instance of the MethodCallRequestMsg specifying the requested Directory operation and the AgentDescription argument.


getResult

protected MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
                                 throws DirectoryFailure
Throws:
DirectoryFailure

getResult

protected MethodCallResultMsg getResult(MethodCallRequestMsg msgOut,
                                        java.lang.String operationName)
                                 throws DirectoryFailure
Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager. Create an OperationWaiter object and store it in the _waiters hashtable. This object is associated with the current MethodCallRequestMsg and it will store the MethodCallResultsMsg, when the result arrives. After sending the TransportMessage, wait for the result.

Throws:
DirectoryFailure

waitForReply

protected MethodCallResultMsg waitForReply(java.lang.String operationID,
                                           java.lang.String operationName)
                                    throws DirectoryFailure
This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM. If the result comes back even before this method is invoked (like in CORBA sometimes), then retrieve the result from the corrensponding OperationWaiter object and return the result. If this method is invoked before the result comes back, block the current Thread and wait for the result. Waiting is accomplished using the OperationWaiter object, which is associated with this request and invoking the wait() method on it. After the result is received and this waiting Thread is unblocked (in doNotify() method of the OperationWaiter), the result is returned to the agent.

Throws:
DirectoryFailure

checkRegisterResult

protected void checkRegisterResult(MethodCallResultMsg result,
                                   AgentDescription desc)
                            throws AlreadyRegisteredException,
                                   DirectoryFailure
Throws:
AlreadyRegisteredException
DirectoryFailure

removeWaiter

protected void removeWaiter(java.lang.String id)

printDebugString

protected void printDebugString(java.lang.String msg,
                                int loggerDisplayLevel)
A utility method to print a String. Add the name of the class printing the String.

Parameters:
msg - The String to be printed.