remove check for Tool stage from SpringModule as it is no longer required
This commit is contained in:
committed by
Dave Syer
parent
8cbdf37570
commit
5e3603c29d
@@ -72,24 +72,22 @@ public class SpringModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
public void configure() {
|
||||
if (binder().currentStage() != Stage.TOOL) {
|
||||
if (beanFactory == null) {
|
||||
beanFactory = beanFactoryProvider.get();
|
||||
}
|
||||
if (beanFactory.getBeanNamesForType(ProvisionListener.class).length > 0) {
|
||||
binder().bindListener(Matchers.any(),
|
||||
beanFactory.getBeansOfType(ProvisionListener.class).values()
|
||||
.toArray(new ProvisionListener[0]));
|
||||
}
|
||||
if (beanFactory instanceof DefaultListableBeanFactory) {
|
||||
((DefaultListableBeanFactory) beanFactory)
|
||||
.setAutowireCandidateResolver(new GuiceAutowireCandidateResolver(
|
||||
binder().getProvider(Injector.class)));
|
||||
}
|
||||
if (beanFactory.getBeanNamesForType(GuiceModuleMetadata.class).length > 0) {
|
||||
this.matcher = new CompositeTypeMatcher(
|
||||
beanFactory.getBeansOfType(GuiceModuleMetadata.class).values());
|
||||
}
|
||||
if (beanFactory == null) {
|
||||
beanFactory = beanFactoryProvider.get();
|
||||
}
|
||||
if (beanFactory.getBeanNamesForType(ProvisionListener.class).length > 0) {
|
||||
binder().bindListener(Matchers.any(),
|
||||
beanFactory.getBeansOfType(ProvisionListener.class).values()
|
||||
.toArray(new ProvisionListener[0]));
|
||||
}
|
||||
if (beanFactory instanceof DefaultListableBeanFactory) {
|
||||
((DefaultListableBeanFactory) beanFactory)
|
||||
.setAutowireCandidateResolver(new GuiceAutowireCandidateResolver(
|
||||
binder().getProvider(Injector.class)));
|
||||
}
|
||||
if (beanFactory.getBeanNamesForType(GuiceModuleMetadata.class).length > 0) {
|
||||
this.matcher = new CompositeTypeMatcher(
|
||||
beanFactory.getBeansOfType(GuiceModuleMetadata.class).values());
|
||||
}
|
||||
bind(beanFactory);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import javax.inject.Named;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,6 +37,11 @@ import static org.junit.Assert.assertNotNull;
|
||||
*/
|
||||
public class EnableGuiceModulesTests {
|
||||
|
||||
@After
|
||||
public void cleanUp() {
|
||||
System.clearProperty("spring.guice.dedup");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
@@ -43,6 +49,15 @@ public class EnableGuiceModulesTests {
|
||||
assertNotNull(context.getBean(Foo.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDedupFeatureEnabled() {
|
||||
System.setProperty("spring.guice.dedup", "true");
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
TestConfig.class);
|
||||
assertNotNull(context.getBean(Foo.class));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void module() {
|
||||
|
||||
Reference in New Issue
Block a user