private void introspectInterfaces(Class<?> beanClass, Class<?> currClass) throws IntrospectionException { for (Class<?> ifc : currClass.getInterfaces()) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { for (PropertyDescriptor pd : getBeanInfo(ifc).getPropertyDescriptors()) { PropertyDescriptor existingPd = this.propertyDescriptorCache.get(pd.getName()); if (existingPd == null || (existingPd.getReadMethod() == null && pd.getReadMethod() != null)) { // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method // against a declared read method, so we prefer read method descriptors here. pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } } introspectInterfaces(ifc, ifc); } } }
logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]"); this.beanInfo = getBeanInfo(beanClass);
private void introspectInterfaces(Class<?> beanClass, Class<?> currClass) throws IntrospectionException { for (Class<?> ifc : currClass.getInterfaces()) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { for (PropertyDescriptor pd : getBeanInfo(ifc).getPropertyDescriptors()) { PropertyDescriptor existingPd = this.propertyDescriptorCache.get(pd.getName()); if (existingPd == null || (existingPd.getReadMethod() == null && pd.getReadMethod() != null)) { // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method // against a declared read method, so we prefer read method descriptors here. pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } } introspectInterfaces(ifc, ifc); } } }
logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]"); this.beanInfo = getBeanInfo(beanClass);
@Test public void shouldUseExtendedBeanInfoWhenApplicable() throws NoSuchMethodException, SecurityException { // given a class with a non-void returning setter method @SuppressWarnings("unused") class C { public Object setFoo(String s) { return this; } public String getFoo() { return null; } } // CachedIntrospectionResults should delegate to ExtendedBeanInfo CachedIntrospectionResults results = CachedIntrospectionResults.forClass(C.class); BeanInfo info = results.getBeanInfo(); PropertyDescriptor pd = null; for (PropertyDescriptor candidate : info.getPropertyDescriptors()) { if (candidate.getName().equals("foo")) { pd = candidate; } } // resulting in a property descriptor including the non-standard setFoo method assertThat(pd, notNullValue()); assertThat(pd.getReadMethod(), equalTo(C.class.getMethod("getFoo"))); assertThat( "No write method found for non-void returning 'setFoo' method. " + "Check to see if CachedIntrospectionResults is delegating to " + "ExtendedBeanInfo as expected", pd.getWriteMethod(), equalTo(C.class.getMethod("setFoo", String.class))); }
public PropertyDescriptor[] getPropertyDescriptors() { return this.cachedIntrospectionResults.getBeanInfo().getPropertyDescriptors(); }
/** * Retrieve the JavaBeans <code>PropertyDescriptor</code>s of a given class. * @param clazz the Class to retrieve the PropertyDescriptors for * @return an array of <code>PropertyDescriptors</code> for the given class * @throws BeansException if PropertyDescriptor look fails */ public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws BeansException { CachedIntrospectionResults cr = CachedIntrospectionResults.forClass(clazz); return cr.getBeanInfo().getPropertyDescriptors(); }
beanInfo = beanInfoFactory.getBeanInfo(beanClass); if (beanInfo != null) { break; Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) : Introspector.getBeanInfo(beanClass)); Class<?>[] ifcs = clazz.getInterfaces(); for (Class<?> ifc : ifcs) { BeanInfo ifcInfo = Introspector.getBeanInfo(ifc, Introspector.IGNORE_ALL_BEANINFO); PropertyDescriptor[] ifcPds = ifcInfo.getPropertyDescriptors(); for (PropertyDescriptor pd : ifcPds) {