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


Java BeanDefinitionBuilder.addPropertyReference方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.support.BeanDefinitionBuilder.addPropertyReference方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionBuilder.addPropertyReference方法的具体用法?Java BeanDefinitionBuilder.addPropertyReference怎么用?Java BeanDefinitionBuilder.addPropertyReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.support.BeanDefinitionBuilder的用法示例。


在下文中一共展示了BeanDefinitionBuilder.addPropertyReference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseAttributes

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public void parseAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    NamedNodeMap attributes = element.getAttributes();
    for (int x = 0; x < attributes.getLength(); x++) {
        Attr attribute = (Attr) attributes.item(x);
        if (isEligibleAttribute(attribute)) {
            String propertyName
                    = attribute.getLocalName().endsWith(REF_SUFFIX)
                            ? attribute.getLocalName()
                                    .substring(0, attribute.getLocalName()
                                            .length() - REF_SUFFIX.length())
                            : attribute.getLocalName();
            propertyName = Conventions
                    .attributeNameToPropertyName(propertyName);
            Assert.state(StringUtils.hasText(propertyName),
                    "Illegal property name returned from"
                            + " 'extractPropertyName(String)': cannot be"
                            + " null or empty.");
            if (attribute.getLocalName().endsWith(REF_SUFFIX)) {
                builder.addPropertyReference(propertyName,
                        attribute.getValue());
            } else {
                builder.addPropertyValue(propertyName, attribute.getValue());
            }
        }
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:27,代码来源:RedissonNamespaceParserSupport.java

示例2: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element));

	List<Element> txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES_ELEMENT);
	if (txAttributes.size() > 1) {
		parserContext.getReaderContext().error(
				"Element <attributes> is allowed at most once inside element <advice>", element);
	}
	else if (txAttributes.size() == 1) {
		// Using attributes source.
		Element attributeSourceElement = txAttributes.get(0);
		RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext);
		builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition);
	}
	else {
		// Assume annotations source.
		builder.addPropertyValue("transactionAttributeSource",
				new RootBeanDefinition("org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TxAdviceBeanDefinitionParser.java

示例3: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.addPropertyReference("cacheManager", CacheNamespaceHandler.extractCacheManager(element));
	CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition());

	List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT);
	if (cacheDefs.size() >= 1) {
		// Using attributes source.
		List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
		builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
	} else {
		// Assume annotations source.
		builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
				AnnotationCacheOperationSource.class));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:CacheAdviceParser.java

示例4: createSqlSessionFactoryBean

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected final AbstractBeanDefinition createSqlSessionFactoryBean(String dataSourceName, String mapperPackage,
		String typeAliasesPackage, Dialect dialect, Configuration configuration) {
	configuration.setDatabaseId(dataSourceName);
	BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(SqlSessionFactoryBean.class);
	bdb.addPropertyValue("configuration", configuration);
	bdb.addPropertyValue("failFast", true);
	bdb.addPropertyValue("typeAliases", this.saenTypeAliases(typeAliasesPackage));
	bdb.addPropertyReference("dataSource", dataSourceName);
	bdb.addPropertyValue("plugins", new Interceptor[] { new CustomPageInterceptor(dialect) });
	if (!StringUtils.isEmpty(mapperPackage)) {
		try {
			mapperPackage = new StandardEnvironment().resolveRequiredPlaceholders(mapperPackage);
			String mapperPackages = ClassUtils.convertClassNameToResourcePath(mapperPackage);
			String mapperPackagePath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPackages + "/*.xml";
			Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperPackagePath);
			bdb.addPropertyValue("mapperLocations", resources);
		} catch (Exception e) {
			log.error("初始化失败", e);
			throw new RuntimeException( String.format("SqlSessionFactory 初始化失败  mapperPackage=%s", mapperPackage + ""));
		}
	}
	return bdb.getBeanDefinition();
}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:24,代码来源:AbstractDataBaseBean.java

