|
|
|
@ -182,17 +182,12 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser { |
|
|
|
|
|
|
|
|
|
|
|
if (element.hasAttribute(SCOPED_PROXY_ATTRIBUTE)) { |
|
|
|
if (element.hasAttribute(SCOPED_PROXY_ATTRIBUTE)) { |
|
|
|
String mode = element.getAttribute(SCOPED_PROXY_ATTRIBUTE); |
|
|
|
String mode = element.getAttribute(SCOPED_PROXY_ATTRIBUTE); |
|
|
|
if ("targetClass".equals(mode)) { |
|
|
|
switch (mode) { |
|
|
|
scanner.setScopedProxyMode(ScopedProxyMode.TARGET_CLASS); |
|
|
|
case "targetClass" -> scanner.setScopedProxyMode(ScopedProxyMode.TARGET_CLASS); |
|
|
|
} |
|
|
|
case "interfaces" -> scanner.setScopedProxyMode(ScopedProxyMode.INTERFACES); |
|
|
|
else if ("interfaces".equals(mode)) { |
|
|
|
case "no" -> scanner.setScopedProxyMode(ScopedProxyMode.NO); |
|
|
|
scanner.setScopedProxyMode(ScopedProxyMode.INTERFACES); |
|
|
|
default -> |
|
|
|
} |
|
|
|
throw new IllegalArgumentException("scoped-proxy only supports 'no', 'interfaces' and 'targetClass'"); |
|
|
|
else if ("no".equals(mode)) { |
|
|
|
|
|
|
|
scanner.setScopedProxyMode(ScopedProxyMode.NO); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
throw new IllegalArgumentException("scoped-proxy only supports 'no', 'interfaces' and 'targetClass'"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -234,28 +229,28 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser { |
|
|
|
String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); |
|
|
|
String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); |
|
|
|
String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); |
|
|
|
String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); |
|
|
|
expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); |
|
|
|
expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); |
|
|
|
if ("annotation".equals(filterType)) { |
|
|
|
switch (filterType) { |
|
|
|
return new AnnotationTypeFilter((Class<Annotation>) ClassUtils.forName(expression, classLoader)); |
|
|
|
case "annotation" -> { |
|
|
|
} |
|
|
|
return new AnnotationTypeFilter((Class<Annotation>) ClassUtils.forName(expression, classLoader)); |
|
|
|
else if ("assignable".equals(filterType)) { |
|
|
|
|
|
|
|
return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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 = ClassUtils.forName(expression, classLoader); |
|
|
|
|
|
|
|
if (!TypeFilter.class.isAssignableFrom(filterClass)) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
|
|
|
"Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return (TypeFilter) BeanUtils.instantiateClass(filterClass); |
|
|
|
case "assignable" -> { |
|
|
|
} |
|
|
|
return new AssignableTypeFilter(ClassUtils.forName(expression, classLoader)); |
|
|
|
else { |
|
|
|
} |
|
|
|
throw new IllegalArgumentException("Unsupported filter type: " + filterType); |
|
|
|
case "aspectj" -> { |
|
|
|
|
|
|
|
return new AspectJTypeFilter(expression, classLoader); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case "regex" -> { |
|
|
|
|
|
|
|
return new RegexPatternTypeFilter(Pattern.compile(expression)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case "custom" -> { |
|
|
|
|
|
|
|
Class<?> filterClass = ClassUtils.forName(expression, classLoader); |
|
|
|
|
|
|
|
if (!TypeFilter.class.isAssignableFrom(filterClass)) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException( |
|
|
|
|
|
|
|
"Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (TypeFilter) BeanUtils.instantiateClass(filterClass); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default -> throw new IllegalArgumentException("Unsupported filter type: " + filterType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|