本文整理汇总了Java中org.springframework.beans.factory.support.BeanDefinitionBuilder.setFactoryMethod方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionBuilder.setFactoryMethod方法的具体用法?Java BeanDefinitionBuilder.setFactoryMethod怎么用?Java BeanDefinitionBuilder.setFactoryMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.BeanDefinitionBuilder
的用法示例。
在下文中一共展示了BeanDefinitionBuilder.setFactoryMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
//Sort out the Config Class
BeanDefinitionBuilder configBuilder
= helper.createBeanDefinitionBuilder(element, parserContext,
Config.class);
String configId = helper.getId(null, configBuilder, parserContext);
helper.parseAttributes(element, parserContext, configBuilder);
helper.registerBeanDefinition(configBuilder, configId,
null, parserContext);
//Do the main Redisson bean
BeanDefinitionBuilder builder
= helper.createBeanDefinitionBuilder(element, parserContext,
Redisson.class);
builder.setFactoryMethod("create");
builder.setDestroyMethodName("shutdown");
builder.addConstructorArgReference(configId);
parserContext.getDelegate().parseQualifierElements(element,
builder.getRawBeanDefinition());
String id = helper.getId(element, builder, parserContext);
helper.parseAttributes(element, parserContext, configBuilder);
//Sort out all the nested elements
parseChildElements(element, configId, id, builder, parserContext);
helper.registerBeanDefinition(builder, id,
helper.parseAliase(element), parserContext);
return builder.getBeanDefinition();
}
示例2: registryMangoInstance
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
* 向spring中注入mango实例
* @param beanFactory
*/
private void registryMangoInstance(DefaultListableBeanFactory beanFactory){
BeanDefinitionBuilder mangoBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mango.class);
mangoBuilder.setFactoryMethod("newInstance");
mangoBuilder.addPropertyValue("checkColumn",config.isCheckColumn());
mangoBuilder.addPropertyValue("compatibleWithEmptyList",config.isCompatibleWithEmptyList());
mangoBuilder.addPropertyValue("lazyInit",config.isLazyInit());
mangoBuilder.addPropertyValue("useActualParamName",config.isUseActualParamName());
mangoBuilder.addPropertyValue("useTransactionForBatchUpdate",config.isUseTransactionForBatchUpdate());
configCacheHandler(mangoBuilder);
beanFactory.registerBeanDefinition(Mango.class.getName(),mangoBuilder.getBeanDefinition());
}
示例3: registerAsyncExecutionAspect
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) {
if (!parserContext.getRegistry().containsBeanDefinition(AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_CLASS_NAME);
builder.setFactoryMethod("aspectOf");
String executor = element.getAttribute("executor");
if (StringUtils.hasText(executor)) {
builder.addPropertyReference("executor", executor);
}
parserContext.registerBeanComponent(
new BeanComponentDefinition(builder.getBeanDefinition(),
AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
}
}
示例4: buildLocalComponent
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private AbstractBeanDefinition buildLocalComponent(BeanMetadata metadata) {
// add basic definition properties
BeanDefinitionBuilder builder =
BeanDefinitionBuilder.genericBeanDefinition(metadata.getClassName()).setInitMethodName(
metadata.getInitMethod()).setDestroyMethodName(metadata.getDestroyMethod()).setLazyInit(
getLazy(metadata)).setScope(metadata.getScope());
// add factory-method/factory-bean
String factoryMethod = metadata.getFactoryMethod();
if (StringUtils.hasText(factoryMethod)) {
builder.setFactoryMethod(factoryMethod);
Target factory = metadata.getFactoryComponent();
if (factory != null) {
builder.getRawBeanDefinition().setFactoryBeanName(((ComponentMetadata) factory).getId());
}
}
// add constructor props
List<BeanArgument> beanArguments = metadata.getArguments();
ConstructorArgumentValues cargs = builder.getRawBeanDefinition().getConstructorArgumentValues();
for (BeanArgument arg : beanArguments) {
int index = arg.getIndex();
Object val = BeanMetadataElementFactory.buildBeanMetadata(arg.getValue());
if (index > -1) {
cargs.addGenericArgumentValue(val, arg.getValueType());
} else {
cargs.addIndexedArgumentValue(index, val, arg.getValueType());
}
}
// add property values
Collection<BeanProperty> props = metadata.getProperties();
MutablePropertyValues pvs = new MutablePropertyValues();
for (BeanProperty injection : props) {
pvs.addPropertyValue(injection.getName(), BeanMetadataElementFactory
.buildBeanMetadata(injection.getValue()));
}
return builder.getBeanDefinition();
}