moving unit tests from .testsuite -> .context

This commit is contained in:
Chris Beams
2008-12-14 20:13:56 +00:00
parent 87de85ef19
commit 8b2cf634a3
33 changed files with 129 additions and 9 deletions

View File

@@ -0,0 +1,82 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.beans.factory.config;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.ObjectFactory;
/**
* @author Juergen Hoeller
*/
public class SimpleMapScope implements Scope, Serializable {
private final Map map = new HashMap();
private final List callbacks = new LinkedList();
public SimpleMapScope() {
}
public final Map getMap() {
return this.map;
}
public Object get(String name, ObjectFactory objectFactory) {
synchronized (this.map) {
Object scopedObject = this.map.get(name);
if (scopedObject == null) {
scopedObject = objectFactory.getObject();
this.map.put(name, scopedObject);
}
return scopedObject;
}
}
public Object remove(String name) {
synchronized (this.map) {
return this.map.remove(name);
}
}
public void registerDestructionCallback(String name, Runnable callback) {
this.callbacks.add(callback);
}
public Object resolveContextualObject(String key) {
return null;
}
public void close() {
for (Iterator it = this.callbacks.iterator(); it.hasNext();) {
Runnable runnable = (Runnable) it.next();
runnable.run();
}
}
public String getConversationId() {
return null;
}
}

View File

