com.ibm.ia.agent

Class EntityAgent<T extends Entity>

  • 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:

    1. Retrieve the bound entity from the entity store, using getBoundEntity().
    2. If getBoundEntity() returned null, use createBoundEntity() to create an uninitialized instance of the bound entity.
    3. Read the attributes of the bound entity and modify them as required.
    4. If desired, use updateBoundEntity() to store the newly created or modified bound entity to the entity store.
    5. If desired, use deleteBoundEntity() to delete the bound entity in the entity store.

For more information refer to Entity lifecycle documentation in the InfoCenter.

    • Method Detail

      • 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.