示例5: registerSchedulerTriggerBean

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
/**
 * 
 * @param acf
 * @param sch
 * @return
 */
private Trigger registerSchedulerTriggerBean(DefaultListableBeanFactory acf, AbstractJob sch) {
    //注册JobDetail
    String jobDetailBeanName = sch.getJobName() + "JobDetail";
    if (context.containsBean(jobDetailBeanName)) {
        throw new RuntimeException("duplicate jobName[" + sch.getJobName() + "] defined!!");
    }
    BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder
        .genericBeanDefinition(MethodInvokingJobDetailFactoryBean.class);
    beanDefBuilder.addPropertyValue("targetObject", sch);
    beanDefBuilder.addPropertyValue("targetMethod", "execute");
    beanDefBuilder.addPropertyValue("concurrent", false);
    acf.registerBeanDefinition(jobDetailBeanName, beanDefBuilder.getRawBeanDefinition());

    //注册Trigger
    String triggerBeanName = sch.getJobName() + "Trigger";
    beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(CronTriggerFactoryBean.class);
    beanDefBuilder.addPropertyReference("jobDetail", jobDetailBeanName);
    beanDefBuilder.addPropertyValue("cronExpression", sch.getCronExpr());
    beanDefBuilder.addPropertyValue("group", groupName);
    acf.registerBeanDefinition(triggerBeanName, beanDefBuilder.getRawBeanDefinition());

    logger.info("register scheduler task [{}] ok!!", sch.getJobName());
    return (Trigger) context.getBean(triggerBeanName);

}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:32,代码来源:SchedulerFactoryBeanWrapper.java

示例6: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element,ParserContext parserContext,BeanDefinitionBuilder builder) {
	String id=element.getAttribute("id");
	if(StringUtils.isNotEmpty(id))hasId=false;
	String dataSourceRegisterName=element.getAttribute("dataSourceRegisterName");
	builder.addPropertyValue("dataSourceName", dataSourceRegisterName);
	builder.addPropertyReference("entityInterceptor", UnByteCodeProxyInterceptor.BEAN_ID);
	NodeList nodeList=element.getChildNodes();
	for(int i=0;i<nodeList.getLength();i++){
		Node node=nodeList.item(i);
		String nodeName=parserContext.getDelegate().getLocalName(node);
		IElementParser<?> parser=parserMap.get(nodeName);
		if(parser!=null){
			builder.addPropertyValue(parser.propertyName(), parser.parse(node, parserContext));
		}
	}
	String scanPackages=element.getAttribute("scanPackages");
	if(StringUtils.isNotEmpty(scanPackages)){
		builder.addPropertyValue("scanPackages", scanPackages.split(","));			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:22,代码来源:SessionFactoryBeanParser.java

示例7: process

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();
	if (name.endsWith(PROPERTY_REF)) {
		String propertyName = name.substring(0, name.length() - PROPERTY_REF.length());
		builder.addPropertyReference(propertyName, attribute.getValue());
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:PropertyRefAttributeCallback.java

示例8: 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

示例9: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DataSourceInitializer.class);
	builder.addPropertyReference("dataSource", element.getAttribute("data-source"));
	builder.addPropertyValue("enabled", element.getAttribute("enabled"));
	DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:InitializeDatabaseBeanDefinitionParser.java

示例10: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
	String location = element.getAttribute("location");
	if (StringUtils.hasLength(location)) {
		String[] locations = StringUtils.commaDelimitedListToStringArray(location);
		builder.addPropertyValue("locations", locations);
	}

	String propertiesRef = element.getAttribute("properties-ref");
	if (StringUtils.hasLength(propertiesRef)) {
		builder.addPropertyReference("properties", propertiesRef);
	}

	String fileEncoding = element.getAttribute("file-encoding");
	if (StringUtils.hasLength(fileEncoding)) {
		builder.addPropertyValue("fileEncoding", fileEncoding);
	}

	String order = element.getAttribute("order");
	if (StringUtils.hasLength(order)) {
		builder.addPropertyValue("order", Integer.valueOf(order));
	}

	builder.addPropertyValue("ignoreResourceNotFound",
			Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));

	builder.addPropertyValue("localOverride",
			Boolean.valueOf(element.getAttribute("local-override")));

	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AbstractPropertyLoadingBeanDefinitionParser.java

示例11: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);

	// Mark as infrastructure bean and attach source location.
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));

	String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE);
	if (StringUtils.hasText(defaultDomain)) {
		builder.addPropertyValue("defaultDomain", defaultDomain);
	}

	String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
	if (StringUtils.hasText(serverBeanName)) {
		builder.addPropertyReference("server", serverBeanName);
	}
	else {
		AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
		if (specialServer != null) {
			builder.addPropertyValue("server", specialServer);
		}
	}

	String registration = element.getAttribute(REGISTRATION_ATTRIBUTE);
	RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING;
	if (REGISTRATION_IGNORE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.IGNORE_EXISTING;
	}
	else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.REPLACE_EXISTING;
	}
	builder.addPropertyValue("registrationPolicy", registrationPolicy);

	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:MBeanExportBeanDefinitionParser.java

