|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.amazon.carbonado.Trigger<S>
com.amazon.carbonado.spi.TriggerManager<S>
public class TriggerManager<S extends Storable>
Used by Storage implementations to manage triggers and consolidate them into single logical triggers. This class is thread-safe and ensures that changes to the trigger set do not affect transactions in progress.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.amazon.carbonado.Trigger |
|---|
Trigger.Abort |
| Constructor Summary | |
|---|---|
TriggerManager()
|
|
TriggerManager(Class<S> type,
Iterable<TriggerFactory> triggerFactories)
|
|
| Method Summary | |
|---|---|
boolean |
addTrigger(Trigger<? super S> trigger)
|
void |
addTriggers(Class<S> type,
Iterable<TriggerFactory> triggerFactories)
|
void |
afterDelete(S storable,
Object state)
Called right after a storable has been successfully deleted. |
void |
afterInsert(S storable,
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,
Object state)
Called right after a storable has been successfully deleted via tryDelete. |
void |
afterTryInsert(S storable,
Object state)
Called right after a storable has been successfully inserted via tryInsert. |
void |
afterTryUpdate(S storable,
Object state)
Called right after a storable has been successfully updated via tryUpdate. |
void |
afterUpdate(S storable,
Object state)
Called right after a storable has been successfully updated. |
Object |
beforeDelete(S storable)
Called before a storable is to be deleted. |
Object |
beforeInsert(S storable)
Called before a storable is to be inserted. |
Object |
beforeTryDelete(S storable)
Called before a storable is to be deleted via tryDelete. |
Object |
beforeTryInsert(S storable)
Called before a storable is to be inserted via tryInsert. |
Object |
beforeTryUpdate(S storable)
Called before a storable is to be updated via tryUpdate. |
Object |
beforeUpdate(S storable)
Called before a storable is to be updated. |
void |
failedDelete(S storable,
Object state)
Called when an delete operation failed because the record was missing or an exception was thrown. |
void |
failedInsert(S storable,
Object state)
Called when an insert operation failed due to a unique constraint violation or an exception was thrown. |
void |
failedUpdate(S storable,
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)
|
| Methods inherited from class com.amazon.carbonado.Trigger |
|---|
abortTry |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TriggerManager()
public TriggerManager(Class<S> type,
Iterable<TriggerFactory> triggerFactories)
throws RepositoryException
triggerFactories - TriggerFactories which will be called upon to
optionally return a trigger to initially register
RepositoryException| Method Detail |
|---|
public Trigger<? super S> getInsertTrigger()
public Trigger<? super S> getUpdateTrigger()
public Trigger<? super S> getDeleteTrigger()
public Trigger<? super S> getLoadTrigger()
public boolean addTrigger(Trigger<? super S> trigger)
public boolean removeTrigger(Trigger<? super S> trigger)
public void addTriggers(Class<S> type,
Iterable<TriggerFactory> triggerFactories)
throws RepositoryException
RepositoryExceptionpublic void locallyDisableInsert()
public void locallyEnableInsert()
public void locallyDisableUpdate()
public void locallyEnableUpdate()
public void locallyDisableDelete()
public void locallyEnableDelete()
public void locallyDisableLoad()
public void locallyEnableLoad()
public Object beforeInsert(S storable)
throws PersistException
TriggerAny 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 inserted
PersistException
public Object beforeTryInsert(S storable)
throws PersistException
TriggerTrigger.beforeInsert(S). 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 inserted
PersistExceptionTrigger.abortTry()
public void afterInsert(S storable,
Object state)
throws PersistException
TriggerAny 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 method
PersistException
public void afterTryInsert(S storable,
Object state)
throws PersistException
TriggerTrigger.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 method
PersistExceptionTrigger.abortTry()
public void failedInsert(S storable,
Object state)
TriggerAny 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 null
public Object beforeUpdate(S storable)
throws PersistException
TriggerAny 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 updated
PersistException
public Object beforeTryUpdate(S storable)
throws PersistException
TriggerTrigger.beforeUpdate(S). 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 updated
PersistExceptionTrigger.abortTry()
public void afterUpdate(S storable,
Object state)
throws PersistException
TriggerAny 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 method
PersistException
public void afterTryUpdate(S storable,
Object state)
throws PersistException
TriggerTrigger.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 method
PersistExceptionTrigger.abortTry()
public void failedUpdate(S storable,
Object state)
TriggerAny 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 null
public Object beforeDelete(S storable)
throws PersistException
TriggerAny 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 deleted
PersistException
public Object beforeTryDelete(S storable)
throws PersistException
TriggerTrigger.beforeDelete(S). 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 deleted
PersistExceptionTrigger.abortTry()
public void afterDelete(S storable,
Object state)
throws PersistException
TriggerAny 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 method
PersistException
public void afterTryDelete(S storable,
Object state)
throws PersistException
TriggerTrigger.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 method
PersistExceptionTrigger.abortTry()
public void failedDelete(S storable,
Object state)
TriggerAny 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 null
public void afterLoad(S storable)
throws FetchException
Trigger
afterLoad in class Trigger<S extends Storable>storable - storable after being loaded or fetched
FetchException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||