本文整理匯總了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);
}
}
示例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());
}
}
}
示例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;
}
示例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 );
}
示例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" );
}
示例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 );
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}