當前位置: 首頁>>代碼示例>>Java>>正文


Java AutowireCapableBeanFactory.initializeBean方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.AutowireCapableBeanFactory.initializeBean方法的典型用法代碼示例。如果您正苦於以下問題:Java AutowireCapableBeanFactory.initializeBean方法的具體用法?Java AutowireCapableBeanFactory.initializeBean怎麽用?Java AutowireCapableBeanFactory.initializeBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.config.AutowireCapableBeanFactory的用法示例。


在下文中一共展示了AutowireCapableBeanFactory.initializeBean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGet

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private synchronized Object doGet(final String className) {
    // Check again for the cache here, inside the sync method
    Object bean = beans.get(className);
    if (bean != null) {
        return bean;
    }
    try {
        AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
        Class<?> beanClass = Class.forName(className);
        bean = factory.createBean(beanClass, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
        factory.initializeBean(bean, beanClass.getSimpleName() + "#" + System.identityHashCode(bean));
        beans.put(className, bean);
        return bean;
    } catch (Exception e) {
        throw new IllegalArgumentException("Couldn't instantiate class " + className, e);
    }
}
 
開發者ID:mateli,項目名稱:OpenCyclos,代碼行數:18,代碼來源:CustomObjectHandlerImpl.java

示例2: autowireArguments

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private void autowireArguments(Object service, Object[] args) {
    if (disableAutowiredArguments) {
        return;
    }
    if (args == null) {
        return;
    }
    if (shouldAutowire(service)) {
        for (Object arg : args) {
            if (arg == null) {
                continue;
            }
            AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
            beanFactory.autowireBeanProperties(arg, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
            beanFactory.initializeBean(arg, arg.getClass().getName());
        }
    }
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:19,代碼來源:SpaceRemotingServiceExporter.java

示例3: beans

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Bean (name = "lol") @Lazy
public Collection<MyBeanClass> beans (final AutowireCapableBeanFactory factory) {
  Collection<MyBeanClass> result = new ArrayList<MyBeanClass> () {
    private static final long serialVersionUID = 1L;
    
    {
      log.warn ("CALLED Collection() for " + System.identityHashCode (this));
    }
    
    @PostConstruct
    private void init () {
      log.warn ("CALLED [email protected]");
      for (MyBeanClass m : this) {
        factory.initializeBean (m, UUID.randomUUID ().toString ());
      }
    }
  };
  
  result.add (new MyBeanClass (1));
  result.add (new MyBeanClass (2));
  
  return result;
}
 
開發者ID:dfci-cccb,項目名稱:mev,代碼行數:24,代碼來源:MyTest.java

示例4: injectDependencies

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Override
protected void injectDependencies(TestContext testContext) throws Exception {
    MergeClassPathXMLApplicationContext context = BaseTest.getContext();
    Object bean = testContext.getTestInstance();
    AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
    beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
    beanFactory.initializeBean(bean, testContext.getTestClass().getName());
    testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE);
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:10,代碼來源:MergeDependencyInjectionTestExecutionListener.java

示例5: importBatch

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private void importBatch(List<Long> entityIds) throws PropertyValueException {
	preload(entityIds, getMigrationInformation());
	
	try {
		MapSqlParameterSource entityIdsParameterSource = new MapSqlParameterSource();
		entityIdsParameterSource.addValue(getMigrationInformation().getParameterIds(), entityIds);
		AutowireCapableBeanFactory autowire = applicationContext.getAutowireCapableBeanFactory();
		
		AbstractResultRowMapper<? extends Map<Owning, Owned>> rowMapper = getMigrationInformation().newRowMapper(entityIds.size(), DEFAULT_VALUES_PER_KEY);
		
		autowire.autowireBean(rowMapper);
		autowire.initializeBean(rowMapper, rowMapper.getClass().getSimpleName());
		prepareRowMapper(rowMapper, entityIds);
		getNamedParameterJdbcTemplate().query(getMigrationInformation().getSqlRequest(), entityIdsParameterSource, rowMapper);
		
		for (Map.Entry<Owning, Owned> entry : rowMapper.getResults().entrySet()) {
			Owning entity = entry.getKey();
			getMigrationInformation().addToAssociation(entity, entry.getValue());
			if (getEntityService() != null) {
				getEntityService().update(entity);
			} else {
				entityManagerUtils.getEntityManager().persist(entity);
			}
		}
		
	} catch (RuntimeException | ServiceException | SecurityServiceException e) {
		getLogger().error("Error during the persistence of {} items. {} cancelled creations.",
				getMigrationInformation().getAssociationName(), entityIds.size(), e);
		ProcessorMonitorContext.get().getDoneItems().addAndGet(-1 * entityIds.size());
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:32,代碼來源:AbstractBatchAssociationMigrationService.java

示例6: startSpring

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
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 );
    }
 
開發者ID:apache,項目名稱:usergrid,代碼行數:14,代碼來源:WebSocketServer.java

示例7: setup

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@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" );
}
 
開發者ID:apache,項目名稱:usergrid,代碼行數:15,代碼來源:HazelcastTest.java

示例8: startSpring

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
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 );
    }
 
開發者ID:apache,項目名稱:usergrid,代碼行數:14,代碼來源:MongoServer.java

示例9: testByteContentInjectedFromResourceFileWhenAutowiring

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testByteContentInjectedFromResourceFileWhenAutowiring() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	DocumentTemplate bean = new DocumentTemplate();
	beanFactory.initializeBean(bean, "template");
	assertEquals(1612, bean.getLogo().length);
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceObjectAutowiringIT.java

示例10: testSimpleTypeValueInjection

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testSimpleTypeValueInjection() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	Messages bean = new Messages();
	beanFactory.initializeBean(bean, "messages");
	assertEquals("Hello, {}!", bean.getWelcome());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceValueBeanPostProcessorIT.java

示例11: testAutowiredBundleClassInjection

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testAutowiredBundleClassInjection() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	Greeting bean = new Greeting();
	beanFactory.initializeBean(bean, "greeting");
	assertEquals("Hello, {}!", bean.getWelcome());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceValueBeanPostProcessorIT.java

示例12: testAutowiredBundleNameInjection

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testAutowiredBundleNameInjection() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	Greeting bean = new Greeting();
	beanFactory.initializeBean(bean, "greeting");
	assertEquals("Dear Customer", bean.getName());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceValueBeanPostProcessorIT.java

示例13: testMandatoryValueInjection

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testMandatoryValueInjection() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	Messages bean = new Messages();
	beanFactory.initializeBean(bean, "messages");
	assertEquals("Web", bean.getApplication().asIs());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceValueBeanPostProcessorIT.java

示例14: testReferenceInjection

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testReferenceInjection() {
	AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
	Messages bean = new Messages();
	beanFactory.initializeBean(bean, "messages");
	assertEquals("See you!", bean.getGoodbyeValue().fetch(in(Locale.US)).asIs());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:8,代碼來源:ResourceValueBeanPostProcessorIT.java

示例15: testByteContentInjectedFromResourceFileWhenAutowiring

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Test
public void testByteContentInjectedFromResourceFileWhenAutowiring() {
    AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    Warning bean = new Warning();
    beanFactory.initializeBean(bean, "warning");
    assertEquals("Hello, John!", bean.getMessage());
    assertEquals("#", bean.getEscaped());
}
 
開發者ID:resource4j,項目名稱:resource4j,代碼行數:9,代碼來源:SpringELProcessorIT.java


注:本文中的org.springframework.beans.factory.config.AutowireCapableBeanFactory.initializeBean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。