本文整理匯總了Java中org.springframework.beans.factory.support.AbstractBeanDefinition.setLazyInit方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractBeanDefinition.setLazyInit方法的具體用法?Java AbstractBeanDefinition.setLazyInit怎麽用?Java AbstractBeanDefinition.setLazyInit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.support.AbstractBeanDefinition
的用法示例。
在下文中一共展示了AbstractBeanDefinition.setLazyInit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseInternal
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
Class<?> beanClass = getBeanClass(element);
Assert.notNull(beanClass);
if (beanClass != null) {
builder.getRawBeanDefinition().setBeanClass(beanClass);
}
builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
OsgiDefaultsDefinition defaults = resolveDefaults(element.getOwnerDocument(), parserContext);
applyDefaults(parserContext, defaults, builder);
doParse(element, parserContext, builder);
AbstractBeanDefinition def = builder.getBeanDefinition();
// check whether the bean is mandatory (and if it is, make it top-level
// bean)
if (parserContext.isNested()) {
String value = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
value = (StringUtils.hasText(value) ? value + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR : "");
String generatedName = generateBeanName(value, def, parserContext);
// make the bean lazy (since it is an inner bean initiallly)
def.setLazyInit(true);
// disable autowiring for promoted bean
def.setAutowireCandidate(false);
def.setAttribute(PROMOTED_REF, Boolean.TRUE);
BeanDefinitionHolder holder = new BeanDefinitionHolder(def, generatedName);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
return createBeanReferenceDefinition(generatedName, def);
}
return def;
}
示例2: parseAttributes
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
private AbstractBeanDefinition parseAttributes(Element ele, String beanName, AbstractBeanDefinition beanDefinition) {
AbstractBeanDefinition bd =
parserContext.getDelegate().parseBeanDefinitionAttributes(ele, beanName, null, beanDefinition);
// handle lazy flag (initialize)
String lazyInit = ele.getAttribute(LAZY_INIT_ATTR);
// check whether the value is "lazy"
if (StringUtils.hasText(lazyInit)) {
if (lazyInit.equalsIgnoreCase(LAZY_INIT_VALUE)) {
bd.setLazyInit(true);
} else {
bd.setLazyInit(false);
}
} else {
bd.setLazyInit(getDefaults(ele).getDefaultInitialization());
}
// handle factory component
String componentFactory = ele.getAttribute(FACTORY_REF_ATTR);
if (StringUtils.hasText(componentFactory)) {
bd.setFactoryBeanName(componentFactory);
}
// check whether the bean is a prototype with destroy method
if (StringUtils.hasText(bd.getDestroyMethodName())
&& BeanDefinition.SCOPE_PROTOTYPE.equalsIgnoreCase(bd.getScope())) {
error("Blueprint prototype beans cannot define destroy methods", ele);
}
return bd;
}
示例3: registryBean
import org.springframework.beans.factory.support.AbstractBeanDefinition; //導入方法依賴的package包/類
private void registryBean(String druidNodeName, MybatisNodeProperties nodeProperties,
DruidProperties defaultProperties, Configuration configuration, BeanDefinitionRegistry registry) {
if (nodeProperties == null) {
return;
}
String mapperPackage = nodeProperties.getMapperPackage();
String typeAliasesPackage = nodeProperties.getTypeAliasesPackage();
String dbType = super.getDbType(nodeProperties.getMaster(), defaultProperties);
Order order = nodeProperties.getOrder();
Dialect dialect = nodeProperties.getDialect();
Style style = nodeProperties.getStyle();
if (null == dialect) {
dialect = Dialect.valoueOfName(dbType);
}
Mapper mappers = nodeProperties.getMapper();
if (mappers == null) {
mappers = Mapper.valueOfDialect(dialect);
}
String basepackage = nodeProperties.getBasePackage();
if (StringUtils.isEmpty(basepackage)) {
log.warn("BasePackage為空,db配置異常,當前配置數據源對象的名字{}", druidNodeName);
basepackage = "";
}
boolean primary = nodeProperties.isPrimary();
String dataSourceName = druidNodeName + "DataSource";
// String dataSourceMasterName = druidNodeName + "DataSource-Master";
String jdbcTemplateName = druidNodeName + "JdbcTemplate";
String transactionManagerName = druidNodeName;
String sqlSessionFactoryBeanName = druidNodeName + "RegerSqlSessionFactoryBean";
String scannerConfigurerName = druidNodeName + "RegerScannerConfigurer";
AbstractBeanDefinition dataSource = super.createDataSource(nodeProperties, defaultProperties, dataSourceName);
// AbstractBeanDefinition dataSourceMaster =
// super.createDataSourceMaster(dataSourceName);
AbstractBeanDefinition jdbcTemplate = super.createJdbcTemplate(dataSourceName);
AbstractBeanDefinition transactionManager = super.createTransactionManager(dataSourceName);
AbstractBeanDefinition sqlSessionFactoryBean = super.createSqlSessionFactoryBean(dataSourceName, mapperPackage,
typeAliasesPackage, dialect, configuration);
AbstractBeanDefinition scannerConfigurer = super.createScannerConfigurerBean(sqlSessionFactoryBeanName,
basepackage, mappers, order, style);
dataSource.setLazyInit(true);
dataSource.setPrimary(primary);
dataSource.setScope(BeanDefinition.SCOPE_SINGLETON);
// dataSourceMaster.setLazyInit(true);
// dataSourceMaster.setScope(BeanDefinition.SCOPE_SINGLETON);
jdbcTemplate.setLazyInit(true);
jdbcTemplate.setPrimary(primary);
jdbcTemplate.setScope(BeanDefinition.SCOPE_SINGLETON);
transactionManager.setLazyInit(true);
transactionManager.setPrimary(primary);
transactionManager.setScope(BeanDefinition.SCOPE_SINGLETON);
sqlSessionFactoryBean.setLazyInit(true);
sqlSessionFactoryBean.setPrimary(primary);
sqlSessionFactoryBean.setScope(BeanDefinition.SCOPE_SINGLETON);
scannerConfigurer.setLazyInit(true);
scannerConfigurer.setPrimary(primary);
scannerConfigurer.setScope(BeanDefinition.SCOPE_SINGLETON);
registry.registerBeanDefinition(dataSourceName, dataSource);
// registry.registerBeanDefinition(dataSourceMasterName,
// dataSourceMaster);
registry.registerBeanDefinition(jdbcTemplateName, jdbcTemplate);
registry.registerBeanDefinition(transactionManagerName, transactionManager);
registry.registerBeanDefinition(sqlSessionFactoryBeanName, sqlSessionFactoryBean);
registry.registerBeanDefinition(scannerConfigurerName, scannerConfigurer);
if (primary) {
registry.registerAlias(dataSourceName, "dataSource");
registry.registerAlias(jdbcTemplateName, "jdbcTemplate");
registry.registerAlias(transactionManagerName, "transactionManager");
}
}