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


Java RootBeanDefinition.setBeanClassName方法代码示例

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


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

示例1: createContainerFactory

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext,
		PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) {

	RootBeanDefinition factoryDef = new RootBeanDefinition();

	String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
	String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
	if (!"".equals(containerClass)) {
		return null; // Not supported
	}
	else if ("".equals(containerType) || containerType.startsWith("default")) {
		factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory");
	}
	else if (containerType.startsWith("simple")) {
		factoryDef.setBeanClassName("org.springframework.jms.config.SimpleJmsListenerContainerFactory");
	}

	factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties);
	factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties);

	return factoryDef;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JmsListenerContainerParser.java

示例2: registerBean

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
	 * 注册bean定义
	 * @param idOrName
	 * @param beanClass
	 * @param isSingleton
	 */
	public static void registerBean(String idOrName,Class beanClass,boolean isSingleton) {
		DefaultListableBeanFactory beanFactory = getDefaultBeanFactory();
		if(!beanFactory.containsBean( idOrName )){
			
			RootBeanDefinition beanDefinition = new RootBeanDefinition();
			beanDefinition.setBeanClassName(beanClass.getName());
            beanDefinition.setScope(AbstractBeanDefinition.SCOPE_SINGLETON);
//			beanDefinition.setSingleton(isSingleton); //默认为true, 需要增加可配置性
			beanFactory.registerBeanDefinition( idOrName , beanDefinition);
			
			if(log.isDebugEnabled()) log.debug("注册bean: {} singleton?:{}",  idOrName, isSingleton);
		}
		
	}
 
开发者ID:jambo-framework,项目名称:jambo2,代码行数:21,代码来源:SpringContextManager.java

