Add factory method to Reactive-/IsNewAwareAuditingHandler.
By providing a factory method that accepts the MappingContext we can avoid the creation of additional support beans during the configuration phase for store modules implementing auditing. See: #2593
This commit is contained in:
@@ -36,7 +36,7 @@ public class IsNewAwareAuditingHandler extends AuditingHandler {
|
||||
private final PersistentEntities entities;
|
||||
|
||||
/**
|
||||
* Creates a new {@link IsNewAwareAuditingHandler} for the given {@link MappingContext}.
|
||||
* Creates a new {@link IsNewAwareAuditingHandler} for the given {@link PersistentEntities}.
|
||||
*
|
||||
* @param entities must not be {@literal null}.
|
||||
* @since 1.10
|
||||
@@ -48,6 +48,16 @@ public class IsNewAwareAuditingHandler extends AuditingHandler {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that creates a new {@link IsNewAwareAuditingHandler} for the given {@link MappingContext}.
|
||||
*
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
* @since 3.0
|
||||
*/
|
||||
public static IsNewAwareAuditingHandler from(MappingContext<?,?> mappingContext) {
|
||||
return new IsNewAwareAuditingHandler(PersistentEntities.of(mappingContext));
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the given object created or modified based on {@link PersistentEntity#isNew(Object)}. Will route the calls to
|
||||
* {@link #markCreated(Object)} and {@link #markModified(Object)} accordingly.
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ReactiveIsNewAwareAuditingHandler extends ReactiveAuditingHandler {
|
||||
private final PersistentEntities entities;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ReactiveIsNewAwareAuditingHandler} for the given {@link MappingContext}.
|
||||
* Creates a new {@link ReactiveIsNewAwareAuditingHandler} for the given {@link PersistentEntities}.
|
||||
*
|
||||
* @param entities must not be {@literal null}.
|
||||
*/
|
||||
@@ -48,6 +48,16 @@ public class ReactiveIsNewAwareAuditingHandler extends ReactiveAuditingHandler {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method that creates a new {@link ReactiveIsNewAwareAuditingHandler} for the given {@link MappingContext}.
|
||||
*
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
* @since 3.0
|
||||
*/
|
||||
public static ReactiveIsNewAwareAuditingHandler from(MappingContext<?,?> mappingContext) {
|
||||
return new ReactiveIsNewAwareAuditingHandler(PersistentEntities.of(mappingContext));
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the given object created or modified based on {@link PersistentEntity#isNew(Object)}. Will route the calls to
|
||||
* {@link #markCreated(Object)} and {@link #markModified(Object)} accordingly.
|
||||
|
||||
Reference in New Issue
Block a user