|
|
|
@ -31,6 +31,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
|
|
|
import org.springframework.beans.testfixture.beans.TestBean; |
|
|
|
import org.springframework.beans.testfixture.beans.TestBean; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
import org.springframework.context.ConfigurableApplicationContext; |
|
|
|
|
|
|
|
import org.springframework.context.weaving.LoadTimeWeaverAware; |
|
|
|
import org.springframework.core.SpringProperties; |
|
|
|
import org.springframework.core.SpringProperties; |
|
|
|
import org.springframework.core.testfixture.EnabledForTestGroups; |
|
|
|
import org.springframework.core.testfixture.EnabledForTestGroups; |
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
|
@ -68,6 +69,16 @@ class BackgroundBootstrapTests { |
|
|
|
ctx.close(); |
|
|
|
ctx.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
@Timeout(10) |
|
|
|
|
|
|
|
@EnabledForTestGroups(LONG_RUNNING) |
|
|
|
|
|
|
|
void bootstrapWithLoadTimeWeaverAware() { |
|
|
|
|
|
|
|
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(LoadTimeWeaverAwareBeanConfig.class); |
|
|
|
|
|
|
|
ctx.getBean("testBean1", TestBean.class); |
|
|
|
|
|
|
|
ctx.getBean("testBean2", TestBean.class); |
|
|
|
|
|
|
|
ctx.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@Timeout(10) |
|
|
|
@Timeout(10) |
|
|
|
@EnabledForTestGroups(LONG_RUNNING) |
|
|
|
@EnabledForTestGroups(LONG_RUNNING) |
|
|
|
@ -266,6 +277,50 @@ class BackgroundBootstrapTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
|
|
|
static class LoadTimeWeaverAwareBeanConfig { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
LoadTimeWeaverAware loadTimeWeaverAware(ObjectProvider<TestBean> testBean1) { |
|
|
|
|
|
|
|
Thread thread = new Thread(testBean1::getObject); |
|
|
|
|
|
|
|
thread.start(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
thread.join(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (InterruptedException ex) { |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (loadTimeWeaver -> {}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
public TestBean testBean1(TestBean testBean2) { |
|
|
|
|
|
|
|
return new TestBean(testBean2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean @Lazy |
|
|
|
|
|
|
|
public FactoryBean<TestBean> testBean2() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Thread.sleep(2000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (InterruptedException ex) { |
|
|
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TestBean testBean = new TestBean(); |
|
|
|
|
|
|
|
return new FactoryBean<>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public TestBean getObject() { |
|
|
|
|
|
|
|
return testBean; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Class<?> getObjectType() { |
|
|
|
|
|
|
|
return testBean.getClass(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
static class StrictLockingBeanConfig { |
|
|
|
static class StrictLockingBeanConfig { |
|
|
|
|
|
|
|
|
|
|
|
|