List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBeanDefinitionNames
@Override
public String[] getBeanDefinitionNames()
From source file:com.doctor.spring4.blog.code.WireObjectDependenciesOutsideSpring.java
/** * /*from ww w. j a v a 2 s . c o m*/ * Using @Configurable, the catch though is that it requires AspectJ to work. * Spring essentially enhances the constructor of the class to inject in the dependencies along the lines of what is being explicitly done in the third approach above: * The following is also required to configure the Aspect responsible for @Configurable weaving: * <context:spring-configured/> * * @see http://stackoverflow.com/questions/27744287/what-is-the-spring-java-config-equivalent-of-contextspring-configured */ @Ignore @Test public void test_() { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringConfig2.class); Person2 person = new Person2(); assertNull(person.getContext()); assertNotNull(person.getContext()); Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println); applicationContext.close(); }
From source file:com.doctor.spring4.blog.code.WireObjectDependenciesOutsideSpring.java
/** * Instantiate the bean and then inject dependencies using AutoWireCapableBeanFactory.autowireBean(instance) *//*w ww. j a v a2 s .c o m*/ @Test public void test_only_inject_dependencies() { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringConfig.class); Person person = new Person(); assertNull(person.getContext()); applicationContext.getAutowireCapableBeanFactory().autowireBean(person); assertNotNull(person.getContext()); Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println); applicationContext.close(); }
From source file:com.doctor.spring4.blog.code.WireObjectDependenciesOutsideSpring.java
/** * Instantiate the bean and then inject dependencies using AutoWireCapableBeanFactory.autowireBean(instance) * beanperson??//from www. j a v a 2 s . c o m */ @Test public void test_create_bean_and_inject_dependencies() { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringConfig.class); Person person = (Person) applicationContext.getAutowireCapableBeanFactory().createBean(Person.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); assertNotNull(person.getContext()); Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println); applicationContext.close(); }
From source file:com.doctor.spring4.blog.code.WireObjectDependenciesOutsideSpring.java
/** * ??spring??//w w w .j av a 2 s . com * * @see http://www.javacodegeeks.com/2012/03/integrating-spring-into-legacy.html * */ @Test public void test_registerSingleton() { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringConfig.class); Person person = new Person(); assertNull(person.getContext()); applicationContext.getBeanFactory().registerSingleton("person", person); assertNotNull(applicationContext.getBean(Person.class)); assertNull(person.getContext()); applicationContext.getAutowireCapableBeanFactory().autowireBean(person); assertNotNull(person.getContext()); Stream.of(applicationContext.getBeanDefinitionNames()).forEach(System.out::println); applicationContext.close(); }