public class TriggerManager<S extends Storable> extends Trigger<S>
Trigger.Abort
Constructor and Description |
---|
TriggerManager() |
TriggerManager(java.lang.Class<S> type,
java.lang.Iterable<TriggerFactory> triggerFactories) |
Modifier and Type | Method and Description |
---|---|
boolean |
addTrigger(Trigger<? super S> trigger) |
void |
addTriggers(java.lang.Class<S> type,
java.lang.Iterable<TriggerFactory> triggerFactories) |
void |
afterDelete(S storable,
java.lang.Object state)
Called right after a storable has been successfully deleted.
|
void |
afterInsert(S storable,
java.lang.Object state)
Called right after a storable has been successfully inserted.
|
void |
afterLoad(S storable)
Called right after a storable has been successfully loaded or
fetched.
|
void |
afterTryDelete(S storable,
java.lang.Object state)
Called right after a storable has been successfully deleted via
tryDelete.
|
void |
afterTryInsert(S storable,
java.lang.Object state)
Called right after a storable has been successfully inserted via
tryInsert.
|
void |
afterTryUpdate(S storable,
java.lang.Object state)
Called right after a storable has been successfully updated via
tryUpdate.
|
void |
afterUpdate(S storable,
java.lang.Object state)
Called right after a storable has been successfully updated.
|
java.lang.Object |
beforeDelete(S storable)
Called before a storable is to be deleted.
|
java.lang.Object |
beforeDelete(Transaction txn,
S storable)
Called before a storable is to be deleted.
|
java.lang.Object |
beforeInsert(S storable)
Called before a storable is to be inserted.
|
java.lang.Object |
beforeInsert(Transaction txn,
S storable)
Called before a storable is to be inserted.
|
java.lang.Object |
beforeTryDelete(S storable)
Called before a storable is to be deleted via tryDelete.
|
java.lang.Object |
beforeTryDelete(Transaction txn,
S storable)
Called before a storable is to be deleted via tryDelete.
|
java.lang.Object |
beforeTryInsert(S storable)
Called before a storable is to be inserted via tryInsert.
|
java.lang.Object |
beforeTryInsert(Transaction txn,
S storable)
Called before a storable is to be inserted via tryInsert.
|
java.lang.Object |
beforeTryUpdate(S storable)
Called before a storable is to be updated via tryUpdate.
|
java.lang.Object |
beforeTryUpdate(Transaction txn,
S storable)
Called before a storable is to be updated via tryUpdate.
|
java.lang.Object |
beforeUpdate(S storable)
Called before a storable is to be updated.
|
java.lang.Object |
beforeUpdate(Transaction txn,
S storable)
Called before a storable is to be updated.
|
void |
failedDelete(S storable,
java.lang.Object state)
Called when an delete operation failed because the record was missing or
an exception was thrown.
|
void |
failedInsert(S storable,
java.lang.Object state)
Called when an insert operation failed due to a unique constraint
violation or an exception was thrown.
|
void |
failedUpdate(S storable,
java.lang.Object state)
Called when an update operation failed because the record was missing or
an exception was thrown.
|
Trigger<? super S> |
getDeleteTrigger()
Returns a consolidated trigger to call for delete operations, or null if
none.
|
Trigger<? super S> |
getInsertTrigger()
Returns a consolidated trigger to call for insert operations, or null if
none.
|
Trigger<? super S> |
getLoadTrigger()
Returns a consolidated trigger to call for load operations, or null if
none.
|
Trigger<? super S> |
getUpdateTrigger()
Returns a consolidated trigger to call for update operations, or null if
none.
|
void |
locallyDisableDelete()
Disables execution of all managed delete triggers for the current
thread.
|
void |
locallyDisableInsert()
Disables execution of all managed insert triggers for the current
thread.
|
void |
locallyDisableLoad()
Disables execution of all managed load triggers for the current
thread.
|
void |
locallyDisableUpdate()
Disables execution of all managed update triggers for the current
thread.
|
void |
locallyEnableDelete()
Enables execution of all managed delete triggers for the current thread,
if they had been disabled before.
|
void |
locallyEnableInsert()
Enables execution of all managed insert triggers for the current thread,
if they had been disabled before.
|
void |
locallyEnableLoad()
Enables execution of all managed load triggers for the current thread,
if they had been disabled before.
|
void |
locallyEnableUpdate()
Enables execution of all managed update triggers for the current thread,
if they had been disabled before.
|
boolean |
removeTrigger(Trigger<? super S> trigger) |
public TriggerManager()
public TriggerManager(java.lang.Class<S> type, java.lang.Iterable<TriggerFactory> triggerFactories) throws RepositoryException
triggerFactories
- TriggerFactories which will be called upon to
optionally return a trigger to initially registerRepositoryException
public Trigger<? super S> getInsertTrigger()
public Trigger<? super S> getUpdateTrigger()
public Trigger<? super S> getDeleteTrigger()
public Trigger<? super S> getLoadTrigger()
public void addTriggers(java.lang.Class<S> type, java.lang.Iterable<TriggerFactory> triggerFactories) throws RepositoryException
RepositoryException
public void locallyDisableInsert()
public void locallyEnableInsert()
public void locallyDisableUpdate()
public void locallyEnableUpdate()
public void locallyDisableDelete()
public void locallyEnableDelete()
public void locallyDisableLoad()
public void locallyEnableLoad()
public java.lang.Object beforeInsert(S storable) throws PersistException
Trigger
Any exception thrown by this method will cause the insert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the insert method.
beforeInsert
in class Trigger<S extends Storable>
storable
- storable before being insertedPersistException
public java.lang.Object beforeInsert(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeInsert(Object)
. Only override if access to
the transaction is required.
Any exception thrown by this method will cause the insert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the insert method.
beforeInsert
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being insertedPersistException
public java.lang.Object beforeTryInsert(S storable) throws PersistException
Trigger
Trigger.beforeInsert(Object)
. Only override
if trigger needs to distinguish between different insert variants.
Any exception thrown by this method will cause the tryInsert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryInsert method.
beforeTryInsert
in class Trigger<S extends Storable>
storable
- storable before being insertedPersistException
Trigger.abortTry()
public java.lang.Object beforeTryInsert(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeTryInsert(Object)
. Only
override if trigger needs access to the transaction and to distinguish
between different insert variants.
Any exception thrown by this method will cause the tryInsert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryInsert method.
beforeTryInsert
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being insertedPersistException
Trigger.abortTry()
public void afterInsert(S storable, java.lang.Object state) throws PersistException
Trigger
Any exception thrown by this method will cause the insert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the insert method.
afterInsert
in class Trigger<S extends Storable>
storable
- storable after being insertedstate
- object returned by beforeInsert methodPersistException
public void afterTryInsert(S storable, java.lang.Object state) throws PersistException
Trigger
Trigger.afterInsert(S, java.lang.Object)
.
Only override if trigger needs to distinguish between different insert
variants.
Any exception thrown by this method will cause the tryInsert operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryInsert method.
afterTryInsert
in class Trigger<S extends Storable>
storable
- storable after being insertedstate
- object returned by beforeTryInsert methodPersistException
Trigger.abortTry()
public void failedInsert(S storable, java.lang.Object state)
Trigger
Any exception thrown by this method will be passed to the current thread's uncaught exception handler.
failedInsert
in class Trigger<S extends Storable>
storable
- storable which failed to be insertedstate
- object returned by beforeInsert method, but it may be nullpublic java.lang.Object beforeUpdate(S storable) throws PersistException
Trigger
Any exception thrown by this method will cause the update operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the update method.
beforeUpdate
in class Trigger<S extends Storable>
storable
- storable before being updatedPersistException
public java.lang.Object beforeUpdate(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeUpdate(Object)
. Only override if access to
the transaction is required.
Any exception thrown by this method will cause the update operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the update method.
beforeUpdate
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being updatedPersistException
public java.lang.Object beforeTryUpdate(S storable) throws PersistException
Trigger
Trigger.beforeUpdate(Object)
. Only override
if trigger needs to distinguish between different update variants.
Any exception thrown by this method will cause the tryUpdate operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryUpdate method.
beforeTryUpdate
in class Trigger<S extends Storable>
storable
- storable before being updatedPersistException
Trigger.abortTry()
public java.lang.Object beforeTryUpdate(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeTryUpdate(Object)
. Only
override if trigger needs access to the transaction and to distinguish
between different update variants.
Any exception thrown by this method will cause the tryUpdate operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryUpdate method.
beforeTryUpdate
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being updatedPersistException
Trigger.abortTry()
public void afterUpdate(S storable, java.lang.Object state) throws PersistException
Trigger
Any exception thrown by this method will cause the update operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the update method.
afterUpdate
in class Trigger<S extends Storable>
storable
- storable after being updatedstate
- optional object returned by beforeUpdate methodPersistException
public void afterTryUpdate(S storable, java.lang.Object state) throws PersistException
Trigger
Trigger.afterUpdate(S, java.lang.Object)
.
Only override if trigger needs to distinguish between different update
variants.
Any exception thrown by this method will cause the tryUpdate operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryUpdate method.
afterTryUpdate
in class Trigger<S extends Storable>
storable
- storable after being updatedstate
- object returned by beforeTryUpdate methodPersistException
Trigger.abortTry()
public void failedUpdate(S storable, java.lang.Object state)
Trigger
Any exception thrown by this method will be passed to the current thread's uncaught exception handler.
failedUpdate
in class Trigger<S extends Storable>
storable
- storable which failed to be updatedstate
- optional object returned by beforeUpdate
method, but it may be nullpublic java.lang.Object beforeDelete(S storable) throws PersistException
Trigger
Any exception thrown by this method will cause the delete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the delete method.
beforeDelete
in class Trigger<S extends Storable>
storable
- storable before being deletedPersistException
public java.lang.Object beforeDelete(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeDelete(Object)
. Only override if access to
the transaction is required.
Any exception thrown by this method will cause the delete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the delete method.
beforeDelete
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being deletedPersistException
public java.lang.Object beforeTryDelete(S storable) throws PersistException
Trigger
Trigger.beforeDelete(Object)
. Only override
if trigger needs to distinguish between different delete variants.
Any exception thrown by this method will cause the tryDelete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryDelete method.
beforeTryDelete
in class Trigger<S extends Storable>
storable
- storable before being deletedPersistException
Trigger.abortTry()
public java.lang.Object beforeTryDelete(Transaction txn, S storable) throws PersistException
Trigger
Trigger.beforeTryDelete(Object)
. Only
override if trigger needs access to the transaction and to distinguish
between different delete variants.
Any exception thrown by this method will cause the tryDelete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryDelete method.
beforeTryDelete
in class Trigger<S extends Storable>
txn
- nested transaction which trigger runs instorable
- storable before being deletedPersistException
Trigger.abortTry()
public void afterDelete(S storable, java.lang.Object state) throws PersistException
Trigger
Any exception thrown by this method will cause the delete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the delete method.
afterDelete
in class Trigger<S extends Storable>
storable
- storable after being deletedstate
- optional object returned by beforeDelete methodPersistException
public void afterTryDelete(S storable, java.lang.Object state) throws PersistException
Trigger
Trigger.afterDelete(S, java.lang.Object)
.
Only override if trigger needs to distinguish between different delete
variants.
Any exception thrown by this method will cause the tryDelete operation to rollback and all remaining triggers to not run. The exception is ultimately passed to the caller of the tryDelete method.
afterTryDelete
in class Trigger<S extends Storable>
storable
- storable after being deletedstate
- object returned by beforeTryDelete methodPersistException
Trigger.abortTry()
public void failedDelete(S storable, java.lang.Object state)
Trigger
Any exception thrown by this method will be passed to the current thread's uncaught exception handler.
failedDelete
in class Trigger<S extends Storable>
storable
- storable which failed to be deletedstate
- optional object returned by beforeDelete
method, but it may be nullpublic void afterLoad(S storable) throws FetchException
Trigger
afterLoad
in class Trigger<S extends Storable>
storable
- storable after being loaded or fetchedFetchException
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.