示例12: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected void doParse(Element element, BeanDefinitionBuilder bean) {

        try {
            String serviceItf = element.getAttribute("interface");
            String timeOut = element.getAttribute("timeout");
            String serverPort = element.getAttribute("serverPort");
            String ref = element.getAttribute("ref");
            String weight = element.getAttribute("weight");
            String workerThreads = element.getAttribute("workerThreads");
            String appKey = element.getAttribute("appKey");
            String groupName = element.getAttribute("groupName");

            bean.addPropertyValue("serverPort", Integer.parseInt(serverPort));
            bean.addPropertyValue("timeout", Integer.parseInt(timeOut));
            bean.addPropertyValue("serviceItf", Class.forName(serviceItf));
            bean.addPropertyReference("serviceObject", ref);
            bean.addPropertyValue("appKey", appKey);

            if (NumberUtils.isNumber(weight)) {
                bean.addPropertyValue("weight", Integer.parseInt(weight));
            }
            if (NumberUtils.isNumber(workerThreads)) {
                bean.addPropertyValue("workerThreads", Integer.parseInt(workerThreads));
            }
            if (StringUtils.isNotBlank(groupName)) {
                bean.addPropertyValue("groupName", groupName);
            }
        } catch (Exception e) {
            logger.error("ProviderFactoryBeanDefinitionParser error.", e);
            throw new RuntimeException(e);
        }

    }
 
开发者ID:linuer,项目名称:nan,代码行数:34,代码来源:ProviderFactoryBeanDefinitionParser.java

示例13: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element,BeanDefinitionBuilder builder) {
	String name=element.getAttribute("name");
	String asDefault=element.getAttribute("asDefault");
	String dataSource=element.getAttribute("dataSource-ref");
	builder.addPropertyValue("name", name);
	builder.addPropertyValue("asDefault", asDefault);
	builder.addPropertyReference("dataSource", dataSource);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:DataSourceRegisterBeanParser.java

示例14: factoryInvoker

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanComponentDefinition factoryInvoker(Element element, String bean, String method, Object[] args, ParserContext parserContext) {
    BeanDefinitionBuilder builder
            = preInvoke(element, bean, method, args, parserContext, true);
    builder.addPropertyReference("targetObject", bean);
    return doInvoke(element, builder, parserContext);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:RedissonNamespaceParserSupport.java

示例15: invoker

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public BeanComponentDefinition invoker(Element element, String bean, String method, Object[] args, ParserContext parserContext) {
    BeanDefinitionBuilder builder
            = preInvoke(element, bean, method, args, parserContext, false);
    builder.addPropertyReference("targetObject", bean);
    return doInvoke(element, builder, parserContext);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:RedissonNamespaceParserSupport.java


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