T - The type of the entity.
This must match the entityType property of the EntityInitializerDescriptor
annotation.public abstract class EntityInitializer<T extends com.ibm.ia.model.Entity>
extends com.ibm.ia.common.BaseComponent
implements com.ibm.ia.extension.spi.EntityInitializerService
The abstract class for entity initializer implementations.
At most one entity initializer is called for a new entity instance. The implementation is responsible for initializing all the attributes that are necessary, including the attributes of parent types.
| Modifier and Type | Method and Description |
|---|---|
T |
createEntityFromEvent(com.ibm.ia.model.Event event)
Entry point of the first phase of the entity initializer in response to
an event.
|
void |
emit(com.ibm.ia.model.Event event)
Emit an event.
|
java.lang.String |
getEntityId()
Returns the ID of the entity to be initialized.
|
java.lang.String |
getEntityType()
Returns the type of the entity to be initialized.
|
void |
initializeEntity(T entity)
Entry point of the second phase of the entity initializer in response to
an event, or in response to creating an entity using the REST API.
|
createRelationship, createRelationship, deactivated, emit, getConceptFactory, getEventInstance, getEventResolver, getLocalQueryService, getModelFactory, getModelSerializer, getObjectEntityResolver, getObjectEventResolver, getRequiredEngineVersion, getSolutionDescriptor, getSolutionProperties, getSolutionProperty, getSolutionProperty, getTimeService, getTimeService, processOutboundEvents, resetResolvers, setEntityResolver, setEntityScopedQS, setModelFactory, setObjectEntityResolver, setRequiredEngineVersion, setSolutionDescriptorpublic T createEntityFromEvent(com.ibm.ia.model.Event event) throws ComponentException
Entry point of the first phase of the entity initializer in response to an event.
The default implementation creates an instance of the bound entity using the entity type returned by getEntityType(). The attribute that contains the entity ID is set automatically but any other attributes are uninitialized. You can override this method to initialize attributes of the entity using the value of the event.
This method can veto the request to initialize the entity by returning a null value, in which case the entity is not created. Agents that are bound to the entity will receive a null value.
If this method returns a non-null value, the runtime will invoke initializeEntity() to complete this phase of the entity initialization.
ComponentExceptionevent - The current event.public void initializeEntity(T entity) throws ComponentException
Entry point of the second phase of the entity initializer in response to an event, or in response to creating an entity using the REST API.
The default implementation does not modify the entity. You can override this method to retrieve information from external systems to initialize the attributes of the entity or emit events.
ComponentExceptionentity - The entity to be initialized.public final java.lang.String getEntityType()
throws ComponentException
ComponentExceptionjava.lang.UnsupportedOperationException - if called outside a valid execution context.public final java.lang.String getEntityId()
throws ComponentException
ComponentExceptionjava.lang.UnsupportedOperationException - if called outside a valid execution context.public final void emit(com.ibm.ia.model.Event event)
throws ComponentException
ComponentExceptionjava.lang.UnsupportedOperationException - if called outside a valid execution context.event - The event to emit.© Copyright IBM 2017