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


Java RootBeanDefinition类代码示例

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


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

示例1: parseProperties

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
    if (nodeList != null && nodeList.getLength() > 0) {
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if ("property".equals(node.getNodeName())
                        || "property".equals(node.getLocalName())) {
                    String name = ((Element) node).getAttribute("name");
                    if (name != null && name.length() > 0) {
                        String value = ((Element) node).getAttribute("value");
                        String ref = ((Element) node).getAttribute("ref");
                        if (value != null && value.length() > 0) {
                            beanDefinition.getPropertyValues().addPropertyValue(name, value);
                        } else if (ref != null && ref.length() > 0) {
                            beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref));
                        } else {
                            throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:DubboBeanDefinitionParser.java

示例2: customizeContext

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Override
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
    Class<?> testClass = mergedConfig.getTestClass();
    FlywayTest flywayAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, FlywayTest.class);

    BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
    RootBeanDefinition registrarDefinition = new RootBeanDefinition();

    registrarDefinition.setBeanClass(PreloadableEmbeddedPostgresRegistrar.class);
    registrarDefinition.getConstructorArgumentValues()
            .addIndexedArgumentValue(0, databaseAnnotation);
    registrarDefinition.getConstructorArgumentValues()
            .addIndexedArgumentValue(1, flywayAnnotation);

    registry.registerBeanDefinition("preloadableEmbeddedPostgresRegistrar", registrarDefinition);
}
 
开发者ID:zonkyio,项目名称:embedded-database-spring-test,代码行数:17,代码来源:EmbeddedPostgresContextCustomizerFactory.java

示例3: getDefaultKeyValueTemplateBeanDefinition

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
        RepositoryConfigurationSource configurationSource) {
    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(TarantoolKeyValueTemplate.class);

    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
            new RuntimeBeanReference(TARANTOOL_OPS_IMPL_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
            new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(2,
            new RuntimeBeanReference(TARANTOOL_CONVERTER_BEAN_NAME));

    keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:18,代码来源:TarantoolRepositoryConfigurationExtension.java

示例4: doParse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的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

示例5: postProcessBeanDefinitionRegistry

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
/**
 * Derive further bean definitions from the configuration classes in the registry.
 */
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
	RootBeanDefinition iabpp = new RootBeanDefinition(ImportAwareBeanPostProcessor.class);
	iabpp.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	registry.registerBeanDefinition(IMPORT_AWARE_PROCESSOR_BEAN_NAME, iabpp);

	RootBeanDefinition ecbpp = new RootBeanDefinition(EnhancedConfigurationBeanPostProcessor.class);
	ecbpp.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	registry.registerBeanDefinition(ENHANCED_CONFIGURATION_PROCESSOR_BEAN_NAME, ecbpp);

	int registryId = System.identityHashCode(registry);
	if (this.registriesPostProcessed.contains(registryId)) {
		throw new IllegalStateException(
				"postProcessBeanDefinitionRegistry already called for this post-processor against " + registry);
	}
	if (this.factoriesPostProcessed.contains(registryId)) {
		throw new IllegalStateException(
				"postProcessBeanFactory already called for this post-processor against " + registry);
	}
	this.registriesPostProcessed.add(registryId);

	processConfigBeanDefinitions(registry);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ConfigurationClassPostProcessor.java

示例6: doParse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的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

示例7: createAdvisorBeanDefinition

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
/**
 * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong>
 * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes.
 */
private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) {
	RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
	advisorDefinition.setSource(parserContext.extractSource(advisorElement));

	String adviceRef = advisorElement.getAttribute(ADVICE_REF);
	if (!StringUtils.hasText(adviceRef)) {
		parserContext.getReaderContext().error(
				"'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot());
	}
	else {
		advisorDefinition.getPropertyValues().add(
				ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef));
	}

	if (advisorElement.hasAttribute(ORDER_PROPERTY)) {
		advisorDefinition.getPropertyValues().add(
				ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY));
	}

	return advisorDefinition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ConfigBeanDefinitionParser.java

示例8: registerOrEscalateApcAsRequired

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
	Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
	if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
		BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
		if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
			int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName());
			int requiredPriority = findPriorityForClass(cls);
			if (currentPriority < requiredPriority) {
				apcDefinition.setBeanClassName(cls.getName());
			}
		}
		return null;
	}
	RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
	beanDefinition.setSource(source);
	beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);
	beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition);
	return beanDefinition;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AopConfigUtils.java

示例9: parse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    RootBeanDefinition beanDefinition = new RootBeanDefinition();
    beanDefinition.setBeanClass(beanClass);
    beanDefinition.setLazyInit(false);

    String key = element.getAttribute("key");
    String value = element.getAttribute("value");
    String hide = element.getAttribute("hide");
    if(CommonUtils.isTrue(hide)){
        JSFContext.putGlobalVal(Constants.HIDE_KEY_PREFIX + key, value);
    } else {
        JSFContext.putGlobalVal(key, value);
    }

    beanDefinition.getPropertyValues().addPropertyValue("key", key);
    beanDefinition.getPropertyValues().addPropertyValue("value", value);
    beanDefinition.getPropertyValues().addPropertyValue("hide", Boolean.valueOf(hide));

    return beanDefinition;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:22,代码来源:JSFParameterDefinitionParser.java

