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


Java BeanDefinitionHolder.getBeanName方法代码示例

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


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

示例1: registerBeanDefinition

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
/**
 * Register the given bean definition with the given bean factory.
 * @param definitionHolder the bean definition including name and aliases
 * @param registry the bean factory to register with
 * @throws BeanDefinitionStoreException if registration failed
 */
public static void registerBeanDefinition(
		BeanDefinitionHolder definitionHolder, BeanDefinitionRegistry registry)
		throws BeanDefinitionStoreException {

	// Register bean definition under primary name.
	String beanName = definitionHolder.getBeanName();
	registry.registerBeanDefinition(beanName, definitionHolder.getBeanDefinition());

	// Register aliases for bean name, if any.
	String[] aliases = definitionHolder.getAliases();
	if (aliases != null) {
		for (String alias : aliases) {
			registry.registerAlias(beanName, alias);
		}
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:23,代码来源:BeanDefinitionReaderUtils.java

示例2: register

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public static BeanDefinitionHolder register(Element ele, BeanDefinitionHolder bdHolder, ParserContext parserContext) {
	if (bdHolder != null) {
		String name = bdHolder.getBeanName();
		checkReservedName(name, ele, parserContext);
		checkUniqueName(name, parserContext.getRegistry());
		try {
			// add non-lenient constructor resolution
			BeanDefinition beanDefinition = bdHolder.getBeanDefinition();
			if (beanDefinition instanceof AbstractBeanDefinition) {
				AbstractBeanDefinition abd = (AbstractBeanDefinition) beanDefinition;
				abd.setLenientConstructorResolution(false);
				abd.setNonPublicAccessAllowed(false);
			}

			// Register the final decorated instance.
			BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, parserContext.getRegistry());
		} catch (BeanDefinitionStoreException ex) {
			parserContext.getReaderContext().error(
					"Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex);
		}
		// register component (and send registration events)
		parserContext.registerComponent(new BeanComponentDefinition(bdHolder));
	}
	return bdHolder;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:ParsingUtils.java

示例3: registerBeanDefinition

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
/**
 * Register the given bean definition with the given bean factory.
 * @param definitionHolder the bean definition including name and aliases
 * @param registry the bean factory to register with
 * @throws BeanDefinitionStoreException if registration failed
 */
public static void registerBeanDefinition(
		BeanDefinitionHolder definitionHolder, BeanDefinitionRegistry registry)
		throws BeanDefinitionStoreException {

	// Register bean definition under primary name.
	String beanName = definitionHolder.getBeanName();
	registry.registerBeanDefinition(beanName, definitionHolder.getBeanDefinition());

	// Register aliases for bean name, if any.
	String[] aliases = definitionHolder.getAliases();
	if (aliases != null) {
		for (String aliase : aliases) {
			registry.registerAlias(beanName, aliase);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:BeanDefinitionReaderUtils.java

示例4: testGetAnonymousInnerBeanFromScope

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
@Test
public void testGetAnonymousInnerBeanFromScope() throws Exception {
	TestBean bean = (TestBean) this.beanFactory.getBean("outerBean");
	assertFalse(AopUtils.isAopProxy(bean));
	assertTrue(AopUtils.isCglibProxy(bean.getSpouse()));

	BeanDefinition beanDef = this.beanFactory.getBeanDefinition("outerBean");
	BeanDefinitionHolder innerBeanDef =
			(BeanDefinitionHolder) beanDef.getPropertyValues().getPropertyValue("spouse").getValue();
	String name = innerBeanDef.getBeanName();

	MockHttpServletRequest request = new MockHttpServletRequest();
	RequestAttributes requestAttributes = new ServletRequestAttributes(request);
	RequestContextHolder.setRequestAttributes(requestAttributes);

	try {
		assertNull(request.getAttribute("scopedTarget." + name));
		assertEquals("scoped", bean.getSpouse().getName());
		assertNotNull(request.getAttribute("scopedTarget." + name));
		assertEquals(TestBean.class, request.getAttribute("scopedTarget." + name).getClass());
		assertEquals("scoped", ((TestBean) request.getAttribute("scopedTarget." + name)).getName());
	}
	finally {
		RequestContextHolder.setRequestAttributes(null);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:RequestScopedProxyTests.java

示例5: doScan

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
@Override
public Set<BeanDefinitionHolder> doScan(String... basePackages) {
	Set<BeanDefinitionHolder> beanDefinitions = super.doScan(basePackages);
	for (BeanDefinitionHolder holder : beanDefinitions) {
		GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
		String id = getValue(definition);
		if (StringUtils.isEmpty(id)) {
			id = holder.getBeanName();
		}
		String className = holder.getBeanDefinition().getBeanClassName();
		// logger.info("holder:" + holder.getBeanName() + " className:" + className);
		OptionData.load(id, className);
		definition.getPropertyValues().add("innerClassName", definition.getBeanClassName());
		definition.setBeanClass(OptionFactoryBean.class);
	}
	return beanDefinitions;
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:18,代码来源:OptionScanner.java

示例6: postProcessBeanDefinitionRegistry

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
    ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) registry;

    BeanDefinitionHolder dataSourceInfo = getDataSourceBeanDefinition(beanFactory, databaseAnnotation);

    RootBeanDefinition dataSourceDefinition = new RootBeanDefinition();
    dataSourceDefinition.setPrimary(dataSourceInfo.getBeanDefinition().isPrimary());

    BeanDefinitionHolder flywayInfo = getFlywayBeanDefinition(beanFactory, flywayAnnotation);
    if (flywayInfo == null) {
        dataSourceDefinition.setBeanClass(EmptyEmbeddedPostgresDataSourceFactoryBean.class);
    } else {
        String contextBeanName = flywayInfo.getBeanName() + "DataSourceContext";
        RootBeanDefinition dataSourceContextDefinition = new RootBeanDefinition();
        dataSourceContextDefinition.setBeanClass(FlywayDataSourceContext.class);
        registry.registerBeanDefinition(contextBeanName, dataSourceContextDefinition);

        dataSourceDefinition.setBeanClass(FlywayEmbeddedPostgresDataSourceFactoryBean.class);

        dataSourceDefinition.getConstructorArgumentValues()
                .addIndexedArgumentValue(0, flywayInfo.getBeanName());
        dataSourceDefinition.getConstructorArgumentValues()
                .addIndexedArgumentValue(1, new RuntimeBeanReference(contextBeanName));
    }

    logger.info("Replacing '{}' DataSource bean with embedded version", dataSourceInfo.getBeanName());
    registry.registerBeanDefinition(dataSourceInfo.getBeanName(), dataSourceDefinition);
}
 
开发者ID:zonkyio,项目名称:embedded-database-spring-test,代码行数:30,代码来源:EmbeddedPostgresContextCustomizerFactory.java

示例7: decorate

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
	BeanDefinition trackingBppDef = createTrackerBpp((Element) node, definition);
	// append the tracked bean name to the generated name for easier debugging
	String generatedName =
			parserContext.getReaderContext().generateBeanName(trackingBppDef)
					+ BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + definition.getBeanName();

	parserContext.getRegistry().registerBeanDefinition(generatedName, trackingBppDef);
	return definition;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:ManagedPropertiesDefinitionParser.java

示例8: decorate

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
/**
 * Registers an &lt;dwr:remote ... /&gt; element.
 */
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
{
    Element element = (Element) node;

    String javascript = element.getAttribute("javascript");

    BeanDefinitionBuilder beanCreator = BeanDefinitionBuilder.rootBeanDefinition(BeanCreator.class);

    try
    {
        String beanClassName = resolveBeanClassname(definition.getBeanDefinition(), parserContext.getRegistry());
        if (beanClassName == null) 
        {
            throw new FatalBeanException("Unabled to find type for beanName '" + definition.getBeanName() + 
                                         "'. " + "Check your bean has a correctly configured parent or provide a class for " + 
                                         " the bean definition");
        }
        beanCreator.addPropertyValue("beanClass", ClassUtils.forName(beanClassName));
    }
    catch (ClassNotFoundException e)
    {
        throw new FatalBeanException("Unable to create DWR bean creator for '" + definition.getBeanName() + "'.", e);
    }

    String name = definition.getBeanName();
    if (name.startsWith("scopedTarget."))
    {
        name = name.substring(name.indexOf(".") + 1);
    }
    beanCreator.addPropertyValue("beanId", name);
    beanCreator.addPropertyValue("javascript", javascript);

    BeanDefinitionBuilder creatorConfig = BeanDefinitionBuilder.rootBeanDefinition(CreatorConfig.class);
    creatorConfig.addPropertyValue("creator", beanCreator.getBeanDefinition());            
    registerCreator(parserContext.getRegistry(), javascript, creatorConfig, new HashMap(), node.getChildNodes());

    return definition;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:42,代码来源:DwrNamespaceHandler.java

示例9: decorate

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public BeanDefinitionHolder decorate(Node filterElement, BeanDefinitionHolder parent, ParserContext parserContext)
{
    String name = parent.getBeanName();
    Element element = (Element) filterElement;
    BeanDefinitionRegistry registry = parserContext.getRegistry();
    processFilter(registry, element, name);
    addGlobalFilter(registry, element, name);
    return parent;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:10,代码来源:FilterDecorator.java

示例10: registerComponents

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
@Override
protected void registerComponents(XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {
	super.registerComponents(readerContext, beanDefinitions, element);
	for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
		String beanName = beanDefHolder.getBeanName();
		// TODO ahai 未规范实现
		if (beanName.endsWith("Timer")) {
			timerList.add(beanName);
		}
	}
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:12,代码来源:ComponentScanBeanDefinitionParser.java

示例11: setBeanDefinitionHolder

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public void setBeanDefinitionHolder(BeanDefinitionHolder holder) {
	this.definition = (AbstractBeanDefinition) holder.getBeanDefinition();
	this.beanName = holder.getBeanName();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:GroovyBeanDefinitionWrapper.java

示例12: createScopedProxy

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
/**
 * Generate a scoped proxy for the supplied target bean, registering the target
 * bean with an internal name and setting 'targetBeanName' on the scoped proxy.
 * @param definition the original bean definition
 * @param registry the bean definition registry
 * @param proxyTargetClass whether to create a target class proxy
 * @return the scoped proxy definition
 */
public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder definition,
		BeanDefinitionRegistry registry, boolean proxyTargetClass) {

	String originalBeanName = definition.getBeanName();
	BeanDefinition targetDefinition = definition.getBeanDefinition();
	String targetBeanName = getTargetBeanName(originalBeanName);

	// Create a scoped proxy definition for the original bean name,
	// "hiding" the target bean in an internal target definition.
	RootBeanDefinition proxyDefinition = new RootBeanDefinition(ScopedProxyFactoryBean.class);
	proxyDefinition.setDecoratedDefinition(new BeanDefinitionHolder(targetDefinition, targetBeanName));
	proxyDefinition.setOriginatingBeanDefinition(targetDefinition);
	proxyDefinition.setSource(definition.getSource());
	proxyDefinition.setRole(targetDefinition.getRole());

	proxyDefinition.getPropertyValues().add("targetBeanName", targetBeanName);
	if (proxyTargetClass) {
		targetDefinition.setAttribute(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE, Boolean.TRUE);
		// ScopedProxyFactoryBean's "proxyTargetClass" default is TRUE, so we don't need to set it explicitly here.
	}
	else {
		proxyDefinition.getPropertyValues().add("proxyTargetClass", Boolean.FALSE);
	}

	// Copy autowire settings from original bean definition.
	proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
	proxyDefinition.setPrimary(targetDefinition.isPrimary());
	if (targetDefinition instanceof AbstractBeanDefinition) {
		proxyDefinition.copyQualifiersFrom((AbstractBeanDefinition) targetDefinition);
	}

	// The target bean should be ignored in favor of the scoped proxy.
	targetDefinition.setAutowireCandidate(false);
	targetDefinition.setPrimary(false);

	// Register the target bean as separate bean in the factory.
	registry.registerBeanDefinition(targetBeanName, targetDefinition);

	// Return the scoped proxy definition as primary bean definition
	// (potentially an inner bean).
	return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:ScopedProxyUtils.java

示例13: registerCreator

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public static void registerCreator(BeanDefinitionHolder beanDefinitionHolder, BeanDefinitionRegistry beanDefinitionRegistry, Class<?> beanDefinitionClass, String javascript)
{
    String creatorConfigName = "__" + javascript;
    if (beanDefinitionRegistry.containsBeanDefinition(creatorConfigName))
    {
        log.info("[" + javascript + "] remote bean definition already detected. Invalid mixed use of <dwr:annotation-config /> and <dwr:annotation-scan />? Re-scanned package?");
    }
    else
    {
        BeanDefinitionBuilder beanCreator = BeanDefinitionBuilder.rootBeanDefinition(BeanCreator.class);
        try {
            beanCreator.addPropertyValue("beanClass", beanDefinitionClass);
            String name = beanDefinitionHolder.getBeanName();
            if (name.startsWith("scopedTarget."))
            {
                name = name.substring(name.indexOf(".") + 1);
            }
            beanCreator.addPropertyValue("beanId", name);
            beanCreator.addPropertyValue("javascript", javascript);
            BeanDefinitionBuilder creatorConfig = BeanDefinitionBuilder.rootBeanDefinition(CreatorConfig.class);
            creatorConfig.addPropertyValue("creator", beanCreator.getBeanDefinition());
            List<String> includes = new ArrayList<String>();
            for (Method method : beanDefinitionClass.getMethods()) {
                if (method.getAnnotation(RemoteMethod.class) != null)
                {
                    includes.add(method.getName());
                }
            }
            // Handle the Filter/Filters annotations.
            ManagedList filters = new ManagedList();
            Filter filter = beanDefinitionClass.getAnnotation(Filter.class);
            if (null != filter) {
                processFilter(beanDefinitionRegistry, filter, javascript, filters);
            }
            Filters filtersAnn = beanDefinitionClass.getAnnotation(Filters.class);
            if (filtersAnn != null)
            {
                Filter[] fs = filtersAnn.value();
                for (Filter filterFromFilters : fs)
                {
                    processFilter(beanDefinitionRegistry, filterFromFilters, javascript, filters);
                }
            }
            if (filters.size() > 0) {
                creatorConfig.addPropertyValue("filters", filters);
            }
            // Processing of Filter/Filters complete, continue processing.
            creatorConfig.addPropertyValue("includes", includes);
            BeanDefinitionHolder aux = new BeanDefinitionHolder(creatorConfig.getBeanDefinition(), creatorConfigName);
            BeanDefinitionReaderUtils.registerBeanDefinition(aux, beanDefinitionRegistry);
            lookupCreators(beanDefinitionRegistry).put(javascript, new RuntimeBeanReference(creatorConfigName));
        } catch (Exception ex) {
            throw new FatalBeanException("Unable to create DWR bean creator for '" + beanDefinitionHolder.getBeanName() + "'. ", ex);
        }
    }
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:57,代码来源:CreatorParserHelper.java

示例14: decorate

import org.springframework.beans.factory.config.BeanDefinitionHolder; //导入方法依赖的package包/类
public BeanDefinitionHolder decorate(Node remoteElement, BeanDefinitionHolder bean, ParserContext parserContext)
{
    String name = bean.getBeanName();
    Element element = (Element) remoteElement;
    String javascript = element.getAttribute("javascript");
    BeanDefinitionBuilder beanCreator = BeanDefinitionBuilder.rootBeanDefinition(BeanCreator.class);

    try
    {
        String beanClassName = resolveBeanClassname(bean.getBeanDefinition(), parserContext.getRegistry());
        if (beanClassName == null)
        {
            throw new FatalBeanException("Unabled to find type for beanName '" + name + "'. " + "Check your bean has a correctly configured parent or provide a class for " + " the bean definition");
        }
        beanCreator.addPropertyValue("beanClass", ClassUtils.forName(beanClassName, ClassUtils.getDefaultClassLoader()));
    }
    catch (ClassNotFoundException e)
    {
        throw new FatalBeanException("Unable to create DWR bean creator for '" + name + "'.", e);
    }


    if (name.startsWith("scopedTarget."))
    {
        name = name.substring(name.indexOf(".") + 1);
    }
    if (!StringUtils.hasText(javascript))
    {
        javascript = StringUtils.capitalize(name);
        if (log.isDebugEnabled())
        {
            log.debug("No javascript name provided. Remoting using bean id [" + javascript + "]");
        }
    }
    beanCreator.addPropertyValue("beanId", name);
    beanCreator.addPropertyValue("javascript", javascript);

    BeanDefinitionRegistry registry = parserContext.getRegistry();
    BeanDefinitionBuilder creatorConfig = BeanDefinitionBuilder.rootBeanDefinition(CreatorConfig.class);
    creatorConfig.addPropertyValue("creator", beanCreator.getBeanDefinition());
    configureCreator(registry, javascript, creatorConfig, remoteElement.getChildNodes());
    registerCreator(registry, creatorConfig, javascript);

    return bean;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:46,代码来源:RemoteDecorator.java


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