DATACMNS-532 - Added support for default methods on repository interfaces.

DefaultRepositoryInformation now excludes default methods from the query methods it detects. RepositoryFactorySupport adds a special MethodInterceptor to the proxy which handles the invocation of default methods.

Related tickets: DATACMNS-535.
This commit is contained in:
Oliver Gierke
2014-07-05 16:55:56 +02:00
parent 6f79d9d727
commit 15597d35dc
3 changed files with 72 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ package org.springframework.data.util;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.springframework.beans.BeanUtils;
import org.springframework.core.annotation.AnnotationUtils;
@@ -51,6 +53,18 @@ public class ReflectionUtils {
}
}
/**
* Back-port of Java 8's {@code isDefault()} method on {@link Method}.
*
* @param method must not be {@literal null}.
* @return
*/
public static boolean isDefaultMethod(Method method) {
return ((method.getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC)
&& method.getDeclaringClass().isInterface();
}
/**
* A {@link FieldFilter} that has a description.
*