Example usage for org.springframework.beans ExtendedBeanInfo ExtendedBeanInfo

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

Introduction

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

Prototype

public ExtendedBeanInfo(BeanInfo delegate) 

Source Link

Document

Wrap the given BeanInfo instance; copy all its existing property descriptors locally, wrapping each in a custom SimpleIndexedPropertyDescriptor indexed or SimplePropertyDescriptor non-indexed PropertyDescriptor variant that bypasses default JDK weak/soft reference management; then search through its method descriptors to find any non-void returning write methods and update or create the corresponding PropertyDescriptor for each one found.

Usage

From source file:org.grails.beans.support.CachedIntrospectionResults.java

/**
 * Create a new CachedIntrospectionResults instance for the given class.
 * @param beanClass the bean class to analyze
 * @throws BeansException in case of introspection failure
 *///w  ww  . j  ava  2  s  .c  om
private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
    try {
        BeanInfo beanInfo = new ExtendedBeanInfo(Introspector.getBeanInfo(beanClass));
        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;

        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.equals(beanClass)
                    && ("classLoader".equals(pd.getName()) || "protectionDomain".equals(pd.getName()))) {
                // Ignore Class.getClassLoader() and getProtectionDomain() methods - nobody needs to bind to those
                continue;
            }
            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);
    }
}