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


Java BeanDefinition.getFactoryBeanName方法代码示例

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


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

示例1: SimpleBeanMetadata

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Constructs a new <code>SpringLocalComponentMetadata</code> instance.
 * 
 * @param name bean name
 * @param definition Spring bean definition
 */
public SimpleBeanMetadata(String name, BeanDefinition definition) {
	super(name, definition);

	final String factoryMtd = definition.getFactoryMethodName();
	if (StringUtils.hasText(factoryMtd)) {
		factoryMethod = factoryMtd;
		String factory = definition.getFactoryBeanName();
		if (StringUtils.hasText(factory)) {
			factoryComponent = new SimpleRefMetadata(factory);
		} else {
			factoryComponent = null;
		}
	} else {
		factoryComponent = null;
		factoryMethod = null;
	}

	arguments = MetadataUtils.getBeanArguments(definition);
	properties = MetadataUtils.getBeanProperties(definition);

	// double check if the definition had "scope" declared
	boolean hasAttribute = definition.hasAttribute(BlueprintParser.DECLARED_SCOPE);
	scope = (hasAttribute ? (StringUtils.hasText(name) ? beanDefinition.getScope() : null) : null);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:31,代码来源:SimpleBeanMetadata.java

示例2: getBeanFactoryClassName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Get the Factory class name which corresponds to given bean definition.
 * @param definition Bean definition
 * @param beanFactory Bean factory
 * @return Factory class name, or <code>null</code> if not found
 */
private static String getBeanFactoryClassName(BeanDefinition definition,
		ConfigurableListableBeanFactory beanFactory) {
	if (definition instanceof AnnotatedBeanDefinition) {
		return ((AnnotatedBeanDefinition) definition).getMetadata().getClassName();
	} else {
		if (definition.getFactoryBeanName() != null) {
			BeanDefinition fd = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
			if (fd != null) {
				return fd.getBeanClassName();
			}
		} else {
			return definition.getBeanClassName();
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:23,代码来源:BeanRegistryUtils.java

示例3: postProcessBeanFactory

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    this.beanFactory = beanFactory;
    for (String name : beanFactory.getBeanDefinitionNames()) {
        BeanDefinition definition = beanFactory.getBeanDefinition(name);
        String method = definition.getFactoryMethodName();
        String bean = definition.getFactoryBeanName();
        if (method != null && bean != null) {
            this.beans.put(name, new MetaData(bean, method));
        }
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:13,代码来源:ConfigurationBeanFactoryMetaData.java

示例4: shouldSkip

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Check whether the given bean definition is not subject to the annotation-based
 * required property check as performed by this post-processor.
 * <p>The default implementations check for the presence of the
 * {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any.
 * It also suggests skipping in case of a bean definition with a "factory-bean"
 * reference set, assuming that instance-based factories pre-populate the bean.
 * @param beanFactory the BeanFactory to check against
 * @param beanName the name of the bean to check against
 * @return {@code true} to skip the bean; {@code false} to process it
 */
protected boolean shouldSkip(ConfigurableListableBeanFactory beanFactory, String beanName) {
	if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) {
		return false;
	}
	BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
	if (beanDefinition.getFactoryBeanName() != null) {
		return true;
	}
	Object value = beanDefinition.getAttribute(SKIP_REQUIRED_CHECK_ATTRIBUTE);
	return (value != null && (Boolean.TRUE.equals(value) || Boolean.valueOf(value.toString())));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:RequiredAnnotationBeanPostProcessor.java

示例5: generateBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Generate a bean name for the given bean definition, unique within the
 * given bean factory.
 * @param definition the bean definition to generate a bean name for
 * @param registry the bean factory that the definition is going to be
 * registered with (to check for existing bean names)
 * @param isInnerBean whether the given bean definition will be registered
 * as inner bean or as top-level bean (allowing for special name generation
 * for inner beans versus top-level beans)
 * @return the generated bean name
 * @throws BeanDefinitionStoreException if no unique name can be generated
 * for the given bean definition
 */
public static String generateBeanName(
		BeanDefinition definition, BeanDefinitionRegistry registry, boolean isInnerBean)
		throws BeanDefinitionStoreException {

	String generatedBeanName = definition.getBeanClassName();
	if (generatedBeanName == null) {
		if (definition.getParentName() != null) {
			generatedBeanName = definition.getParentName() + "$child";
		}
		else if (definition.getFactoryBeanName() != null) {
			generatedBeanName = definition.getFactoryBeanName() + "$created";
		}
	}
	if (!StringUtils.hasText(generatedBeanName)) {
		throw new BeanDefinitionStoreException("Unnamed bean definition specifies neither " +
				"'class' nor 'parent' nor 'factory-bean' - can't generate bean name");
	}

	String id = generatedBeanName;
	if (isInnerBean) {
		// Inner bean: generate identity hashcode suffix.
		id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + ObjectUtils.getIdentityHexString(definition);
	}
	else {
		// Top-level bean: use plain class name.
		// Increase counter until the id is unique.
		int counter = -1;
		while (counter == -1 || registry.containsBeanDefinition(id)) {
			counter++;
			id = generatedBeanName + GENERATED_BEAN_NAME_SEPARATOR + counter;
		}
	}
	return id;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:BeanDefinitionReaderUtils.java


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