Example usage for org.springframework.beans CachedIntrospectionResults CachedIntrospectionResults

List of usage examples for org.springframework.beans CachedIntrospectionResults CachedIntrospectionResults

Introduction

In this page you can find the example usage for org.springframework.beans CachedIntrospectionResults CachedIntrospectionResults.

Prototype

private CachedIntrospectionResults(Class<?> beanClass) throws BeansException 

Source Link

Document

Create a new CachedIntrospectionResults instance for the given class.

Usage

From source file:org.springframework.beans.CachedIntrospectionResults.java

/**
 * Create CachedIntrospectionResults for the given bean class.
 * @param beanClass the bean class to analyze
 * @return the corresponding CachedIntrospectionResults
 * @throws BeansException in case of introspection failure
 *//*www.java 2 s  . com*/
@SuppressWarnings("unchecked")
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
    CachedIntrospectionResults results = strongClassCache.get(beanClass);
    if (results != null) {
        return results;
    }
    results = softClassCache.get(beanClass);
    if (results != null) {
        return results;
    }

    results = new CachedIntrospectionResults(beanClass);
    ConcurrentMap<Class<?>, CachedIntrospectionResults> classCacheToUse;

    if (ClassUtils.isCacheSafe(beanClass, CachedIntrospectionResults.class.getClassLoader())
            || isClassLoaderAccepted(beanClass.getClassLoader())) {
        classCacheToUse = strongClassCache;
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug(
                    "Not strongly caching class [" + beanClass.getName() + "] because it is not cache-safe");
        }
        classCacheToUse = softClassCache;
    }

    CachedIntrospectionResults existing = classCacheToUse.putIfAbsent(beanClass, results);
    return (existing != null ? existing : results);
}