示例3: registerTransactionAspect

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
private void registerTransactionAspect(Element element, ParserContext parserContext) {
	String txAspectBeanName = TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME;
	String txAspectClassName = TransactionManagementConfigUtils.TRANSACTION_ASPECT_CLASS_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAspectBeanName)) {
		RootBeanDefinition def = new RootBeanDefinition();
		def.setBeanClassName(txAspectClassName);
		def.setFactoryMethodName("aspectOf");
		registerTransactionManager(element, def);
		parserContext.registerBeanComponent(new BeanComponentDefinition(def, txAspectBeanName));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AnnotationDrivenBeanDefinitionParser.java

示例4: doParse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

	if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) {
		RootBeanDefinition weavingEnablerDef = new RootBeanDefinition();
		weavingEnablerDef.setBeanClassName(ASPECTJ_WEAVING_ENABLER_CLASS_NAME);
		parserContext.getReaderContext().registerWithGeneratedName(weavingEnablerDef);

		if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) {
			new SpringConfiguredBeanDefinitionParser().parse(element, parserContext);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:LoadTimeWeaverBeanDefinitionParser.java

示例5: parse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
	if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
		RootBeanDefinition def = new RootBeanDefinition();
		def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
		def.setFactoryMethodName("aspectOf");
		def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		def.setSource(parserContext.extractSource(element));
		parserContext.registerBeanComponent(new BeanComponentDefinition(def, BEAN_CONFIGURER_ASPECT_BEAN_NAME));
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SpringConfiguredBeanDefinitionParser.java

示例6: registerCacheAspect

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
 * Registers a
 * <pre class="code">
 * <bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
 *   <property name="cacheManager" ref="cacheManager"/>
 *   <property name="keyGenerator" ref="keyGenerator"/>
 * </bean>
 * </pre>
 */
private void registerCacheAspect(Element element, ParserContext parserContext) {
	if (!parserContext.getRegistry().containsBeanDefinition(CACHE_ASPECT_BEAN_NAME)) {
		RootBeanDefinition def = new RootBeanDefinition();
		def.setBeanClassName(CACHE_ASPECT_CLASS_NAME);
		def.setFactoryMethodName("aspectOf");
		parseCacheManagerProperty(element, def);
		CacheNamespaceHandler.parseKeyGenerator(element, def);
		parserContext.registerBeanComponent(new BeanComponentDefinition(def, CACHE_ASPECT_BEAN_NAME));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AnnotationDrivenCacheBeanDefinitionParser.java

示例7: registerCacheAspect

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
 * Registers a
 * <pre class="code">
 * <bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
 *   <property name="cacheManager" ref="cacheManager"/>
 *   <property name="keyGenerator" ref="keyGenerator"/>
 * </bean>
 * </pre>
 */
private static void registerCacheAspect(Element element, ParserContext parserContext) {
	if (!parserContext.getRegistry().containsBeanDefinition(CacheManagementConfigUtils.CACHE_ASPECT_BEAN_NAME)) {
		RootBeanDefinition def = new RootBeanDefinition();
		def.setBeanClassName(CACHE_ASPECT_CLASS_NAME);
		def.setFactoryMethodName("aspectOf");
		parseCacheResolution(element, def, false);
		CacheNamespaceHandler.parseKeyGenerator(element, def);
		parserContext.registerBeanComponent(new BeanComponentDefinition(def, CacheManagementConfigUtils.CACHE_ASPECT_BEAN_NAME));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AnnotationDrivenCacheBeanDefinitionParser.java

示例8: createContainerFactory

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext,
		PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) {

	RootBeanDefinition factoryDef = new RootBeanDefinition();
	factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJcaListenerContainerFactory");

	factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties);
	factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties);

	return factoryDef;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:JcaListenerContainerParser.java

示例9: registerBeanDefinitions

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
		BeanDefinitionRegistry registry) {
	RootBeanDefinition bd = new RootBeanDefinition();
	bd.setBeanClassName("${mybeanclass}");
	registry.registerBeanDefinition("mybean", bd);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:8,代码来源:ConditionalOnBeanTests.java

示例10: createContainer

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
protected RootBeanDefinition createContainer(Element containerEle, Element listenerEle, ParserContext parserContext,
		PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) {

	RootBeanDefinition containerDef = new RootBeanDefinition();
	containerDef.setSource(parserContext.extractSource(containerEle));
	containerDef.getPropertyValues().addPropertyValues(commonContainerProperties);
	containerDef.getPropertyValues().addPropertyValues(specificContainerProperties);

	String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
	String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
	if (!"".equals(containerClass)) {
		containerDef.setBeanClassName(containerClass);
	}
	else if ("".equals(containerType) || containerType.startsWith("default")) {
		containerDef.setBeanClassName("org.springframework.jms.listener.DefaultMessageListenerContainer");
	}
	else if (containerType.startsWith("simple")) {
		containerDef.setBeanClassName("org.springframework.jms.listener.SimpleMessageListenerContainer");
	}
	else {
		parserContext.getReaderContext().error(
				"Invalid 'container-type' attribute: only \"default\" and \"simple\" supported.", containerEle);
	}

	// Parse listener specific settings
	parseListenerConfiguration(listenerEle, parserContext, containerDef.getPropertyValues());

	return containerDef;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:JmsListenerContainerParser.java

示例11: testGenericsBasedFieldInjectionWithSimpleMatchAndMockito

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Test
public void testGenericsBasedFieldInjectionWithSimpleMatchAndMockito() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	RootBeanDefinition bd = new RootBeanDefinition(RepositoryFieldInjectionBeanWithSimpleMatch.class);
	bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	bf.registerBeanDefinition("annotatedBean", bd);

	RootBeanDefinition rbd = new RootBeanDefinition();
	rbd.setBeanClassName(Mockito.class.getName());
	rbd.setFactoryMethodName("mock");
	// TypedStringValue used to be equivalent to an XML-defined argument String
	rbd.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue(Repository.class.getName()));
	bf.registerBeanDefinition("repo", rbd);

	RepositoryFieldInjectionBeanWithSimpleMatch bean = (RepositoryFieldInjectionBeanWithSimpleMatch) bf.getBean("annotatedBean");
	Repository repo = bf.getBean("repo", Repository.class);
	assertSame(repo, bean.repository);
	assertSame(repo, bean.stringRepository);
	assertSame(1, bean.repositoryArray.length);
	assertSame(1, bean.stringRepositoryArray.length);
	assertSame(repo, bean.repositoryArray[0]);
	assertSame(repo, bean.stringRepositoryArray[0]);
	assertSame(1, bean.repositoryList.size());
	assertSame(1, bean.stringRepositoryList.size());
	assertSame(repo, bean.repositoryList.get(0));
	assertSame(repo, bean.stringRepositoryList.get(0));
	assertSame(1, bean.repositoryMap.size());
	assertSame(1, bean.stringRepositoryMap.size());
	assertSame(repo, bean.repositoryMap.get("repo"));
	assertSame(repo, bean.stringRepositoryMap.get("repo"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:36,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例12: parseListener

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
private void parseListener(Element containerEle, Element listenerEle, ParserContext parserContext,
		PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) {

	RootBeanDefinition listenerDef = new RootBeanDefinition();
	listenerDef.setSource(parserContext.extractSource(listenerEle));
	listenerDef.setBeanClassName("org.springframework.jms.listener.adapter.MessageListenerAdapter");

	String ref = listenerEle.getAttribute(REF_ATTRIBUTE);
	if (!StringUtils.hasText(ref)) {
		parserContext.getReaderContext().error(
				"Listener 'ref' attribute contains empty value.", listenerEle);
	}
	else {
		listenerDef.getPropertyValues().add("delegate", new RuntimeBeanReference(ref));
	}

	String method = null;
	if (listenerEle.hasAttribute(METHOD_ATTRIBUTE)) {
		method = listenerEle.getAttribute(METHOD_ATTRIBUTE);
		if (!StringUtils.hasText(method)) {
			parserContext.getReaderContext().error(
					"Listener 'method' attribute contains empty value.", listenerEle);
		}
	}
	listenerDef.getPropertyValues().add("defaultListenerMethod", method);

	PropertyValue messageConverterPv = commonContainerProperties.getPropertyValue("messageConverter");
	if (messageConverterPv != null) {
		listenerDef.getPropertyValues().addPropertyValue(messageConverterPv);
	}

	BeanDefinition containerDef = createContainer(
			containerEle, listenerEle, parserContext, commonContainerProperties, specificContainerProperties);
	containerDef.getPropertyValues().add("messageListener", listenerDef);

	if (listenerEle.hasAttribute(RESPONSE_DESTINATION_ATTRIBUTE)) {
		String responseDestination = listenerEle.getAttribute(RESPONSE_DESTINATION_ATTRIBUTE);
		Boolean pubSubDomain = (Boolean) commonContainerProperties.getPropertyValue("replyPubSubDomain").getValue();
		listenerDef.getPropertyValues().add(
				pubSubDomain ? "defaultResponseTopicName" : "defaultResponseQueueName", responseDestination);
		if (containerDef.getPropertyValues().contains("destinationResolver")) {
			listenerDef.getPropertyValues().add("destinationResolver",
					containerDef.getPropertyValues().getPropertyValue("destinationResolver").getValue());
		}
	}


	String containerBeanName = listenerEle.getAttribute(ID_ATTRIBUTE);
	// If no bean id is given auto generate one using the ReaderContext's BeanNameGenerator
	if (!StringUtils.hasText(containerBeanName)) {
		containerBeanName = parserContext.getReaderContext().generateBeanName(containerDef);
	}

	// Register the listener and fire event
	parserContext.registerBeanComponent(new BeanComponentDefinition(containerDef, containerBeanName));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:57,代码来源:AbstractListenerContainerParser.java

示例13: inject

import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
protected void inject(Object bean, String beanName, PropertyValues pvs) throws Throwable {
    Field field = (Field) this.member;
    //find consumer field
    //auto initialize dubbo Remote Caller
    DefaultListableBeanFactory factory = (DefaultListableBeanFactory) beanFactory;
    RootBeanDefinition beanDefinition = new RootBeanDefinition();
    beanDefinition.setBeanClass(ConsumerBean.class);
    beanDefinition.setLazyInit(false);
    beanDefinition.setBeanClassName(ConsumerBean.class.getName());

    ConstructorArgumentValues values = new ConstructorArgumentValues();
    values.addIndexedArgumentValue(0, field.getType().getName());

    beanDefinition.setConstructorArgumentValues(values);


    factory.registerBeanDefinition(field.getName(), beanDefinition);

    try {
        Object value;
        if (this.cached) {
            value = resolvedCachedArgument(beanName, this.cachedFieldValue);
        }
        else {
            DependencyDescriptor descriptor = new DependencyDescriptor(field, this.required);
            Set<String> autowiredBeanNames = new LinkedHashSet<String>(1);
            TypeConverter typeConverter = beanFactory.getTypeConverter();
            value = beanFactory.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
            synchronized (this) {
                if (!this.cached) {
                    if (value != null || this.required) {
                        this.cachedFieldValue = descriptor;
                        registerDependentBeans(beanName, autowiredBeanNames);
                        if (autowiredBeanNames.size() == 1) {
                            String autowiredBeanName = autowiredBeanNames.iterator().next();
                            if (beanFactory.containsBean(autowiredBeanName)) {
                                if (beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
                                    this.cachedFieldValue = new RuntimeBeanReference(autowiredBeanName);
                                }
                            }
                        }
                    }
                    else {
                        this.cachedFieldValue = null;
                    }
                    this.cached = true;
                }
            }
        }
        if (value != null) {
            ReflectionUtils.makeAccessible(field);
            field.set(bean, value);
        }
    }
    catch (Throwable ex) {
        throw new BeanCreationException("Could not autowire field: " + field, ex);
    }
}
 
开发者ID:xyp260466,项目名称:dubbo-lite,代码行数:60,代码来源:DubboConsumerAnnotationBeanPostProcessor.java


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