|
|
|
@ -186,6 +186,14 @@ public class BeanRegistryAdapterTests { |
|
|
|
assertThat(beanDefinition.getScope()).isEqualTo(AbstractBeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
assertThat(beanDefinition.getScope()).isEqualTo(AbstractBeanDefinition.SCOPE_PROTOTYPE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void customScope() { |
|
|
|
|
|
|
|
BeanRegistryAdapter adapter = new BeanRegistryAdapter(this.beanFactory, this.beanFactory, this.env, ScopeBeanRegistrar.class); |
|
|
|
|
|
|
|
new ScopeBeanRegistrar().register(adapter, env); |
|
|
|
|
|
|
|
BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition("foo"); |
|
|
|
|
|
|
|
assertThat(beanDefinition.getScope()).isEqualTo("custom"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void defaultSupplier() { |
|
|
|
void defaultSupplier() { |
|
|
|
BeanRegistryAdapter adapter = new BeanRegistryAdapter(this.beanFactory, this.beanFactory, this.env, DefaultBeanRegistrar.class); |
|
|
|
BeanRegistryAdapter adapter = new BeanRegistryAdapter(this.beanFactory, this.beanFactory, this.env, DefaultBeanRegistrar.class); |
|
|
|
@ -308,6 +316,14 @@ public class BeanRegistryAdapterTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class ScopeBeanRegistrar implements BeanRegistrar { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void register(BeanRegistry registry, Environment env) { |
|
|
|
|
|
|
|
registry.registerBean("foo", Foo.class, spec -> spec.scope("custom")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class SupplierBeanRegistrar implements BeanRegistrar { |
|
|
|
private static class SupplierBeanRegistrar implements BeanRegistrar { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|