當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。