Class ReadonlyProfile
java.lang.Object
com.aquima.interactions.profile.wrapper.ReadonlyProfile
- All Implemented Interfaces:
IEventChannel
,IProfile
,IProfileLifecycle
,Serializable
- Direct Known Subclasses:
DependencyProfile
,ReadonlyInferenceContext
Decorator class that wraps a profile to make it immutable (read-only).
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReadonlyProfile
(IProfile profile) Constructs a read-only wrapper for the specified profile. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(IProfileActivationContext profileActivationContext) This method may be used for activating the profile after deserialization.boolean
addEventListener
(IEventListener listener) Always throws an InvalidStateException: No modifications allowed on a read only profile.void
commitTransaction
(String name) Always throws an InvalidStateException: No modifications allowed on a read only profile.createInstance
(String entityName) Always throws an InvalidStateException: No modifications allowed on a read only profile.createInstance
(String entityName, GUID instanceId, String instanceName) Always throws an InvalidStateException: No modifications allowed on a read only profile.void
deleteInstance
(IEntityInstance instance, boolean autoDetach) Always throws an InvalidStateException: No modifications allowed on a read only profile.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 instance) 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.protected IProfile
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.void
This method may be used for preparing the profile for serialization.boolean
removeEventListener
(IEventListener listener) Always throws an InvalidStateException: No modifications allowed on a read only profile.void
restore
(IProfileState state) Clears the current state and overrides it with the provided state.void
rollbackTransaction
(String name) Always throws an InvalidStateException: No modifications allowed on a read only profile.void
startTransaction
(String name) Always throws an InvalidStateException: No modifications allowed on a read only profile.protected IEntityInstance
wrapInstance
(IEntityInstance instance)
-
Constructor Details
-
Method Details
-
getProfile
-
wrapInstance
-
createInstance
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
createInstance
in interfaceIProfile
- 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
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
createInstance
in interfaceIProfile
- Parameters:
entityName
- The name of the entity for which a new instance should be created.instanceId
- Unique ID of the new instance.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.
-
deleteInstance
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
deleteInstance
in interfaceIProfile
- 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
- 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).
-
getEntityDefinition
Description copied from interface:IProfile
This method returns an entity definition for the supplied entity name.- Specified by:
getEntityDefinition
in interfaceIProfile
- Parameters:
entityName
- The name of the entity for which the definition is requested.- Returns:
- IEntityDefinition object containing the static entity information.
-
getInstance
Description copied from interface:IProfile
This method can be used to lookup an instance based on a reference.- Specified by:
getInstance
in interfaceIProfile
- Parameters:
instance
- InstanceReference of the instance that should be returned.- Returns:
- IEntityInstance The entity instance for the specified ID.
-
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
- 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.
-
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
- 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.
-
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
- 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.
-
addEventListener
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
addEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be added.- Returns:
- boolean indicating if the listener was actually added.
-
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
- Returns:
- Bit-mask containing the event types that are supported by this event channel.
-
removeEventListener
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
removeEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be removed.- Returns:
- boolean indicating if the listener was actually removed.
-
commitTransaction
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
commitTransaction
in interfaceIProfile
- Parameters:
name
- Identifier for the transaction.- Throws:
InvalidStateException
- This exception will always be thrown, as no modifications are allowed.
-
rollbackTransaction
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
rollbackTransaction
in interfaceIProfile
- Parameters:
name
- Identifier for the transaction.- Throws:
InvalidStateException
- This exception will always be thrown, as no modifications are allowed.
-
startTransaction
Always throws an InvalidStateException: No modifications allowed on a read only profile.- Specified by:
startTransaction
in interfaceIProfile
- Parameters:
name
- Identifier for the transaction.- Throws:
InvalidStateException
- This exception will always be thrown, as no modifications are allowed.
-
getState
Description copied from interface:IProfile
Returns the state of the profile (for serialization) -
restore
Description copied from interface:IProfile
Clears the current state and overrides it with the provided state. -
passivate
public void passivate()Description copied from interface:IProfileLifecycle
This method may be used for preparing the profile for serialization.- Specified by:
passivate
in interfaceIProfileLifecycle
-
activate
Description copied from interface:IProfileLifecycle
This method may be used for activating the profile after deserialization.- Specified by:
activate
in interfaceIProfileLifecycle
- Parameters:
profileActivationContext
- the current profile activation context.
-