org.apache.openjpa.kernel
Class AuditManager

java.lang.Object
  extended by org.apache.openjpa.kernel.InMemorySavepointManager
      extended by 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 laoding 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
    AuditManager(Auditor auditor)
               
     
    Method Summary
     void afterBegin(TransactionEvent event)
              ----------------------------------------------------------------------- Transaction callbacks.
     void 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.
     Set<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(Class<?> cls)
              Records all auditable classes in operation-specific sets.
     
    Methods inherited from class org.apache.openjpa.kernel.InMemorySavepointManager
    getPreFlush, newSavepoint, setPreFlush, supportsIncrementalFlush
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    AuditManager

    public AuditManager(Auditor auditor)
    Method Detail

    register

    public void register(Class<?> cls)
    Records all auditable classes in operation-specific sets.

    Specified by:
    register in interface PCRegistry.RegisterClassListener

    getAuditor

    public Auditor getAuditor()

    getAuditedTypes

    public Set<Class<?>> getAuditedTypes()

    afterBegin

    public void afterBegin(TransactionEvent event)
    ----------------------------------------------------------------------- Transaction callbacks. -----------------------------------------------------------------------

    Specified by:
    afterBegin in interface BeginTransactionListener
    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 interface EndTransactionListener
    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 interface EndTransactionListener
    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 interface EndTransactionListener
    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 interface EndTransactionListener
    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 interface EndTransactionListener
    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 interface FlushTransactionListener
    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 interface FlushTransactionListener
    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 interface EndTransactionListener
    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
    sm -
    Returns:


    Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.