Java Code Examples for org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties()
The following examples show how to use
org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicroInjectSpringPlugin.java From nh-micro with Apache License 2.0 | 5 votes |
public GroovyObject execPlugIn(String name, GroovyObject groovyObject, GroovyObject proxyObject) throws Exception { ApplicationContext context=MicroContextHolder.getContext(); AutowireCapableBeanFactory autowireCapableBeanFactory=context.getAutowireCapableBeanFactory(); autowireCapableBeanFactory.autowireBeanProperties(groovyObject, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); return proxyObject; }
Example 2
Source File: MicroInjectSpringPlugin.java From nh-micro with Apache License 2.0 | 5 votes |
public GroovyObject execPlugIn(String name, GroovyObject groovyObject, GroovyObject proxyObject) throws Exception { ApplicationContext context=MicroContextHolder.getContext(); AutowireCapableBeanFactory autowireCapableBeanFactory=context.getAutowireCapableBeanFactory(); autowireCapableBeanFactory.autowireBeanProperties(groovyObject, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); return proxyObject; }
Example 3
Source File: WebSocketServer.java From usergrid with Apache License 2.0 | 5 votes |
public void startSpring() { String[] locations = getApplicationContextLocations(); ApplicationContext ac = new ClassPathXmlApplicationContext( locations ); AutowireCapableBeanFactory acbf = ac.getAutowireCapableBeanFactory(); acbf.autowireBeanProperties( this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false ); acbf.initializeBean( this, "webSocketServer" ); assertNotNull( emf ); assertTrue( "EntityManagerFactory is instance of EntityManagerFactoryImpl", emf instanceof EntityManagerFactoryImpl ); }
Example 4
Source File: HazelcastTest.java From usergrid with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { // assertNotNull(client); String maven_opts = System.getenv( "MAVEN_OPTS" ); logger.info( "Maven options: " + maven_opts ); String[] locations = { "usergrid-test-context.xml" }; ac = new ClassPathXmlApplicationContext( locations ); AutowireCapableBeanFactory acbf = ac.getAutowireCapableBeanFactory(); acbf.autowireBeanProperties( this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false ); acbf.initializeBean( this, "testClient" ); }
Example 5
Source File: MongoServer.java From usergrid with Apache License 2.0 | 5 votes |
public void startSpring() { String[] locations = getApplicationContextLocations(); ApplicationContext ac = new ClassPathXmlApplicationContext( locations ); AutowireCapableBeanFactory acbf = ac.getAutowireCapableBeanFactory(); acbf.autowireBeanProperties( this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false ); acbf.initializeBean( this, "mongoServer" ); assertNotNull( emf ); assertTrue( "EntityManagerFactory is instance of EntityManagerFactoryImpl", emf instanceof EntityManagerFactoryImpl ); }
Example 6
Source File: SpringUtils.java From onetwo with Apache License 2.0 | 4 votes |
public static <T> void injectAndInitialize(AutowireCapableBeanFactory acb, T bean, int autowireMode) { acb.autowireBeanProperties(bean, autowireMode, false); initializeBean(acb, bean); }
Example 7
Source File: ToolBase.java From usergrid with Apache License 2.0 | 4 votes |
public void startSpring() { String[] locations = { "toolsApplicationContext.xml" }; ApplicationContext ac = new ClassPathXmlApplicationContext( locations ); AutowireCapableBeanFactory acbf = ac.getAutowireCapableBeanFactory(); acbf.autowireBeanProperties( this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false ); acbf.initializeBean( this, "testClient" ); assertNotNull( emf ); assertTrue( "EntityManagerFactory is instance of EntityManagerFactory", emf instanceof EntityManagerFactory ); injector = ac.getBean( Injector.class ); }
Example 8
Source File: DependencyInjectionTestExecutionListener.java From spring-analysis-note with MIT License | 3 votes |
/** * Performs dependency injection and bean initialization for the supplied * {@link TestContext} as described in * {@link #prepareTestInstance(TestContext) prepareTestInstance()}. * <p>The {@link #REINJECT_DEPENDENCIES_ATTRIBUTE} will be subsequently removed * from the test context, regardless of its value. * @param testContext the test context for which dependency injection should * be performed (never {@code null}) * @throws Exception allows any exception to propagate * @see #prepareTestInstance(TestContext) * @see #beforeTestMethod(TestContext) */ protected void injectDependencies(TestContext testContext) throws Exception { Object bean = testContext.getTestInstance(); Class<?> clazz = testContext.getTestClass(); AutowireCapableBeanFactory beanFactory = testContext.getApplicationContext().getAutowireCapableBeanFactory(); beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false); beanFactory.initializeBean(bean, clazz.getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX); testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE); }
Example 9
Source File: DependencyInjectionTestExecutionListener.java From java-technology-stack with MIT License | 3 votes |
/** * Performs dependency injection and bean initialization for the supplied * {@link TestContext} as described in * {@link #prepareTestInstance(TestContext) prepareTestInstance()}. * <p>The {@link #REINJECT_DEPENDENCIES_ATTRIBUTE} will be subsequently removed * from the test context, regardless of its value. * @param testContext the test context for which dependency injection should * be performed (never {@code null}) * @throws Exception allows any exception to propagate * @see #prepareTestInstance(TestContext) * @see #beforeTestMethod(TestContext) */ protected void injectDependencies(TestContext testContext) throws Exception { Object bean = testContext.getTestInstance(); Class<?> clazz = testContext.getTestClass(); AutowireCapableBeanFactory beanFactory = testContext.getApplicationContext().getAutowireCapableBeanFactory(); beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false); beanFactory.initializeBean(bean, clazz.getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX); testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE); }
Example 10
Source File: DependencyInjectionTestExecutionListener.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * Performs dependency injection and bean initialization for the supplied * {@link TestContext} as described in * {@link #prepareTestInstance(TestContext) prepareTestInstance()}. * <p>The {@link #REINJECT_DEPENDENCIES_ATTRIBUTE} will be subsequently removed * from the test context, regardless of its value. * @param testContext the test context for which dependency injection should * be performed (never {@code null}) * @throws Exception allows any exception to propagate * @see #prepareTestInstance(TestContext) * @see #beforeTestMethod(TestContext) */ protected void injectDependencies(final TestContext testContext) throws Exception { Object bean = testContext.getTestInstance(); AutowireCapableBeanFactory beanFactory = testContext.getApplicationContext().getAutowireCapableBeanFactory(); beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false); beanFactory.initializeBean(bean, testContext.getTestClass().getName()); testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE); }