File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
src/main/java/org/springframework/data/auditing Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1919
2020import org .apache .commons .logging .Log ;
2121import org .apache .commons .logging .LogFactory ;
22-
2322import org .springframework .beans .factory .InitializingBean ;
2423import org .springframework .data .domain .AuditorAware ;
24+ import org .springframework .data .mapping .context .MappingContext ;
2525import org .springframework .data .mapping .context .PersistentEntities ;
2626import org .springframework .util .Assert ;
2727
@@ -53,6 +53,16 @@ public AuditingHandler(PersistentEntities entities) {
5353 this .auditorAware = Optional .empty ();
5454 }
5555
56+ /**
57+ * Factory method that creates a new {@link AuditingHandler} for the given {@link MappingContext}.
58+ *
59+ * @param mappingContext must not be {@literal null}.
60+ * @since 3.0
61+ */
62+ public static AuditingHandler from (MappingContext <?, ?> mappingContext ) {
63+ return new AuditingHandler (PersistentEntities .of (mappingContext ));
64+ }
65+
5666 /**
5767 * Setter to inject a {@code AuditorAware} component to retrieve the current auditor.
5868 *
Original file line number Diff line number Diff line change 1818import reactor .core .publisher .Mono ;
1919
2020import org .springframework .data .domain .ReactiveAuditorAware ;
21+ import org .springframework .data .mapping .context .MappingContext ;
2122import org .springframework .data .mapping .context .PersistentEntities ;
2223import org .springframework .util .Assert ;
2324
@@ -42,6 +43,16 @@ public ReactiveAuditingHandler(PersistentEntities entities) {
4243 super (entities );
4344 }
4445
46+ /**
47+ * Factory method that creates a new {@link ReactiveAuditingHandler} for the given {@link MappingContext}.
48+ *
49+ * @param mappingContext must not be {@literal null}.
50+ * @since 3.0
51+ */
52+ public static ReactiveAuditingHandler from (MappingContext <?, ?> mappingContext ) {
53+ return new ReactiveAuditingHandler (PersistentEntities .of (mappingContext ));
54+ }
55+
4556 /**
4657 * Setter to inject a {@link ReactiveAuditorAware} component to retrieve the current auditor.
4758 *
You can’t perform that action at this time.
0 commit comments