public class DataService extends Service implements DataServiceDef
Service
implementation that includes basic data and evaluation handling.
Storing and evaluating data objects is likely to be useful for a lot of services. Data is at
a lower level than information and so the InformationService
is a super class of this one,
but all services from Service
up use the same resources to store and return the data values.
This class also accepts a data generator and can create the data module later from it.
infoXmlDH
method to link any derived service with a DataHub
, or the
infoXmlBM
method to link any derived service with a BehaviourMediator
, for example.Modifier and Type | Field and Description |
---|---|
protected org.ai_heuristic.def.EvaluateMathDef |
dataCompare
Default math evaluator, of basic java types
|
protected MethodInfo |
dataMethod
Single operator method to invoke
|
protected java.lang.Object |
resultObj
The result object is typically an evaluation over the data
|
canAccessMeta, canAccessNested, dm, finalised, isRemoteCall, messageStore, serviceAdmin, serviceGrade, serviceInitialise, serviceLinks, serviceState, sm, toLoadScript
shutDown
passwordHandler, service, serviceType
jarFile, syncOn, uuid
Constructor and Description |
---|
DataService()
Creates a new instance of DataService.
|
DataService(java.lang.String thisPassword,
java.lang.String thisAdminKey)
Creates a new instance of DataService.
|
DataService(java.lang.String thisPassword,
java.lang.String thisAdminKey,
org.licas_xml.abs.Element adminXml)
Creates a new instance of DataService.
|
Modifier and Type | Method and Description |
---|---|
protected EvaluateData |
createEvaluateData(DataQueryModel dataQueryModel)
Create the data evaluator based on the input specification.
|
EvaluateData |
createEvaluateData(DataQueryModel dataQueryModel,
java.lang.String adminKey)
Create the data evaluator based on the input specification.
|
protected boolean |
dataTypeOK(java.lang.String dataType)
Return true if the input data type is OK with the current service type.
|
protected void |
dataXmlBM(org.licas_xml.abs.Element dataXml,
org.licas_xml.abs.Element otherXml,
boolean links)
This is the implementation used to send the current data result to a behaviour
mediator if one is running.
|
void |
dataXmlBM(java.lang.String adminKey)
This is used to send the current data and result to a behaviour mediator if one is running.
|
protected void |
dataXmlDH(org.licas_xml.abs.Element dataXml,
org.licas_xml.abs.Element otherXml)
This is used to send the current data result to a data hub if one is running.
|
void |
dataXmlDH(java.lang.String adminKey)
This is used to send the current data result to a data hub if one is running.
|
org.licas_xml.abs.Element |
evaluate(DataQueryModel dataQueryModel)
Evaluate the data.
|
java.lang.Object |
getData()
Get the whole data value.
|
java.lang.Object |
getData(org.licas_xml.abs.Element infoDescr)
Get the data value only, based on some condition.
|
java.lang.String |
getDataType()
Get the data type.
|
protected java.lang.Object |
getInstanceValue(java.lang.String varName)
Get the value of the specified variable if it exists.
|
java.lang.Object |
getResultObj()
Get the result object value.
|
void |
resetValues()
Reset values for the next run, empty here.
|
protected void |
setData(DataQueryModel dataQueryModel)
Set the value for the local
DataModule dataset, from the query parameters. |
boolean |
setData(java.lang.String dataType,
java.lang.Object dataObj,
java.lang.String adminKey)
Set the value that this service will use as its data source.
|
protected void |
setFixedDataValue()
If a data generator has been loaded, use it to set a single fixed
data value for this service.
|
void |
setGenData(java.lang.String adminKey)
Set the random data value, created using the installed data generator.
|
protected void |
setInstanceValues(org.licas_xml.abs.Element instanceValues)
Set actual values for variable instances if they are defined.
|
void |
setResultObj(java.lang.Object thisObj)
Set the result value, which is usually an evaluation over the data source.
|
protected void |
setSerializeValues(org.licas_xml.abs.Element serializeXml)
Set actual values for serialized variable instances if they are defined.
|
addCommunicationID, addDefaultService, addDefaultService, addDefaultService, addDefaultService, addLinkFromService, addLinkToService, addMessageMetrics, addService, addService, addService, addService, addServiceAssociation, addServicePassword, addTempPassword, allowAddService, canAccess, canAccess, canAccess, canAccess, canAccessMeta, canAccessNested, canAccessTemp, canRun, classNameOK, clearServiceLinks, clearServices, clearServices, close, createMetaForRepos, createMetaFull, createPermanentLinkTo, createServiceWrapper, defaultAdminToRemove, dynamicLinkQuery, dynamicLinksToPermanent, dynamicLinksToXml, dynamicLinksToXml, execute, finaliseInitialisation, finaliseInitialisation, finaliseModule, finaliseThisConfig, GET, getAllLinkToService, getAllowAddService, getAutonomicManagerConfig, getCommunicationClientURI, getDescription, getFullPath, getIsRemoteCall, getLinkFromService, getLinkToService, getLocalRemoteID, getParent, getParent, getPassword, getPassword, getPassword, getPasswordHandler, getPrivateMethods, getPublicMethods, getPublicServiceClassname, getServerPassword, getService, getService, getServiceAdmin, getServiceClasses, getServiceGrade, getServiceLinks, getServiceNames, getServiceNames, getServiceNames, getServiceNumber, getServiceOrWrapper, getServiceState, getServiceType, getServiceTypes, handshake, hasCommunicationID, hasLinkTo, hasServerPassword, hasService, hasServiceType, interrupt, isCorrectPassword, isPrivateMethod, isPublicMethod, isStarted, linksToXml, passwordsStateToXml, permanentLinksToXml, reflectionMethods, reflectionObject, removeAllLinksTo, removeAllServices, removeAllServices, removeCommunicationID, removeLinkFromService, removeLinkToService, removePermanentLinkTo, removeServiceAssociation, removeServiceID, removeServicePath, removeServicePath, removeTempPassword, serviceNegotiate, serviceToXml, serviceToXml, setAdminInfo, setCanAccessMeta, setCanAccessNested, setData, setDataModule, setDataModule, setDescription, setIsRemoteCall, setOtherMeta, setParent, setParent, setServerPassword, setServiceGrade, setServiceModule, setServiceState, startAllThreads, startThread, stopAllThreads, syncToAsync, syncToAsyncReply, syncToAsyncTransit, xmlToDynamicLinks, xmlToService
getShutDown, setShutDown, setShutDown
canAccess, getPasswordHandler, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType
getJarFile, getUUID, loadObject, setJarFile, setUUID, threadAliveState
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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setData
getUUID, setJarFile, setUUID
protected MethodInfo dataMethod
protected org.ai_heuristic.def.EvaluateMathDef dataCompare
protected java.lang.Object resultObj
public DataService() throws java.lang.Exception
anon
by default.java.lang.Exception
- any error.public DataService(java.lang.String thisPassword, java.lang.String thisAdminKey) throws java.lang.Exception
thisPassword
- password to invoke this service.thisAdminKey
- admin key for this service.java.lang.Exception
- any error.public DataService(java.lang.String thisPassword, java.lang.String thisAdminKey, org.licas_xml.abs.Element adminXml) throws java.lang.Exception
thisPassword
- password to invoke this service.thisAdminKey
- admin key for this service.adminXml
- the admin info or description of this service.java.lang.Exception
- any error.public void resetValues()
resetValues
in interface DataServiceDef
protected void setInstanceValues(org.licas_xml.abs.Element instanceValues) throws java.lang.Exception
NOTE:
you must add this method to your own derived class if you use it,
so that the private variables in that class can be accessed. It is ignored
unless it gets called through the script initialisation process.
setInstanceValues
in class Service
instanceValues
- the admin script part that defines instance values.java.lang.Exception
- any error.protected java.lang.Object getInstanceValue(java.lang.String varName) throws java.lang.Exception
NOTE:
you must add this method to your own derived class if you use it,
so that the private variables in that class can be accessed. It is ignored
unless it gets called through the script initialisation process.
getInstanceValue
in class Service
varName
- the name of the variable to check for.java.lang.Exception
- any error.protected void setSerializeValues(org.licas_xml.abs.Element serializeXml) throws java.lang.Exception
NOTE:
you must add this method to your own derived class if you
use it, so that the private variables in that class can be accessed.
setSerializeValues
in class Service
serializeXml
- the admin script part that defines serialize instance
values.java.lang.Exception
- any error.public org.licas_xml.abs.Element evaluate(DataQueryModel dataQueryModel) throws java.lang.Exception
dataQueryModel
- evaluator query. For this version it must be a ComparisonQueryModel
.java.lang.Exception
- and error.protected EvaluateData createEvaluateData(DataQueryModel dataQueryModel) throws java.lang.Exception
dataQueryModel
- to store the data evaluator values.java.lang.Exception
- any error.public EvaluateData createEvaluateData(DataQueryModel dataQueryModel, java.lang.String adminKey) throws java.lang.Exception
dataQueryModel
- to store the data evaluator values.adminKey
- the admin key for the parent service.null
if the admin key is incorrect.java.lang.Exception
- any error.public void setGenData(java.lang.String adminKey) throws java.lang.Exception
adminKey
- the admin key for this service.java.lang.Exception
- any error.protected void setFixedDataValue() throws java.lang.Exception
java.lang.Exception
- any error.protected void setData(DataQueryModel dataQueryModel) throws java.lang.Exception
DataModule
dataset, from the query parameters.dataQueryModel
- to store the data evaluator values.java.lang.Exception
- any error.public boolean setData(java.lang.String dataType, java.lang.Object dataObj, java.lang.String adminKey) throws java.lang.Exception
Resource
in the DataModule
and stores the value directly.setData
in interface DataServiceDef
dataType
- the data type.dataObj
- the data object.adminKey
- the admin key for the service.java.lang.Exception
- any error.public java.lang.String getDataType()
getDataType
in interface DataServiceDef
protected boolean dataTypeOK(java.lang.String dataType)
dataType
- the data type, should match with the service and data module.public java.lang.Object getData() throws java.lang.Exception
public java.lang.Object getData(org.licas_xml.abs.Element infoDescr) throws java.lang.Exception
public void dataXmlBM(java.lang.String adminKey) throws java.lang.Exception
Data
entry.
This version sends the data information to a service identified by
ServiceConst
.BEHAVIOURMEDIATOR
. It includes the data element
of this service, any links that it has formed and also the result of the
evaluation process.
dataXmlBM
in interface DataServiceDef
adminKey
- as it would typically be called internally, it is protected by
the service's admin key.java.lang.Exception
- any other error.PasswordException
- incorrect password for the server or mediator service.MethodNotFoundException
- the mediator does not have the calling method.protected void dataXmlBM(org.licas_xml.abs.Element dataXml, org.licas_xml.abs.Element otherXml, boolean links) throws java.lang.Exception
This version sends the data information to a service identified by
ServiceConst
.BEHAVIOURMEDIATOR
. It includes the data element
of this service, any links that it has formed and also the result of the
evaluation process.
dataXml
- this is the service's Data
section. It can be null if it
should not be sent.otherXml
- is any additional information, such as an evaluation result, or
anything that has been dynamically created. It gets added as a sub-element
of the outermost reply element.links
- true if include linking information.java.lang.Exception
- any other error.public void dataXmlDH(java.lang.String adminKey) throws java.lang.Exception
This version sends the data information to a service identified by
ServiceConst
.DATAHUB
. It includes the data element
of this service, any links that it has formed and also the result of the
evaluation process.
dataXmlDH
in interface DataServiceDef
adminKey
- as it would typically be called internally, it is protected by
the service's admin key.java.lang.Exception
- any other error.PasswordException
- incorrect password for the server or mediator service.MethodNotFoundException
- the mediator does not have the calling method.protected void dataXmlDH(org.licas_xml.abs.Element dataXml, org.licas_xml.abs.Element otherXml) throws java.lang.Exception
Data-Value
metadata structure to send the data.
This version sends the data information to a service identified by
ServiceConst
.DATAHUB
. It includes the data element
of this service, any links that it has formed and also the result of the
evaluation process.
dataXml
- this is the service's Data
section. It can be null if it
should not be sent.otherXml
- this is a result or other xml piece of data to send. It can be null
if it should not be sent.java.lang.Exception
- any error.public void setResultObj(java.lang.Object thisObj)
thisObj
- the value to set the result object to.public java.lang.Object getResultObj()