当前位置: 首页>>代码示例>>Java>>正文


Java BeanDefinitionBuilder.setFactoryMethod方法代码示例

本文整理汇总了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();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:30,代码来源:RedissonDefinitionParser.java

示例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());
}
 
开发者ID:jfaster,项目名称:mango-spring-boot-starter,代码行数:19,代码来源:MangoDaoAutoCreator.java

示例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));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AnnotationDrivenBeanDefinitionParser.java

示例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();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:45,代码来源:BeanDefinitionFactory.java


注:本文中的org.springframework.beans.factory.support.BeanDefinitionBuilder.setFactoryMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。