示例10: makeMethodTrigger

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
public static BeanFactory makeMethodTrigger ( Object o, String method ) throws Exception {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    RootBeanDefinition caller = new RootBeanDefinition();

    caller.setFactoryBeanName("obj");
    caller.setFactoryMethodName(method);
    Reflections.setFieldValue(caller.getMethodOverrides(), "overrides", new HashSet<>());
    bf.registerBeanDefinition("caller", caller);

    Reflections.getField(DefaultListableBeanFactory.class, "beanClassLoader").set(bf, null);
    Reflections.getField(DefaultListableBeanFactory.class, "alreadyCreated").set(bf, new HashSet<>());
    Reflections.getField(DefaultListableBeanFactory.class, "singletonsCurrentlyInCreation").set(bf, new HashSet<>());
    Reflections.getField(DefaultListableBeanFactory.class, "inCreationCheckExclusions").set(bf, new HashSet<>());
    Reflections.getField(DefaultListableBeanFactory.class, "logger").set(bf, new NoOpLog());
    Reflections.getField(DefaultListableBeanFactory.class, "prototypesCurrentlyInCreation").set(bf, new ThreadLocal<>());

    @SuppressWarnings ( "unchecked" )
    Map<String, Object> objs = (Map<String, Object>) Reflections.getFieldValue(bf, "singletonObjects");
    objs.put("obj", o);
    return bf;
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:22,代码来源:SpringUtil.java

示例11: doParse

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
private synchronized void doParse(Element element, ParserContext parserContext) {
    String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute("base-package"), ",; \t\n");
    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME)) {
        Object eleSource = parserContext.extractSource(element);

        RootBeanDefinition configMapDef = new RootBeanDefinition(ConcurrentHashMap.class);
        configMapDef.setSource(eleSource);
        configMapDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        String configMapName = parserContext.getReaderContext().registerWithGeneratedName(configMapDef);

        RootBeanDefinition interceptorDef = new RootBeanDefinition(JetCacheInterceptor.class);
        interceptorDef.setSource(eleSource);
        interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        interceptorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

        RootBeanDefinition advisorDef = new RootBeanDefinition(CacheAdvisor.class);
        advisorDef.setSource(eleSource);
        advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("adviceBeanName", interceptorName));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("basePackages", basePackages));
        parserContext.getRegistry().registerBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME, advisorDef);

        CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
                eleSource);
        compositeDef.addNestedComponent(new BeanComponentDefinition(configMapDef, configMapName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheAdvisor.CACHE_ADVISOR_BEAN_NAME));
        parserContext.registerComponent(compositeDef);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:34,代码来源:CacheAnnotationParser.java

示例12: typeNestedSetBinding

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Test
public void typeNestedSetBinding() throws Exception {
	initServlet(new ApplicationContextInitializer<GenericWebApplicationContext>() {
		@Override
		public void initialize(GenericWebApplicationContext context) {
			RootBeanDefinition csDef = new RootBeanDefinition(FormattingConversionServiceFactoryBean.class);
			csDef.getPropertyValues().add("converters", new TestBeanConverter());
			RootBeanDefinition wbiDef = new RootBeanDefinition(ConfigurableWebBindingInitializer.class);
			wbiDef.getPropertyValues().add("conversionService", csDef);
			RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
			adapterDef.getPropertyValues().add("webBindingInitializer", wbiDef);
			context.registerBeanDefinition("handlerAdapter", adapterDef);
		}
	}, NestedSetController.class);

	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
	request.addParameter("testBeanSet", new String[] {"1", "2"});
	MockHttpServletResponse response = new MockHttpServletResponse();
	getServlet().service(request, response);
	assertEquals("[1, 2]-org.springframework.tests.sample.beans.TestBean", response.getContentAsString());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:ServletAnnotationControllerHandlerMethodTests.java

示例13: getDefaultKeyValueTemplateBeanDefinition

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
		RepositoryConfigurationSource configurationSource) {

	RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(
			VaultKeyValueTemplate.class);

	ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
	constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(0,
			new RuntimeBeanReference(VAULT_ADAPTER_BEAN_NAME));

	constructorArgumentValuesForKeyValueTemplate.addIndexedArgumentValue(1,
			new RuntimeBeanReference(VAULT_MAPPING_CONTEXT_BEAN_NAME));

	keyValueTemplateDefinition
			.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

	return keyValueTemplateDefinition;
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:20,代码来源:VaultRepositoryConfigurationExtension.java

示例14: testMethodInjectionWithMapAndMultipleMatches

import org.springframework.beans.factory.support.RootBeanDefinition; //导入依赖的package包/类
@Test
public void testMethodInjectionWithMapAndMultipleMatches() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(MapMethodInjectionBean.class));
	bf.registerBeanDefinition("testBean1", new RootBeanDefinition(TestBean.class));
	bf.registerBeanDefinition("testBean2", new RootBeanDefinition(TestBean.class));

	try {
		bf.getBean("annotatedBean");
		fail("should have failed, more than one bean of type");
	}
	catch (BeanCreationException e) {
		// expected
	}
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例15: testGenericsBasedFactoryBeanInjectionWithBeanDefinition

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

	RepositoryFactoryBeanInjectionBean bean = (RepositoryFactoryBeanInjectionBean) bf.getBean("annotatedBean");
	RepositoryFactoryBean repoFactoryBean = bf.getBean("&repoFactoryBean", RepositoryFactoryBean.class);
	assertSame(repoFactoryBean, bean.repositoryFactoryBean);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:AutowiredAnnotationBeanPostProcessorTests.java


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