@@ -0,0 +1,306 @@
/*
* Copyright 2002-2007 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.UnsatisfiedDependencyException;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
/**
* @author Mark Fisher
* @author Chris Beams
*/
public class ComponentScanParserBeanDefinitionDefaultsTests {
private static final String TEST_BEAN_NAME = "componentScanParserBeanDefinitionDefaultsTests.DefaultsTestBean";
private static final String LOCATION_PREFIX = "org/springframework/context/annotation/";
@Before
public void setUp() {
DefaultsTestBean.INIT_COUNT = 0;
}
@Test
public void testDefaultLazyInit() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
assertFalse("lazy-init should be false", context.getBeanDefinition(TEST_BEAN_NAME).isLazyInit());
assertEquals("initCount should be 0", 0, DefaultsTestBean.INIT_COUNT);
context.refresh();
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
}
@Test
public void testLazyInitTrue() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitTrueTests.xml");
assertTrue("lazy-init should be true", context.getBeanDefinition(TEST_BEAN_NAME).isLazyInit());
assertEquals("initCount should be 0", 0, DefaultsTestBean.INIT_COUNT);
context.refresh();
assertEquals("bean should not have been instantiated yet", 0, DefaultsTestBean.INIT_COUNT);
context.getBean(TEST_BEAN_NAME);
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
}
@Test
public void testLazyInitFalse() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitFalseTests.xml");
assertFalse("lazy-init should be false", context.getBeanDefinition(TEST_BEAN_NAME).isLazyInit());
assertEquals("initCount should be 0", 0, DefaultsTestBean.INIT_COUNT);
context.refresh();
assertEquals("bean should have been instantiated", 1, DefaultsTestBean.INIT_COUNT);
}
@Test
public void testDefaultAutowire() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("no dependencies should have been autowired", bean.getConstructorDependency());
assertNull("no dependencies should have been autowired", bean.getPropertyDependency1());
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
}
@Test
public void testAutowireNo() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireNoTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("no dependencies should have been autowired", bean.getConstructorDependency());
assertNull("no dependencies should have been autowired", bean.getPropertyDependency1());
assertNull("no dependencies should have been autowired", bean.getPropertyDependency2());
}
@Test
public void testAutowireConstructor() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireConstructorTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNotNull("constructor dependency should have been autowired", bean.getConstructorDependency());
assertEquals("cd", bean.getConstructorDependency().getName());
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency1());
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
}
@Test
public void testAutowireByType() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByTypeTests.xml");
try {
context.refresh();
fail("expected exception due to multiple matches for byType autowiring");
}
catch (UnsatisfiedDependencyException e) {
// expected
}
}
@Test
public void testAutowireByName() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByNameTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("constructor dependency should not have been autowired", bean.getConstructorDependency());
assertNull("propertyDependency1 should not have been autowired", bean.getPropertyDependency1());
assertNotNull("propertyDependency2 should have been autowired", bean.getPropertyDependency2());
assertEquals("pd2", bean.getPropertyDependency2().getName());
}
@Test
public void testDefaultDependencyCheck() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("constructor dependency should not have been autowired", bean.getConstructorDependency());
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency1());
assertNull("property dependencies should not have been autowired", bean.getPropertyDependency2());
}
@Test
public void testDependencyCheckAll() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultDependencyCheckAllTests.xml");
try {
context.refresh();
fail("expected exception due to dependency check");
}
catch (UnsatisfiedDependencyException e) {
// expected
}
}
@Test
public void testDependencyCheckObjectsWithAutowireByName() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultDependencyCheckObjectsWithAutowireByNameTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertNull("constructor dependency should not have been autowired", bean.getConstructorDependency());
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency1());
assertNotNull("property dependencies should have been autowired", bean.getPropertyDependency2());
}
@Test
public void testDefaultInitAndDestroyMethodsNotDefined() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertFalse("bean should not have been initialized", bean.isInitialized());
context.close();
assertFalse("bean should not have been destroyed", bean.isDestroyed());
}
@Test
public void testDefaultInitAndDestroyMethodsDefined() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultInitAndDestroyMethodsTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertTrue("bean should have been initialized", bean.isInitialized());
context.close();
assertTrue("bean should have been destroyed", bean.isDestroyed());
}
@Test
public void testDefaultNonExistingInitAndDestroyMethodsDefined() {
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultNonExistingInitAndDestroyMethodsTests.xml");
context.refresh();
DefaultsTestBean bean = (DefaultsTestBean) context.getBean(TEST_BEAN_NAME);
assertFalse("bean should not have been initialized", bean.isInitialized());
context.close();
assertFalse("bean should not have been destroyed", bean.isDestroyed());
}
private static class DefaultsTestBean {
static int INIT_COUNT;
private ConstructorDependencyTestBean constructorDependency;
private PropertyDependencyTestBean propertyDependency1;
private PropertyDependencyTestBean propertyDependency2;
private boolean initialized;
private boolean destroyed;
public DefaultsTestBean() {
INIT_COUNT++;
}
public DefaultsTestBean(ConstructorDependencyTestBean cdtb) {
this();
this.constructorDependency = cdtb;
}
public void init() {
this.initialized = true;
}
public boolean isInitialized() {
return this.initialized;
}
public void destroy() {
this.destroyed = true;
}
public boolean isDestroyed() {
return this.destroyed;
}
public void setPropertyDependency1(PropertyDependencyTestBean pdtb) {
this.propertyDependency1 = pdtb;
}
public void setPropertyDependency2(PropertyDependencyTestBean pdtb) {
this.propertyDependency2 = pdtb;
}
public ConstructorDependencyTestBean getConstructorDependency() {
return this.constructorDependency;
}
public PropertyDependencyTestBean getPropertyDependency1() {
return this.propertyDependency1;
}
public PropertyDependencyTestBean getPropertyDependency2() {
return this.propertyDependency2;
}
}
private static class PropertyDependencyTestBean {
private String name;
public PropertyDependencyTestBean(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
private static class ConstructorDependencyTestBean {
private String name;
public ConstructorDependencyTestBean(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright 2002-2007 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.config.SimpleMapScope;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import example.scannable.FooService;
import example.scannable.ScopedProxyTestBean;
/**
* @author Mark Fisher
* @author Juergen Hoeller
*/
public class ComponentScanParserScopedProxyTests {
@Test
public void testDefaultScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should not be a proxy
assertFalse(AopUtils.isAopProxy(bean));
}
@Test
public void testNoScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyNoTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should not be a proxy
assertFalse(AopUtils.isAopProxy(bean));
}
@Test
public void testInterfacesScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyInterfacesTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
// should cast to the interface
FooService bean = (FooService) context.getBean("scopedProxyTestBean");
// should be dynamic proxy
assertTrue(AopUtils.isJdkDynamicProxy(bean));
}
@Test
public void testTargetClassScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyTargetClassTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should be a class-based proxy
assertTrue(AopUtils.isCglibProxy(bean));
}
@Test
public void testInvalidConfigScopedProxy() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml");
fail("should have thrown Exception; scope-resolver and scoped-proxy both provided");
}
catch (FatalBeanException e) {
// expected
}
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright 2002-2008 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import static org.junit.Assert.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
import example.scannable.AutowiredQualifierFooService;
/**
* @author Mark Fisher
* @author Juergen Hoeller
* @author Chris Beams
*/
public class ComponentScanParserTests {
@Test
public void testAspectJTypeFilter() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/aspectjTypeFilterTests.xml");
assertTrue(context.containsBean("fooServiceImpl"));
assertTrue(context.containsBean("stubFooDao"));
assertFalse(context.containsBean("scopedProxyTestBean"));
}
@Test
public void testNonMatchingResourcePattern() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/nonMatchingResourcePatternTests.xml");
assertFalse(context.containsBean("fooServiceImpl"));
}
@Test
public void testMatchingResourcePattern() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/matchingResourcePatternTests.xml");
assertTrue(context.containsBean("fooServiceImpl"));
}
@Test
public void testComponentScanWithAutowiredQualifier() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/componentScanWithAutowiredQualifierTests.xml");
AutowiredQualifierFooService fooService = (AutowiredQualifierFooService) context.getBean("fooService");
assertTrue(fooService.isInitCalled());
assertEquals("bar", fooService.foo(123));
}
@Test
public void testCustomAnnotationUsedForBothComponentScanAndQualifier() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/customAnnotationUsedForBothComponentScanAndQualifierTests.xml");
CustomAnnotationAutowiredBean testBean = (CustomAnnotationAutowiredBean) context.getBean("testBean");
assertNotNull(testBean.getDependency());
}
@Test
public void testCustomTypeFilter() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/customTypeFilterTests.xml");
CustomAnnotationAutowiredBean testBean = (CustomAnnotationAutowiredBean) context.getBean("testBean");
assertNotNull(testBean.getDependency());
}
@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public static @interface CustomAnnotation {
}
public static class CustomAnnotationAutowiredBean {
@Autowired
@CustomAnnotation
private CustomAnnotationDependencyBean dependency;
public CustomAnnotationDependencyBean getDependency() {
return this.dependency;
}
}
@CustomAnnotation
public static class CustomAnnotationDependencyBean {
}
public static class CustomTypeFilter implements TypeFilter {
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) {
return metadataReader.getClassMetadata().getClassName().contains("Custom");
}
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2002-2007 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author Mark Fisher
*/
public class ComponentScanParserWithUserDefinedStrategiesTests {
@Test
public void testCustomBeanNameGenerator() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/customNameGeneratorTests.xml");
assertTrue(context.containsBean("testing.fooServiceImpl"));
}
@Test
public void testCustomScopeMetadataResolver() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/customScopeResolverTests.xml");
BeanDefinition bd = context.getBeanFactory().getBeanDefinition("fooServiceImpl");
assertEquals("myCustomScope", bd.getScope());
assertFalse(bd.isSingleton());
}
@Test
public void testInvalidConstructorBeanNameGenerator() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/invalidConstructorNameGeneratorTests.xml");
fail("should have failed: no-arg constructor is required");
}
catch (BeansException e) {
// expected
}
}
@Test
public void testInvalidClassNameScopeMetadataResolver() {
try {
new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/invalidClassNameScopeResolverTests.xml");
fail("should have failed: no such class");
}
catch (BeansException e) {
// expected
}
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2002-2007 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
/**
* @author Mark Fisher
*/
public class TestBeanNameGenerator extends AnnotationBeanNameGenerator {
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
String beanName = super.generateBeanName(definition, registry);
return "testing." + beanName;
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2002-2007 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import org.springframework.beans.factory.config.BeanDefinition;
/**
* @author Mark Fisher
*/
public class TestScopeMetadataResolver implements ScopeMetadataResolver {
public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDefinition) {
ScopeMetadata metadata = new ScopeMetadata();
metadata.setScopeName("myCustomScope");
return metadata;
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable" use-default-filters="false" annotation-config="false">
<context:include-filter type="aspectj" expression="example.scannable.Stub*"/>
<context:include-filter type="aspectj" expression="example.scannable.FooService+"/>
<context:exclude-filter type="aspectj" expression="example..Scoped*Test*" />
</context:component-scan>
</beans>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="fooService" class="example.scannable.AutowiredQualifierFooService"/>
<context:component-scan base-package="example.scannable"/>
</beans>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.context.annotation.ComponentScanParserTests$CustomAnnotation"/>
</context:component-scan>
<bean class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer">
<property name="customQualifierTypes">
<value>org.springframework.context.annotation.ComponentScanParserTests$CustomAnnotation</value>
</property>
</bean>
<bean id="testBean" class="org.springframework.context.annotation.ComponentScanParserTests$CustomAnnotationAutowiredBean"/>
</beans>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable"
name-generator="org.springframework.context.annotation.TestBeanNameGenerator"/>
</beans>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable"
scope-resolver="org.springframework.context.annotation.TestScopeMetadataResolver"/>
</beans>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation" use-default-filters="false">
<context:include-filter type="custom" expression="org.springframework.context.annotation.ComponentScanParserTests$CustomTypeFilter"/>
</context:component-scan>
<bean class="org.springframework.beans.factory.annotation.CustomAutowireConfigurer">
<property name="customQualifierTypes">
<value>org.springframework.context.annotation.ComponentScanParserTests$CustomAnnotation</value>
</property>
</bean>
<bean id="testBean" class="org.springframework.context.annotation.ComponentScanParserTests$CustomAnnotationAutowiredBean"/>
</beans>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byType">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="constructor">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="no">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-dependency-check="all">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-dependency-check="objects"
default-autowire="byName">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean id="propertyDependency1"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-init-method="init" default-destroy-method="destroy">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false" annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="false">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="true">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-init-method="myInit" default-destroy-method="myDestroy">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false" annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$DefaultsTestBean"/>
</context:component-scan>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$ConstructorDependencyTestBean">
<constructor-arg value="cd"/>
</bean>
<bean class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd1"/>
</bean>
<bean id="propertyDependency2"
class="org.springframework.context.annotation.ComponentScanParserBeanDefinitionDefaultsTests$PropertyDependencyTestBean">
<constructor-arg value="pd2"/>
</bean>
</beans>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation"
scope-resolver="not.a.valid.classname"/>
</beans>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation"
name-generator="org.springframework.context.annotation.InvalidConstructorBeanNameGenerator"/>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example."
resource-pattern="**/scannable/*.class"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="aspectj" expression="example.scannable.FooService+"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework."
resource-pattern="**/thispackagedoesnotexist/*.class"
use-default-filters="false"
annotation-config="false">
<context:include-filter type="aspectj" expression="example.scannable.FooService+"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable" use-default-filters="false">
<context:include-filter type="assignable" expression="example.scannable.ScopedProxyTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable" use-default-filters="false" scoped-proxy="interfaces">
<context:include-filter type="assignable" expression="example.scannable.ScopedProxyTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.springframework.context.annotation"
use-default-filters="false" scoped-proxy="interfaces"
scope-resolver="org.springframework.context.annotation.TestScopeMetadataResolver">
<context:include-filter type="assignable"
expression="org.springframework.context.annotation.ScopedProxyTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable"
use-default-filters="false" scoped-proxy="no">
<context:include-filter type="assignable" expression="example.scannable.ScopedProxyTestBean"/>
</context:component-scan>
</beans>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="example.scannable" use-default-filters="false" scoped-proxy="targetClass">
<context:include-filter type="assignable" expression="example.scannable.ScopedProxyTestBean"/>
</context:component-scan>
</beans>