Class TxProfile
java.lang.Object
com.aquima.interactions.profile.wrapper.ProfileDelegate
com.aquima.interactions.profile.model.TxProfile
- All Implemented Interfaces:
IEventChannel
,IProfile
,IProfileLifecycle
,Serializable
Wrapper for the IProfile interface that adds transaction support.
- Since:
- 6.5
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEventListener
(IEventListener listener) This method will add the passed event listener to the list of listeners.void
commitTransaction
(String name) Commits the current transaction in the profile.createInstance
(String entityName) This method creates a new empty instance for the specified entity type.createInstance
(String entityName, GUID instanceId, String instanceName) This method creates a new empty instance for the specified entity type.void
deleteInstance
(IEntityInstance instance, boolean autoDetach) Deletes the given instance, rendering the parameter useless.getAllInstancesForEntity
(String entityName, boolean includeChildren) This method returns all existing instances of a certain type in the profile.getEntityDefinition
(String entityName) This method returns an entity definition for the supplied entity name.getInstance
(EntityValue instanceValue) This method can be used to lookup an instance based on a reference.getInstanceById
(String entityName, GUID instanceId) This method returns the instance of the specified type for the given instance id.getInstanceByName
(String entityName, String instanceName) This method returns an instance of the specified type for the given instance name.getSingletonInstance
(String entityName, boolean create) This method can be used to retrieve the singleton instance from the profile for a specific entity type.getState()
Returns the state of the profile (for serialization)int
This method returns a bit-mask containing all event types that are supported by this event channel.boolean
removeEventListener
(IEventListener listener) This method will remove the specified event listener from the list of listeners.void
restore
(IProfileState state) Clears the current state and overrides it with the provided state.void
rollbackTransaction
(String name) Performs a roll-back of all changes since the last start of a transaction.void
startTransaction
(String name) Starts a new transaction in the profile.Methods inherited from class com.aquima.interactions.profile.wrapper.ProfileDelegate
activate, getProfile, passivate
-
Constructor Details
-
TxProfile
Constructs the transactional wrapper with the profile that should be made transactional.- Parameters:
profile
- The profile that should be made transactional.
-
-
Method Details
-
createInstance
Description copied from interface:IProfile
This method creates a new empty instance for the specified entity type. The name and id of this new instance are generated by the profile itself.- Specified by:
createInstance
in interfaceIProfile
- Overrides:
createInstance
in classProfileDelegate
- Parameters:
entityName
- The name of the entity for which a new instance should be created.- Returns:
- A new instance for the specified type. Never null.
-
createInstance
Description copied from interface:IProfile
This method creates a new empty instance for the specified entity type. This method may supply either a name or ID which will be used by the profile to determine these values. When ID and instanceName are supplied with null, the behavior of this function is exactly the same as createInstance( String entityName ).- Specified by:
createInstance
in interfaceIProfile
- Overrides:
createInstance
in classProfileDelegate
- Parameters:
entityName
- The name of the entity for which a new instance should be created.instanceId
- Unique ID of the new instance. When null is supplied, an ID will be generated by the profile.instanceName
- Unique name of the new instance. when null is supplied a name will be generated by the profile.- Returns:
- A new instance for the specified type. Never null.
-
getSingletonInstance
Description copied from interface:IProfile
This method can be used to retrieve the singleton instance from the profile for a specific entity type. Depending on the value of the create parameter that is passed, the behavior of this method differs slightly.
- When there is a singleton instance present in the profile for the specified type, this method will return that instance regardless the value of create.
- When no instance is present for the specified type and create is set to true, the singleton instance will be created and returned.
- When no instance is present for the specified type and create is set to false, an UnknownInstanceException will be thrown.
- Specified by:
getSingletonInstance
in interfaceIProfile
- Overrides:
getSingletonInstance
in classProfileDelegate
- Parameters:
entityName
- String the Name of the entitycreate
- boolean indicating whether the singleton instance should be created in case it does not exist yet.- Returns:
- IEntityInstance interface pointing to the singleton ('0'th) instance for the specified entity type.
-
deleteInstance
Description copied from interface:IProfile
Deletes the given instance, rendering the parameter useless. Please ensure no calls to the parameter IEntityInstance will be done after the deleteInstance.- Specified by:
deleteInstance
in interfaceIProfile
- Overrides:
deleteInstance
in classProfileDelegate
- Parameters:
instance
- IEntityInstance the instance to delete.autoDetach
- Boolean indicating if references to this instance should automatically be updated.
-
getAllInstancesForEntity
Description copied from interface:IProfile
This method returns all existing instances of a certain type in the profile. Even when there are no instances available for a certain type an empty array will be returned.- Specified by:
getAllInstancesForEntity
in interfaceIProfile
- Overrides:
getAllInstancesForEntity
in classProfileDelegate
- Parameters:
entityName
- The entity type for which the instances are requested.includeChildren
- when this option is passed as true, all child entity-types are also returned.- Returns:
- An array of instances for the specified type (never null).
-
getInstance
Description copied from interface:IProfile
This method can be used to lookup an instance based on a reference.- Specified by:
getInstance
in interfaceIProfile
- Overrides:
getInstance
in classProfileDelegate
- Parameters:
instanceValue
- InstanceReference of the instance that should be returned.- Returns:
- IEntityInstance The entity instance for the specified ID.
-
getInstanceById
Description copied from interface:IProfile
This method returns the instance of the specified type for the given instance id. The id of an instance is generated when the instance is created, and can thus only be used within the same session.- Specified by:
getInstanceById
in interfaceIProfile
- Overrides:
getInstanceById
in classProfileDelegate
- Parameters:
entityName
- The name of the entity (type) of which the instance should be.instanceId
- The (unique) id of the instance.- Returns:
- IEntityInstance object of the correct type for the specified name.
-
getInstanceByName
Description copied from interface:IProfile
This method returns an instance of the specified type for the given instance name.- Specified by:
getInstanceByName
in interfaceIProfile
- Overrides:
getInstanceByName
in classProfileDelegate
- Parameters:
entityName
- The name of the entity (type) of which the instance should be.instanceName
- The name of the instance.- Returns:
- IEntityInstance object of the correct type for the specified name.
-
startTransaction
Description copied from interface:IProfile
Starts a new transaction in the profile.- Specified by:
startTransaction
in interfaceIProfile
- Overrides:
startTransaction
in classProfileDelegate
- Parameters:
name
- Unique name identifying the transaction.
-
commitTransaction
Description copied from interface:IProfile
Commits the current transaction in the profile.- Specified by:
commitTransaction
in interfaceIProfile
- Overrides:
commitTransaction
in classProfileDelegate
- Parameters:
name
- Unique name identifying the transaction.
-
rollbackTransaction
Description copied from interface:IProfile
Performs a roll-back of all changes since the last start of a transaction.- Specified by:
rollbackTransaction
in interfaceIProfile
- Overrides:
rollbackTransaction
in classProfileDelegate
- Parameters:
name
- Unique name identifying the transaction.
-
getSupportedEvents
public int getSupportedEvents()Description copied from interface:IEventChannel
This method returns a bit-mask containing all event types that are supported by this event channel. The bit-mask is a bitwise OR of the diverse event types. To check whether a specific event-listener is supported, you can do the following:// This checks if a VALUE listener is supported if ((channel.getSupportedEvents() & IEvent.Mask.VALUE) != 0) { // VALUE event listeners that are supported }
- Specified by:
getSupportedEvents
in interfaceIEventChannel
- Overrides:
getSupportedEvents
in classProfileDelegate
- Returns:
- Bit-mask containing the event types that are supported by this event channel.
-
addEventListener
Description copied from interface:IEventChannel
This method will add the passed event listener to the list of listeners.- Specified by:
addEventListener
in interfaceIEventChannel
- Overrides:
addEventListener
in classProfileDelegate
- Parameters:
listener
- The event listener that should be added.- Returns:
- boolean indicating is the listener was actually added.
-
removeEventListener
Description copied from interface:IEventChannel
This method will remove the specified event listener from the list of listeners.- Specified by:
removeEventListener
in interfaceIEventChannel
- Overrides:
removeEventListener
in classProfileDelegate
- Parameters:
listener
- The event listener that should be removed.- Returns:
- boolean indicating if the listener was actually removed.
-
getEntityDefinition
Description copied from interface:IProfile
This method returns an entity definition for the supplied entity name.- Specified by:
getEntityDefinition
in interfaceIProfile
- Overrides:
getEntityDefinition
in classProfileDelegate
- Parameters:
entityName
- The name of the entity for which the definition is requested.- Returns:
- IEntityDefinition object containing the static entity information.
-
getState
Description copied from interface:IProfile
Returns the state of the profile (for serialization)- Specified by:
getState
in interfaceIProfile
- Overrides:
getState
in classProfileDelegate
- Returns:
- returns the current state of the profile.
-
restore
Description copied from interface:IProfile
Clears the current state and overrides it with the provided state.- Specified by:
restore
in interfaceIProfile
- Overrides:
restore
in classProfileDelegate
- Parameters:
state
- The new state for this profile.
-