org.synyx.hades.domain.auditing
Class AuditingAdvice<T>

java.lang.Object
  extended by org.synyx.hades.domain.auditing.AuditingAdvice<T>
Type Parameters:
T - the type of the auditing instance

public class AuditingAdvice<T>
extends java.lang.Object

Aspect touching entities being saved. Sets modification date and auditor. If no AuditorAware is set only modification and creation date will be set.

The advice intercepts calls to save methods of GenericDao. It is implemented using Aspect annotations to be suitable for all kinds of aspect weaving. To enable capturing audit data simply register the advice and activate annotation based aspect:

 <aop:aspectj-autoproxy />
 <bean class="org.synyx.hades.domain.support.AuditionAdvice" />
 

Author:
Oliver Gierke - gierke@synyx.de

Constructor Summary
AuditingAdvice()
           
 
Method Summary
 void setAuditorAware(AuditorAware<T> auditorAware)
          Setter to inject a AuditorAware component to retrieve the current auditor.
 void setDateTimeForNow(boolean dateTimeForNow)
          Setter do determine if Auditable.setCreated(DateTime) and Auditable.setLastModified(DateTime) shall be filled with the current Java time.
 void setModifyOnCreation(boolean modifyOnCreation)
          Set this to false if you want to treat entity creation as modification and thus set the current date as modification date, too.
 void touch(Auditable<T,?> auditable)
          Sets modification and creation date and auditor on an auditable entity.
 void touch(java.util.List<Auditable<T,?>> auditables)
          Sets modification and creation date and auditor on a List of Auditables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuditingAdvice

public AuditingAdvice()
Method Detail

setAuditorAware

public void setAuditorAware(AuditorAware<T> auditorAware)
Setter to inject a AuditorAware component to retrieve the current auditor.

Parameters:
auditorAware - the auditorAware to set

setDateTimeForNow

public void setDateTimeForNow(boolean dateTimeForNow)
Setter do determine if Auditable.setCreated(DateTime) and Auditable.setLastModified(DateTime) shall be filled with the current Java time. Defaults to true. One might set this to false to use database features to set entity time.

Parameters:
dateTimeForNow - the dateTimeForNow to set

setModifyOnCreation

public void setModifyOnCreation(boolean modifyOnCreation)
Set this to false if you want to treat entity creation as modification and thus set the current date as modification date, too. Defaults to true.

Parameters:
modifyOnCreation - if modification information shall be set on creation, too

touch

public void touch(Auditable<T,?> auditable)
Sets modification and creation date and auditor on an auditable entity.

Parameters:
auditable -

touch

public void touch(java.util.List<Auditable<T,?>> auditables)
Sets modification and creation date and auditor on a List of Auditables.

Parameters:
auditables -


Copyright © 2009-2010 Synyx GmbH & Co. KG. All Rights Reserved.