DATACMNS-1113 - Domain event publication now happens for all methods starting with save….

Previously we explicitly intercepted repository methods named save(…) and saveAll(…) which unfortunately results in custom variants of that (e.g. JpaRepository's saveAndFlush(…)) not causing event publication.

We now publish events for methods whose names start with save….
This commit is contained in:
Oliver Gierke
2017-05-11 09:20:36 +02:00
parent 044a0c07c1
commit 5d08bd6273
2 changed files with 23 additions and 3 deletions

View File

@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Stream;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
@@ -90,7 +89,7 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
Object result = invocation.proceed();
if (!Stream.of("save", "saveAll").anyMatch(it -> invocation.getMethod().getName().equals(it))) {
if (!invocation.getMethod().getName().startsWith("save")) {
return result;
}