public class AutoTimestampEventListener extends AbstractPersistenceEventListener implements MappingContextListener, org.springframework.context.ApplicationContextAware
An event listener that adds support for GORM-style auto-timestamping and auditing
| Modifiers | Name | Description |
|---|---|---|
static class |
AutoTimestampEventListener.TimestampSuppression |
An immutable snapshot of a thread's temporary timestamp suppression state, captured with AutoTimestampEventListener.captureTimestampSuppression and applied on another thread with AutoTimestampEventListener.withTimestampSuppression. |
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
DATE_CREATED_PROPERTY |
|
static java.lang.String |
LAST_UPDATED_PROPERTY |
|
boolean |
cacheAutoTimestampAnnotations |
|
protected java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> |
entitiesWithCreatedBy |
|
protected java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> |
entitiesWithDateCreated |
|
protected java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> |
entitiesWithLastUpdated |
|
protected java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> |
entitiesWithUpdatedBy |
|
boolean |
insertOverwrite |
|
protected java.util.Collection<java.lang.String> |
uninitializedEntities |
| Fields inherited from class | Fields |
|---|---|
class AbstractPersistenceEventListener |
datastore |
| Constructor and description |
|---|
AutoTimestampEventListener(Datastore datastore) |
protected AutoTimestampEventListener(MappingContext mappingContext) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
beforeInsert(PersistentEntity entity, EntityAccess ea) |
|
public boolean |
beforeUpdate(PersistentEntity entity, EntityAccess ea) |
|
public AutoTimestampEventListener.TimestampSuppression |
captureTimestampSuppression()Captures the timestamp suppression state currently active on the calling thread, so that it can be re-applied on another thread with withTimestampSuppression(TimestampSuppression, Runnable). |
|
public AuditorAware<?> |
getAuditorAware() |
|
protected java.util.Set<java.lang.String> |
getCreatedByPropertyNames(java.lang.String entityName) |
|
protected java.util.Set<java.lang.String> |
getDateCreatedPropertyNames(java.lang.String entityName) |
|
protected java.util.Set<java.lang.String> |
getLastUpdatedPropertyNames(java.lang.String entityName) |
|
public TimestampProvider |
getTimestampProvider() |
|
protected java.util.Set<java.lang.String> |
getUpdatedByPropertyNames(java.lang.String entityName) |
|
protected void |
initForMappingContext(MappingContext mappingContext) |
|
protected void |
onPersistenceEvent(AbstractPersistenceEvent event) |
|
public void |
persistentEntityAdded(PersistentEntity entity) |
|
public void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
|
public void |
setAuditorAware(AuditorAware<?> auditorAware) |
|
public void |
setTimestampProvider(TimestampProvider timestampProvider) |
|
protected void |
storeAuditorAvailability(java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> auditorAvailabilityMap, PersistentEntity persistentEntity, PersistentProperty<?> property) |
|
protected void |
storeDateCreatedAndLastUpdatedInfo(PersistentEntity persistentEntity) |
|
protected void |
storeTimestampAvailability(java.util.Map<java.lang.String, java.util.Optional<java.util.Set<java.lang.String>>> timestampAvailabilityMap, PersistentEntity persistentEntity, PersistentProperty<?> property) |
|
public boolean |
supportsEventType(java.lang.Class<? extends org.springframework.context.ApplicationEvent> eventType) |
|
public void |
withTimestampSuppression(AutoTimestampEventListener.TimestampSuppression suppression, java.lang.Runnable runnable)Executes the runnable with the given captured suppression state installed on the calling thread, restoring the thread's previous suppression state afterwards, even when the runnable throws. |
|
public void |
withoutDateCreated(java.lang.Runnable runnable)Temporarily disables the date created processing during the execution of the runnable. |
|
public void |
withoutDateCreated(java.util.List<java.lang.Class> classes, java.lang.Runnable runnable)Temporarily disables the date created processing only on the provided classes during the execution of the runnable. |
|
public void |
withoutDateCreated(java.lang.Class clazz, java.lang.Runnable runnable)Temporarily disables the date created processing only on the provided class during the execution of the runnable. |
|
public void |
withoutLastUpdated(java.lang.Runnable runnable)Temporarily disables the last updated processing during the execution of the runnable. |
|
public void |
withoutLastUpdated(java.util.List<java.lang.Class> classes, java.lang.Runnable runnable)Temporarily disables the last updated processing only on the provided classes during the execution of the runnable. |
|
public void |
withoutLastUpdated(java.lang.Class clazz, java.lang.Runnable runnable)Temporarily disables the last updated processing only on the provided class during the execution of the runnable. |
|
public void |
withoutTimestamps(java.lang.Runnable runnable)Temporarily disables the timestamp processing during the execution of the runnable. |
|
public void |
withoutTimestamps(java.util.List<java.lang.Class> classes, java.lang.Runnable runnable)Temporarily disables the timestamp processing only on the provided classes during the execution of the runnable. |
|
public void |
withoutTimestamps(java.lang.Class clazz, java.lang.Runnable runnable)Temporarily disables the timestamp processing during the execution of the runnable. |
| Methods inherited from class | Name |
|---|---|
class AbstractPersistenceEventListener |
getOrder, isValidSource, onApplicationEvent, onPersistenceEvent, supportsSourceType |
Captures the timestamp suppression state currently active on the calling thread, so that
it can be re-applied on another thread with
withTimestampSuppression(TimestampSuppression, Runnable). Because the
withoutTimestamps, withoutDateCreated and withoutLastUpdated
windows only affect the calling thread, work handed off to other threads (an executor,
a reactive scheduler) is not suppressed unless the captured state is propagated to the
executing thread.
The returned snapshot is immutable and may be applied on any number of threads, concurrently, including after the originating window has closed.
Executes the runnable with the given captured suppression state installed on the calling thread, restoring the thread's previous suppression state afterwards, even when the runnable throws. The snapshot replaces any suppression already active on the calling thread for the duration of the runnable.
suppression - The state captured by captureTimestampSuppression()runnable - The code to execute with the captured suppression state appliedTemporarily disables the date created processing during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
runnable - The code to execute while the date created listener is disabledTemporarily disables the date created processing only on the provided classes during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
classes - Which classes to disable the date created processing forrunnable - The code to execute while the date created listener is disabledTemporarily disables the date created processing only on the provided class during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
clazz - Which class to disable the date created processing forrunnable - The code to execute while the date created listener is disabledTemporarily disables the last updated processing during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
runnable - The code to execute while the last updated listener is disabledTemporarily disables the last updated processing only on the provided classes during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
classes - Which classes to disable the last updated processing forrunnable - The code to execute while the last updated listener is disabledTemporarily disables the last updated processing only on the provided class during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
clazz - Which class to disable the last updated processing forrunnable - The code to execute while the last updated listener is disabledTemporarily disables the timestamp processing during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
runnable - The code to execute while the timestamp listeners are disabledTemporarily disables the timestamp processing only on the provided classes during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
classes - Which classes to disable the timestamp processing forrunnable - The code to execute while the timestamp listeners are disabledTemporarily disables the timestamp processing during the execution of the runnable. The processing is only disabled for the calling thread; concurrently executing threads are unaffected.
clazz - Which class to disable the timestamp processing forrunnable - The code to execute while the timestamp listeners are disabled