DATACMNS-466 - More aggressive checks for the correct Spring version.
We now actively check that the a method in a Spring class we rely on to be public actually is public and throw an exception pointing to the offending JAR in an exception that's thrown otherwise.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,6 +44,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class RepositoryComponentProvider extends ClassPathScanningCandidateComponentProvider {
|
||||
|
||||
private static final String METHOD_NOT_PUBLIC = "AnnotationConfigUtils.processCommonDefinitionAnnotations(…) is not public! Make sure you're using Spring 3.2.5 or better. The class was loaded from %s.";
|
||||
|
||||
private boolean considerNestedRepositoryInterfaces;
|
||||
|
||||
/**
|
||||
@@ -57,6 +59,8 @@ class RepositoryComponentProvider extends ClassPathScanningCandidateComponentPro
|
||||
|
||||
super(false);
|
||||
|
||||
assertRequiredSpringVersionPresent();
|
||||
|
||||
Assert.notNull(includeFilters);
|
||||
|
||||
if (includeFilters.iterator().hasNext()) {
|
||||
@@ -142,6 +146,20 @@ class RepositoryComponentProvider extends ClassPathScanningCandidateComponentPro
|
||||
this.considerNestedRepositoryInterfaces = considerNestedRepositoryInterfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure {@link AnnotationConfigUtils#processCommonDefinitionAnnotations(AnnotatedBeanDefinition) is public and
|
||||
* indicates the offending JAR if not.
|
||||
*/
|
||||
private static void assertRequiredSpringVersionPresent() {
|
||||
|
||||
try {
|
||||
AnnotationConfigUtils.class.getMethod("processCommonDefinitionAnnotations", AnnotatedBeanDefinition.class);
|
||||
} catch (NoSuchMethodException o_O) {
|
||||
throw new IllegalStateException(String.format(METHOD_NOT_PUBLIC, AnnotationConfigUtils.class
|
||||
.getProtectionDomain().getCodeSource().getLocation()), o_O);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link org.springframework.core.type.filter.TypeFilter} that only matches interfaces. Thus setting this up makes
|
||||
* only sense providing an interface type as {@code targetType}.
|
||||
|
||||
Reference in New Issue
Block a user