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


Java ConcurrentReferenceHashMap类代码示例

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


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

示例1: CachedIntrospectionResults

import org.springframework.util.ConcurrentReferenceHashMap; //导入依赖的package包/类
/**
 * Create a new CachedIntrospectionResults instance for the given class.
 * @param beanClass the bean class to analyze
 * @throws BeansException in case of introspection failure
 */
private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
	try {
		if (logger.isTraceEnabled()) {
			logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]");
		}

		BeanInfo beanInfo = null;
		for (BeanInfoFactory beanInfoFactory : beanInfoFactories) {
			beanInfo = beanInfoFactory.getBeanInfo(beanClass);
			if (beanInfo != null) {
				break;
			}
		}
		if (beanInfo == null) {
			// If none of the factories supported the class, fall back to the default
			beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ?
					Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) :
					Introspector.getBeanInfo(beanClass));
		}
		this.beanInfo = beanInfo;

		if (logger.isTraceEnabled()) {
			logger.trace("Caching PropertyDescriptors for class [" + beanClass.getName() + "]");
		}
		this.propertyDescriptorCache = new LinkedHashMap<String, PropertyDescriptor>();

		// This call is slow so we do it once.
		PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors();
		for (PropertyDescriptor pd : pds) {
			if (Class.class == beanClass &&
					("classLoader".equals(pd.getName()) ||  "protectionDomain".equals(pd.getName()))) {
				// Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those
				continue;
			}
			if (logger.isTraceEnabled()) {
				logger.trace("Found bean property '" + pd.getName() + "'" +
						(pd.getPropertyType() != null ? " of type [" + pd.getPropertyType().getName() + "]" : "") +
						(pd.getPropertyEditorClass() != null ?
								"; editor [" + pd.getPropertyEditorClass().getName() + "]" : ""));
			}
			pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd);
			this.propertyDescriptorCache.put(pd.getName(), pd);
		}

		this.typeDescriptorCache = new ConcurrentReferenceHashMap<PropertyDescriptor, TypeDescriptor>();
	}
	catch (IntrospectionException ex) {
		throw new FatalBeanException("Failed to obtain BeanInfo for class [" + beanClass.getName() + "]", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:56,代码来源:CachedIntrospectionResults.java


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