Commit 6dc3d683 authored by Markus Koschany's avatar Markus Koschany

New upstream version 4.3.14

parent 1cb0ad9c
......@@ -51,8 +51,8 @@ configure(allprojects) { project ->
ext.hibval5Version = "5.2.5.Final"
ext.hsqldbVersion = "2.3.4"
ext.httpasyncVersion = "4.1.3"
ext.httpclientVersion = "4.5.3"
ext.jackson2Version = "2.8.10"
ext.httpclientVersion = "4.5.5"
ext.jackson2Version = "2.8.11"
ext.jasperreportsVersion = "6.2.1" // our tests fail with JR-internal NPEs against 6.2.2 and higher
ext.javamailVersion = "1.5.6"
ext.jettyVersion = "9.3.14.v20161028" // as of 9.3.15, Jetty has hard Servlet 3.1 requirement
......@@ -62,7 +62,7 @@ configure(allprojects) { project ->
ext.jtaVersion = "1.2"
ext.junitVersion = "4.12"
ext.log4jVersion = "1.2.17"
ext.nettyVersion = "4.1.17.Final"
ext.nettyVersion = "4.1.20.Final"
ext.okhttpVersion = "2.7.5"
ext.okhttp3Version = "3.8.1"
ext.openjpaVersion = "2.4.2"
......@@ -75,7 +75,7 @@ configure(allprojects) { project ->
ext.testngVersion = "6.9.10"
ext.tiles2Version = "2.2.2"
ext.tiles3Version = "3.0.7"
ext.tomcatVersion = "8.5.23"
ext.tomcatVersion = "8.5.27"
ext.tyrusVersion = "1.3.5" // constrained by WebLogic 12.1.3 support
ext.undertowVersion = "1.3.33.Final"
ext.xmlunitVersion = "1.6"
......@@ -293,7 +293,7 @@ project("spring-core") {
// both into the spring-core jar. cglib 3.2 itself depends on asm 5.x and is therefore
// further transformed by the JarJar task to depend on org.springframework.asm; this
// avoids including two different copies of asm unnecessarily.
def cglibVersion = "3.2.5"
def cglibVersion = "3.2.6"
def objenesisVersion = "2.6"
configurations {
......
version=4.3.13.RELEASE
version=4.3.14.RELEASE
......@@ -148,7 +148,7 @@ public class AspectMetadata implements Serializable {
}
/**
* Return the aspect class.
* Return the aspect name.
*/
public String getAspectName() {
return this.aspectName;
......
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
......@@ -506,13 +506,14 @@ public abstract class BeanUtils {
/**
* Check if the given type represents a "simple" value type:
* a primitive, a String or other CharSequence, a Number, a Date,
* a primitive, an enum, a String or other CharSequence, a Number, a Date,
* a URI, a URL, a Locale or a Class.
* @param clazz the type to check
* @return whether the given type represents a "simple" value type
*/
public static boolean isSimpleValueType(Class<?> clazz) {
return (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
return (ClassUtils.isPrimitiveOrWrapper(clazz) ||
Enum.class.isAssignableFrom(clazz) ||
CharSequence.class.isAssignableFrom(clazz) ||
Number.class.isAssignableFrom(clazz) ||
Date.class.isAssignableFrom(clazz) ||
......
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
......@@ -339,10 +339,10 @@ public class CachedIntrospectionResults {
PropertyDescriptor getPropertyDescriptor(String name) {
PropertyDescriptor pd = this.propertyDescriptorCache.get(name);
if (pd == null && StringUtils.hasLength(name)) {
// Same lenient fallback checking as in PropertyTypeDescriptor...
pd = this.propertyDescriptorCache.get(name.substring(0, 1).toLowerCase() + name.substring(1));
// Same lenient fallback checking as in Property...
pd = this.propertyDescriptorCache.get(StringUtils.uncapitalize(name));
if (pd == null) {
pd = this.propertyDescriptorCache.get(name.substring(0, 1).toUpperCase() + name.substring(1));
pd = this.propertyDescriptorCache.get(StringUtils.capitalize(name));
}
}
return (pd == null || pd instanceof GenericTypeAwarePropertyDescriptor ? pd :
......
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
......@@ -35,6 +35,7 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.util.ClassUtils;
import org.springframework.util.NumberUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
/**
......@@ -353,6 +354,7 @@ class TypeConverterDelegate {
// to be checked, hence we don't return it right away.
try {
Field enumField = requiredType.getField(trimmedValue);
ReflectionUtils.makeAccessible(enumField);
convertedValue = enumField.get(null);
}
catch (Throwable ex) {
......
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
......@@ -1384,8 +1384,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
catch (ClassNotFoundException ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
}
catch (LinkageError ex) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), ex);
catch (LinkageError err) {
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);
}
}
......
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
......@@ -31,11 +31,11 @@ import static org.junit.Assert.*;
* @author Juergen Hoeller
* @author Chris Beams
*/
public final class BeanWrapperEnumTests {
public class BeanWrapperEnumTests {
@Test
public void testCustomEnum() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", "VALUE_1");
assertEquals(CustomEnum.VALUE_1, gb.getCustomEnum());
......@@ -43,7 +43,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumWithNull() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", null);
assertEquals(null, gb.getCustomEnum());
......@@ -51,7 +51,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumWithEmptyString() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnum", "");
assertEquals(null, gb.getCustomEnum());
......@@ -59,7 +59,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumArrayWithSingleValue() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", "VALUE_1");
assertEquals(1, gb.getCustomEnumArray().length);
......@@ -68,7 +68,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumArrayWithMultipleValues() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", new String[] {"VALUE_1", "VALUE_2"});
assertEquals(2, gb.getCustomEnumArray().length);
......@@ -78,7 +78,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumArrayWithMultipleValuesAsCsv() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2");
assertEquals(2, gb.getCustomEnumArray().length);
......@@ -88,7 +88,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumSetWithSingleValue() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", "VALUE_1");
assertEquals(1, gb.getCustomEnumSet().size());
......@@ -97,7 +97,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"});
assertEquals(2, gb.getCustomEnumSet().size());
......@@ -107,7 +107,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumSetWithMultipleValuesAsCsv() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSet", "VALUE_1,VALUE_2");
assertEquals(2, gb.getCustomEnumSet().size());
......@@ -117,7 +117,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testCustomEnumSetWithGetterSetterMismatch() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("customEnumSetMismatch", new String[] {"VALUE_1", "VALUE_2"});
assertEquals(2, gb.getCustomEnumSet().size());
......@@ -127,7 +127,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testStandardEnumSetWithMultipleValues() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
assertNull(gb.getStandardEnumSet());
......@@ -139,7 +139,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testStandardEnumSetWithAutoGrowing() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setAutoGrowNestedPaths(true);
assertNull(gb.getStandardEnumSet());
......@@ -149,11 +149,11 @@ public final class BeanWrapperEnumTests {
@Test
public void testStandardEnumMapWithMultipleValues() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setConversionService(new DefaultConversionService());
assertNull(gb.getStandardEnumMap());
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
Map<String, Integer> map = new LinkedHashMap<>();
map.put("VALUE_1", 1);
map.put("VALUE_2", 2);
bw.setPropertyValue("standardEnumMap", map);
......@@ -164,7 +164,7 @@ public final class BeanWrapperEnumTests {
@Test
public void testStandardEnumMapWithAutoGrowing() {
GenericBean<?> gb = new GenericBean<Object>();
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setAutoGrowNestedPaths(true);
assertNull(gb.getStandardEnumMap());
......@@ -173,4 +173,32 @@ public final class BeanWrapperEnumTests {
assertEquals(new Integer(1), gb.getStandardEnumMap().get(CustomEnum.VALUE_1));
}
@Test
public void testNonPublicEnum() {
NonPublicEnumHolder holder = new NonPublicEnumHolder();
BeanWrapper bw = new BeanWrapperImpl(holder);
bw.setPropertyValue("nonPublicEnum", "VALUE_1");
assertEquals(NonPublicEnum.VALUE_1, holder.getNonPublicEnum());
}
enum NonPublicEnum {
VALUE_1, VALUE_2;
}
static class NonPublicEnumHolder {
private NonPublicEnum nonPublicEnum;
public NonPublicEnum getNonPublicEnum() {
return nonPublicEnum;
}
public void setNonPublicEnum(NonPublicEnum nonPublicEnum) {
this.nonPublicEnum = nonPublicEnum;
}
}
}
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
......@@ -2735,6 +2735,16 @@ public class DefaultListableBeanFactoryTests {
assertSame(Optional.empty(), bf.getBean(Optional.class));
}
@Test
public void testNonPublicEnum() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(NonPublicEnumHolder.class);
bd.getConstructorArgumentValues().addGenericArgumentValue("VALUE_1");
bf.registerBeanDefinition("holderBean", bd);
NonPublicEnumHolder holder = (NonPublicEnumHolder) bf.getBean("holderBean");
assertEquals(NonPublicEnum.VALUE_1, holder.getNonPublicEnum());
}
/**
* Test that by-type bean lookup caching is working effectively by searching for a
* bean of type B 10K times within a container having 1K additional beans of type A.
......@@ -3262,4 +3272,24 @@ public class DefaultListableBeanFactoryTests {
}
}
enum NonPublicEnum {
VALUE_1, VALUE_2;
}
static class NonPublicEnumHolder {
final NonPublicEnum nonPublicEnum;
public NonPublicEnumHolder(NonPublicEnum nonPublicEnum) {
this.nonPublicEnum = nonPublicEnum;
}
public NonPublicEnum getNonPublicEnum() {
return nonPublicEnum;
}
}
}
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2018 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.
......@@ -35,7 +35,7 @@ import static org.springframework.tests.TestResourceUtils.*;
* @author Chris Beams
* @since 2.0
*/
public final class CustomProblemReporterTests {
public class CustomProblemReporterTests {
private static final Resource CONTEXT = qualifiedResource(CustomProblemReporterTests.class, "context.xml");
......@@ -66,10 +66,9 @@ public final class CustomProblemReporterTests {
private static class CollatingProblemReporter implements ProblemReporter {
private List<Problem> errors = new ArrayList<Problem>();
private List<Problem> warnings = new ArrayList<Problem>();
private final List<Problem> errors = new ArrayList<>();
private final List<Problem> warnings = new ArrayList<>();
@Override
public void fatal(Problem problem) {
......
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
......@@ -33,6 +33,7 @@ import org.springframework.cache.interceptor.KeyGenerator;
* for detailed instructions.
*
* @author Chris Beams
* @author Stephane Nicoll
* @since 3.1
* @see EnableCaching
* @see CachingConfigurerSupport
......@@ -67,8 +68,8 @@ public interface CachingConfigurer {
* Return the {@link CacheResolver} bean to use to resolve regular caches for
* annotation-driven cache management. This is an alternative and more powerful
* option of specifying the {@link CacheManager} to use.
* <p>If both a {@link #cacheManager()} and {@link #cacheResolver()} are set, the
* cache manager is ignored.
* <p>If both a {@link #cacheManager()} and {@code #cacheResolver()} are set,
* the cache manager is ignored.
* <p>Implementations must explicitly declare
* {@link org.springframework.context.annotation.Bean @Bean}, e.g.
* <pre class="code">
......
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
......@@ -53,22 +53,20 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Base class for caching aspects, such as the {@link CacheInterceptor}
* or an AspectJ aspect.
* Base class for caching aspects, such as the {@link CacheInterceptor} or an
* AspectJ aspect.
*
* <p>This enables the underlying Spring caching infrastructure to be
* used easily to implement an aspect for any aspect system.
* <p>This enables the underlying Spring caching infrastructure to be used easily
* to implement an aspect for any aspect system.
*
* <p>Subclasses are responsible for calling methods in this class in
* the correct order.
* <p>Subclasses are responsible for calling relevant methods in the correct order.
*
* <p>Uses the <b>Strategy</b> design pattern. A {@link CacheResolver}
* implementation will resolve the actual cache(s) to use, and a
* {@link CacheOperationSource} is used for determining caching
* operations.
* <p>Uses the <b>Strategy</b> design pattern. A {@link CacheOperationSource} is
* used for determining caching operations, a {@link KeyGenerator} will build the
* cache keys, and a {@link CacheResolver} will resolve the actual cache(s) to use.
*
* <p>A cache aspect is serializable if its {@code CacheResolver} and
* {@code CacheOperationSource} are serializable.
* <p>Note: A cache aspect is serializable but does not perform any actual caching
* after deserialization.
*
* @author Costin Leau
* @author Juergen Hoeller
......@@ -132,7 +130,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
/**
* Set the default {@link KeyGenerator} that this cache aspect should delegate to
* if no specific key generator has been set for the operation.
* <p>The default is a {@link SimpleKeyGenerator}
* <p>The default is a {@link SimpleKeyGenerator}.
*/
public void setKeyGenerator(KeyGenerator keyGenerator) {
this.keyGenerator = keyGenerator;
......@@ -145,22 +143,12 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
return this.keyGenerator;
}
/**
* Set the {@link CacheManager} to use to create a default {@link CacheResolver}.
* Replace the current {@link CacheResolver}, if any.
* @see #setCacheResolver(CacheResolver)
* @see SimpleCacheResolver
*/
public void setCacheManager(CacheManager cacheManager) {
this.cacheResolver = new SimpleCacheResolver(cacheManager);
}
/**
* Set the default {@link CacheResolver} that this cache aspect should delegate
* to if no specific cache resolver has been set for the operation.
* <p>The default resolver resolves the caches against their names and the
* default cache manager.
* @see #setCacheManager(org.springframework.cache.CacheManager)
* @see #setCacheManager
* @see SimpleCacheResolver
*/
public void setCacheResolver(CacheResolver cacheResolver) {
......@@ -174,6 +162,16 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
return this.cacheResolver;
}
/**
* Set the {@link CacheManager} to use to create a default {@link CacheResolver}.
* Replace the current {@link CacheResolver}, if any.
* @see #setCacheResolver
* @see SimpleCacheResolver
*/
public void setCacheManager(CacheManager cacheManager) {
this.cacheResolver = new SimpleCacheResolver(cacheManager);
}
/**
* Set the containing {@link BeanFactory} for {@link CacheManager} and other
* service lookups.
......
/*
* Copyright 2010-2017 the original author or authors.
* Copyright 2002-2018 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.
......@@ -19,6 +19,9 @@ package org.springframework.cache.interceptor;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.SmartInitializingSingleton;
/**
* Proxy factory bean for simplified declarative caching handling.
......@@ -41,24 +44,26 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
* @see CacheInterceptor
*/
@SuppressWarnings("serial")
public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean {
public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean
implements BeanFactoryAware, SmartInitializingSingleton {
private final CacheInterceptor cachingInterceptor = new CacheInterceptor();
private final CacheInterceptor cacheInterceptor = new CacheInterceptor();
private Pointcut pointcut = Pointcut.TRUE;
/**
* Set the sources used to find cache operations.
* Set one or more sources to find cache operations.
* @see CacheInterceptor#setCacheOperationSources
*/
public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) {
this.cachingInterceptor.setCacheOperationSources(cacheOperationSources);
this.cacheInterceptor.setCacheOperationSources(cacheOperationSources);
}
/**
* Set a pointcut, i.e a bean that can cause conditional invocation
* of the CacheInterceptor depending on method and attributes passed.
* Note: Additional interceptors are always invoked.
* Set a pointcut, i.e. a bean that triggers conditional invocation of the
* {@link CacheInterceptor} depending on the method and attributes passed.
* <p>Note: Additional interceptors are always invoked.
* @see #setPreInterceptors
* @see #setPostInterceptors
*/
......@@ -66,10 +71,21 @@ public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean {
this.pointcut = pointcut;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.cacheInterceptor.setBeanFactory(beanFactory);
}
@Override
public void afterSingletonsInstantiated() {
this.cacheInterceptor.afterSingletonsInstantiated();
}
@Override
protected Object createMainInterceptor() {
this.cachingInterceptor.afterPropertiesSet();
return new DefaultPointcutAdvisor(this.pointcut, this.cachingInterceptor);
this.cacheInterceptor.afterPropertiesSet();
return new DefaultPointcutAdvisor(this.pointcut, this.cacheInterceptor);
}
}
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
......@@ -25,7 +25,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
......@@ -40,6 +39,7 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.springframework.core.type.filter.TypeFilter;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
......@@ -212,6 +212,10 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
scanner.addExcludeFilter(typeFilter);
}
}
catch (ClassNotFoundException ex) {
parserContext.getReaderContext().warning(
"Ignoring non-present type filter class: " + ex, parserContext.extractSource(element));
}
catch (Exception ex) {
parserContext.getReaderContext().error(
ex.getMessage(), parserContext.extractSource(element), ex.getCause());
......@@ -221,37 +225,34 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
}
@SuppressWarnings("unchecked")
protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader, ParserContext parserContext) {
protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader,
ParserContext parserContext) throws ClassNotFoundException {
String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression);
try {
if ("annotation".equals(filterType)) {
return new AnnotationTypeFilter((Class<Annotation>) classLoader.loadClass(expression));
}
else if ("assignable".equals(filterType)) {
return new AssignableTypeFilter(classLoader.loadClass(expression));
}
else if ("aspectj".equals(filterType)) {
return new AspectJTypeFilter(expression, classLoader);
}
else if ("regex".equals(filterType)) {
return new RegexPatternTypeFilter(Pattern.compile(expression));
}
else if ("custom".equals(filterType)) {
Class<?> filterClass = classLoader.loadClass(expression);
if (!TypeFilter.class.isAssignableFrom(filterClass)) {
throw new IllegalArgumentException(
"Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression);
}
return (TypeFilter) BeanUtils.instantiateClass(filterClass);
}
else {
throw new IllegalArgumentException("Unsupported filter type: " + filterType);
if ("annotation".equals(filterType)) {
return new AnnotationTypeFilter((Class<Annotation>) ClassUtils.forName(expression, classLoader));
}
else if ("assignable".equals(filterType)) {
return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader));
}