Package org.apache.openjpa.kernel
Class AuditManager
- java.lang.Object
-
- org.apache.openjpa.kernel.InMemorySavepointManager
-
- org.apache.openjpa.kernel.AuditManager
-
- All Implemented Interfaces:
PCRegistry.RegisterClassListener
,BeginTransactionListener
,EndTransactionListener
,FlushTransactionListener
,TransactionListener
,SavepointManager
public class AuditManager extends InMemorySavepointManager implements TransactionListener, PCRegistry.RegisterClassListener
Controller for audit facility. This controller performs the following basic duties:- Records auditable types at class loading time
- Listens to instance life cycle changes and transaction.
- Collects auditable instances on instance life cycle changes.
- Delegates real auditing to the
Auditor
at transaction boundary.- Author:
- Pinaki Poddar
-
-
Constructor Summary
Constructors Constructor Description AuditManager(Auditor auditor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterBegin(TransactionEvent event)
----------------------------------------------------------------------- Transaction callbacksvoid
afterCommit(TransactionEvent event)
Notification that a transaction has successfully committed.void
afterCommitComplete(TransactionEvent event)
Notification that a transaction has successfully committed and the transaction is no longer active.void
afterFlush(TransactionEvent event)
Notification that a transaction has flushed all object changes.void
afterRollback(TransactionEvent event)
Notification that a transaction has been rolled back.void
afterRollbackComplete(TransactionEvent event)
Notification that a transaction has been rolled back and the transaction is no longer active.void
afterStateTransitions(TransactionEvent event)
Notification that state transitions are complete.void
beforeCommit(TransactionEvent event)
Notification that the next flush is for the transaction commit.void
beforeFlush(TransactionEvent event)
Notification that a transaction is about to flush all object changes.java.util.Set<java.lang.Class<?>>
getAuditedTypes()
Auditor
getAuditor()
protected Broker
getBroker(PersistenceCapable pc)
Extracts the broker from the given persistence capable instance.protected PersistenceCapable
getPersistenceCapable(LifecycleEvent evt)
Extracts the persistence capable instance from the source of the given event.protected boolean
isAuditable(AuditableOperation op, StateManagerImpl sm)
Affirms if the given state manager is auditable for the given operation.void
register(java.lang.Class<?> cls)
Records all auditable classes in operation-specific sets.-
Methods inherited from class org.apache.openjpa.kernel.InMemorySavepointManager
getPreFlush, newSavepoint, setPreFlush, supportsIncrementalFlush
-
-
-
-
Constructor Detail
-
AuditManager
public AuditManager(Auditor auditor)
-
-
Method Detail
-
register
public void register(java.lang.Class<?> cls)
Records all auditable classes in operation-specific sets.- Specified by:
register
in interfacePCRegistry.RegisterClassListener
-
getAuditor
public Auditor getAuditor()
-
getAuditedTypes
public java.util.Set<java.lang.Class<?>> getAuditedTypes()
-
afterBegin
public void afterBegin(TransactionEvent event)
----------------------------------------------------------------------- Transaction callbacks. ------------------------------------------------------------------------ Specified by:
afterBegin
in interfaceBeginTransactionListener
- See Also:
TransactionEvent.AFTER_BEGIN
-
beforeCommit
public void beforeCommit(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that the next flush is for the transaction commit.- Specified by:
beforeCommit
in interfaceEndTransactionListener
- See Also:
TransactionEvent.BEFORE_COMMIT
-
afterCommit
public void afterCommit(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that a transaction has successfully committed.- Specified by:
afterCommit
in interfaceEndTransactionListener
- See Also:
TransactionEvent.AFTER_COMMIT
-
afterRollback
public void afterRollback(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that a transaction has been rolled back.- Specified by:
afterRollback
in interfaceEndTransactionListener
- See Also:
TransactionEvent.AFTER_ROLLBACK
-
afterCommitComplete
public void afterCommitComplete(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that a transaction has successfully committed and the transaction is no longer active.- Specified by:
afterCommitComplete
in interfaceEndTransactionListener
- See Also:
TransactionEvent.AFTER_COMMIT_COMPLETE
-
afterRollbackComplete
public void afterRollbackComplete(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that a transaction has been rolled back and the transaction is no longer active.- Specified by:
afterRollbackComplete
in interfaceEndTransactionListener
- See Also:
TransactionEvent.AFTER_ROLLBACK_COMPLETE
-
beforeFlush
public void beforeFlush(TransactionEvent event)
Description copied from interface:FlushTransactionListener
Notification that a transaction is about to flush all object changes.- Specified by:
beforeFlush
in interfaceFlushTransactionListener
- See Also:
TransactionEvent.BEFORE_FLUSH
-
afterFlush
public void afterFlush(TransactionEvent event)
Description copied from interface:FlushTransactionListener
Notification that a transaction has flushed all object changes.- Specified by:
afterFlush
in interfaceFlushTransactionListener
- See Also:
TransactionEvent.AFTER_FLUSH
-
afterStateTransitions
public void afterStateTransitions(TransactionEvent event)
Description copied from interface:EndTransactionListener
Notification that state transitions are complete.- Specified by:
afterStateTransitions
in interfaceEndTransactionListener
- See Also:
TransactionEvent.AFTER_STATE_TRANSITIONS
-
getPersistenceCapable
protected PersistenceCapable getPersistenceCapable(LifecycleEvent evt)
Extracts the persistence capable instance from the source of the given event.- Returns:
- null if an instance can not be extracted.
-
getBroker
protected Broker getBroker(PersistenceCapable pc)
Extracts the broker from the given persistence capable instance.- Parameters:
pc
- a persistence capable instance- Returns:
- null if a Broker can notbe extracted
-
isAuditable
protected boolean isAuditable(AuditableOperation op, StateManagerImpl sm)
Affirms if the given state manager is auditable for the given operation.- Parameters:
op
- an auditable operation
-
-