當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanFactoryUtils.transformedBeanName方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanFactoryUtils.transformedBeanName方法的具體用法?Java BeanFactoryUtils.transformedBeanName怎麽用?Java BeanFactoryUtils.transformedBeanName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.BeanFactoryUtils的用法示例。


在下文中一共展示了BeanFactoryUtils.transformedBeanName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getType

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
	String beanName = BeanFactoryUtils.transformedBeanName(name);

	Object bean = this.beans.get(beanName);
	if (bean == null) {
		throw new NoSuchBeanDefinitionException(beanName,
				"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
	}

	if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
		// If it's a FactoryBean, we want to look at what it creates, not the factory class.
		return ((FactoryBean<?>) bean).getObjectType();
	}
	return bean.getClass();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:StaticListableBeanFactory.java

示例2: getLifecycleBeans

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
/**
 * Retrieve all applicable Lifecycle beans: all singletons that have already been created,
 * as well as all SmartLifecycle beans (even if they are marked as lazy-init).
 * @return the Map of applicable beans, with bean names as keys and bean instances as values
 */
protected Map<String, Lifecycle> getLifecycleBeans() {
	Map<String, Lifecycle> beans = new LinkedHashMap<String, Lifecycle>();
	String[] beanNames = this.beanFactory.getBeanNamesForType(Lifecycle.class, false, false);
	for (String beanName : beanNames) {
		String beanNameToRegister = BeanFactoryUtils.transformedBeanName(beanName);
		boolean isFactoryBean = this.beanFactory.isFactoryBean(beanNameToRegister);
		String beanNameToCheck = (isFactoryBean ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
		if ((this.beanFactory.containsSingleton(beanNameToRegister) &&
				(!isFactoryBean || Lifecycle.class.isAssignableFrom(this.beanFactory.getType(beanNameToCheck)))) ||
				SmartLifecycle.class.isAssignableFrom(this.beanFactory.getType(beanNameToCheck))) {
			Lifecycle bean = this.beanFactory.getBean(beanNameToCheck, Lifecycle.class);
			if (bean != this) {
				beans.put(beanNameToRegister, bean);
			}
		}
	}
	return beans;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:DefaultLifecycleProcessor.java

示例3: isAutowireCandidate

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
/**
 * Determine whether the specified bean definition qualifies as an autowire candidate,
 * to be injected into other beans which declare a dependency of matching type.
 * @param beanName the name of the bean definition to check
 * @param descriptor the descriptor of the dependency to resolve
 * @param resolver the AutowireCandidateResolver to use for the actual resolution algorithm
 * @return whether the bean should be considered as autowire candidate
 */
protected boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor, AutowireCandidateResolver resolver)
		throws NoSuchBeanDefinitionException {

	String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName);
	if (containsBeanDefinition(beanDefinitionName)) {
		return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanDefinitionName), descriptor, resolver);
	}
	else if (containsSingleton(beanName)) {
		return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor, resolver);
	}
	else if (getParentBeanFactory() instanceof DefaultListableBeanFactory) {
		// No bean definition found in this factory -> delegate to parent.
		return ((DefaultListableBeanFactory) getParentBeanFactory()).isAutowireCandidate(beanName, descriptor, resolver);
	}
	else if (getParentBeanFactory() instanceof ConfigurableListableBeanFactory) {
		// If no DefaultListableBeanFactory, can't pass the resolver along.
		return ((ConfigurableListableBeanFactory) getParentBeanFactory()).isAutowireCandidate(beanName, descriptor);
	}
	else {
		return true;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:DefaultListableBeanFactory.java

示例4: getBean

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
@Override
public Object getBean(String name) throws BeansException {
	String beanName = BeanFactoryUtils.transformedBeanName(name);
	Object bean = this.beans.get(beanName);

	if (bean == null) {
		throw new NoSuchBeanDefinitionException(beanName,
				"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
	}

	// Don't let calling code try to dereference the
	// bean factory if the bean isn't a factory
	if (BeanFactoryUtils.isFactoryDereference(name) && !(bean instanceof FactoryBean)) {
		throw new BeanIsNotAFactoryException(beanName, bean.getClass());
	}

	if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
		try {
			return ((FactoryBean<?>) bean).getObject();
		}
		catch (Exception ex) {
			throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex);
		}
	}
	else {
		return bean;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:StaticListableBeanFactory.java

示例5: collectBeanNamesForTypeFromFactoryBeans

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
private void collectBeanNamesForTypeFromFactoryBeans(Set<String> result,
		ConfigurableListableBeanFactory beanFactory, Class<?> type) {
	String[] names = beanFactory.getBeanNamesForType(FactoryBean.class, true,
			false);
	for (String name : names) {
		name = BeanFactoryUtils.transformedBeanName(name);
		BeanDefinition beanDefinition = beanFactory.getBeanDefinition(name);
		Class<?> generic = getFactoryBeanGeneric(beanFactory, beanDefinition,
				name);
		if (generic != null && ClassUtils.isAssignable(type, generic)) {
			result.add(name);
		}
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:BeanTypeRegistry.java

示例6: getBeanDefinitionName

import org.springframework.beans.factory.BeanFactoryUtils; //導入方法依賴的package包/類
public static String getBeanDefinitionName(String beanName) {
	return BeanFactoryUtils.transformedBeanName(beanName);
}
 
開發者ID:pchudzik,項目名稱:springmock,代碼行數:4,代碼來源:FactoryBeanRecognizer.java


注:本文中的org.springframework.beans.factory.BeanFactoryUtils.transformedBeanName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。