Spring Data Core

org.springframework.data.auditing
Class AuditingHandler

java.lang.Object
  extended by org.springframework.data.auditing.AuditingHandler
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
IsNewAwareAuditingHandler

public class AuditingHandler
extends Object
implements InitializingBean

Auditing handler to mark entity objects created and modified.

Since:
1.5
Author:
Oliver Gierke

Constructor Summary
AuditingHandler()
          Deprecated. use the constructor taking a MappingContext.
AuditingHandler(MappingContext<? extends PersistentEntity<?,?>,? extends PersistentProperty<?>> mappingContext)
          Creates a new AuditableBeanWrapper using the given MappingContext when looking up auditing metadata via reflection.
 
Method Summary
 void afterPropertiesSet()
           
 void markCreated(Object source)
          Marks the given object as created.
 void markModified(Object source)
          Marks the given object as modified.
 void setAuditorAware(AuditorAware<?> auditorAware)
          Setter to inject a AuditorAware component to retrieve the current auditor.
 void setDateTimeForNow(boolean dateTimeForNow)
          Setter do determine if Auditable.setCreatedDate(DateTime) and Auditable.setLastModifiedDate(DateTime) shall be filled with the current Java time.
 void setDateTimeProvider(DateTimeProvider dateTimeProvider)
          Sets the DateTimeProvider to be used to determine the dates to be set.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuditingHandler

@Deprecated
public AuditingHandler()
Deprecated. use the constructor taking a MappingContext.

Creates a new AuditingHandler.


AuditingHandler

public AuditingHandler(MappingContext<? extends PersistentEntity<?,?>,? extends PersistentProperty<?>> mappingContext)
Creates a new AuditableBeanWrapper using the given MappingContext when looking up auditing metadata via reflection.

Parameters:
mappingContext - must not be null.
Since:
1.8
Method Detail

setAuditorAware

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

Parameters:
auditorAware - must not be null.

setDateTimeForNow

public void setDateTimeForNow(boolean dateTimeForNow)
Setter do determine if Auditable.setCreatedDate(DateTime) and Auditable.setLastModifiedDate(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

setDateTimeProvider

public void setDateTimeProvider(DateTimeProvider dateTimeProvider)
Sets the DateTimeProvider to be used to determine the dates to be set.

Parameters:
dateTimeProvider -

markCreated

public void markCreated(Object source)
Marks the given object as created.

Parameters:
source -

markModified

public void markModified(Object source)
Marks the given object as modified.

Parameters:
source -

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

Spring Data Core

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.