com.ibm.ia.agent
Class EntityAgent<T extends Entity>
- java.lang.Object
-
- com.ibm.ia.common.BaseComponent
-
- com.ibm.ia.agent.Agent
-
- com.ibm.ia.agent.EntityAgent<T>
-
- Type Parameters:
T
- The type of the bound entity.
- All Implemented Interfaces:
- com.ibm.ia.agent.AgentService, com.ibm.ia.agent.EntityAgentService<T>, com.ibm.ia.common.BaseComponentService, Extension, SolutionComponent
- Direct Known Subclasses:
- ScoringEntityAgent
public abstract class EntityAgent<T extends Entity> extends Agent implements com.ibm.ia.agent.EntityAgentService<T>
The base class that is extended by agent implementations that are bound to an entity. This class extends the Agent class and provided support for working with the bound entity.
A typical EntityAgent implementation might use the following pattern to work with the bound entity:
- Retrieve the bound entity from the entity store, using getBoundEntity().
- If getBoundEntity() returned null, use createBoundEntity() to create an uninitialized instance of the bound entity.
- Read the attributes of the bound entity and modify them as required.
- If desired, use updateBoundEntity() to store the newly created or modified bound entity to the entity store.
- If desired, use deleteBoundEntity() to delete the bound entity in the entity store.
For more information refer to Entity lifecycle documentation in the InfoCenter.
-
-
Field Summary
-
Fields inherited from class com.ibm.ia.agent.Agent
delayValue
-
-
Method Summary
Methods Modifier and Type Method and Description T
createBoundEntity()
Creates an instance of the bound entity using the default entity type for the agent.<C extends T>
CcreateBoundEntity(java.lang.Class<C> entityClass)
Creates an instance of the bound entity using the specified entity type.T
createBoundEntity(java.lang.String entityType)
Creates an instance of the bound entity using the specified entity type.boolean
deleteBoundEntity()
Delete the bound entity from the entity store.T
getBoundEntity()
Retrieves the bound entity from the entity store.boolean
updateBoundEntity(T entity)
Stores the bound entity in the entity store.-
Methods inherited from class com.ibm.ia.agent.Agent
activated, agentPerformsSelfMonitoring, cancelSchedule, clearEngineTime, clearEventTTL, clearOutboundEvents, createRelationship, createRelationship, deactivated, emit, getAgentDescriptor, getAgentProperty, getAgentVersion, getCalendarDuration, getCurrentEventReference, getEmittedEvents, getEngineTime, getEntityFactory, getEventFactory, getEventTTL, getFactoryServices, getGenericEntity, getGlobalValue, getJobService, getModelFactory, getRequiredEngineVersion, getSolutionDescriptor, getSolutionProperties, getSolutionProperty, getSolutionProperty, getSpatialService, getTimeService, getTimeService, hasUserDefinedCookie, init, initializeEngineDefinition, isThrowableIgnored, loadRulesetArchive, printToLog, printToLog, printToLog, process, process, resolveEvent, schedule, schedule, setEngineTime, setEventTTL, setRequiredEngineVersion, toString, useMonitorWarning
-
Methods inherited from class com.ibm.ia.common.BaseComponent
emit, getConceptFactory, getEventInstance, getEventResolver, getLocalQueryService, getModelSerializer, getObjectEntityResolver, getObjectEventResolver, getTimeService, processOutboundEvents, resetResolvers, setEntityResolver, setEntityScopedQS, setModelFactory, setObjectEntityResolver, setSolutionDescriptor
-
-
-
-
Method Detail
-
getBoundEntity
public T getBoundEntity() throws AgentException, EntityTypeException
Retrieves the bound entity from the entity store.- Throws:
AgentException
EntityTypeException
- Returns:
- An entity instance containing the current state of the entity. Returns null if the entity does not exist.
-
createBoundEntity
public T createBoundEntity() throws AgentException
Creates an instance of the bound entity using the default entity type for the agent. This method creates an uninitialized instance but it does not update the entity store. The attribute that identifies the entity is set automatically. After the entity instance is initialized, you can use updateBoundEntity() to add it to the entity store.- Throws:
AgentException
- Returns:
- A new instance of the entity type with the bound entity ID.
-
createBoundEntity
public <C extends T> C createBoundEntity(java.lang.Class<C> entityClass) throws AgentException
Creates an instance of the bound entity using the specified entity type. This method creates an uninitialized instance but it does not update the entity store. The attribute that identifies the entity is set automatically. After the entity instance is initialized, you can use updateBoundEntity() to add it to the entity store.- Throws:
AgentException
- Parameters:
entityClass
- The require entity type, which must be a subclass of the default entity type for the agent.- Returns:
- A new instance of the entity type with the bound entity ID.
-
createBoundEntity
public T createBoundEntity(java.lang.String entityType) throws AgentException, EntityTypeException
Creates an instance of the bound entity using the specified entity type. This method creates an uninitialized instance but it does not update the entity store. The attribute that identifies the entity is set automatically. After the entity instance is initialized, you can use updateBoundEntity() to add it to the entity store.- Throws:
AgentException
EntityTypeException
- Parameters:
entityType
- The require entity type, which must be a subclass of the default entity type for the agent.- Returns:
- A new instance of the entity type with the bound entity ID.
-
deleteBoundEntity
public boolean deleteBoundEntity() throws AgentException
Delete the bound entity from the entity store.- Throws:
AgentException
- Returns:
-
updateBoundEntity
public boolean updateBoundEntity(T entity) throws AgentException, BoundEntityIDException
Stores the bound entity in the entity store. This method must be called to save a new or modified bound entity to the entity store.- Throws:
AgentException
BoundEntityIDException
- Parameters:
entity
- The new entity value.- Returns:
- True if the update was successful.
-
-