List of usage examples for java.beans IntrospectionException getCause
public synchronized Throwable getCause()
From source file:de.unentscheidbar.validation.internal.Beans.java
public static PropertyDescriptor property(Class<?> beanClass, String propertyName) { try {//from ww w.j a v a 2 s. c o m BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propDescriptors = beanInfo.getPropertyDescriptors(); if (propDescriptors == null) { throw new IllegalArgumentException("Class " + beanClass.getName() + " does not provide property descriptors in its bean info."); } for (PropertyDescriptor pd : propDescriptors) { if (pd.getName().equals(propertyName)) { return pd; } } return null; } catch (IntrospectionException e) { throw Throwables.propagate(e.getCause()); } }
From source file:be.fgov.kszbcss.rhq.websphere.component.jdbc.db2.pool.ConnectionContextImpl.java
ConnectionContextImpl(Map<String, Object> properties) { dataSource = new DB2SimpleDataSource(); BeanInfo beanInfo;/*from w ww . j av a 2 s .c o m*/ try { beanInfo = Introspector.getBeanInfo(DB2SimpleDataSource.class); } catch (IntrospectionException ex) { throw new Error(ex); } for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) { String name = descriptor.getName(); if (properties.containsKey(name)) { Object value = properties.get(name); Class<?> propertyType = descriptor.getPropertyType(); if (log.isDebugEnabled()) { log.debug("Setting property " + name + ": propertyType=" + propertyType.getName() + ", value=" + value + " (class=" + (value == null ? "<N/A>" : value.getClass().getName()) + ")"); } if (propertyType != String.class && value instanceof String) { // Need to convert value to correct type if (propertyType == Integer.class || propertyType == Integer.TYPE) { value = Integer.valueOf((String) value); } if (log.isDebugEnabled()) { log.debug("Converted value to " + value + " (class=" + value.getClass().getName() + ")"); } } try { descriptor.getWriteMethod().invoke(dataSource, value); } catch (IllegalArgumentException ex) { throw new RuntimeException("Failed to set '" + name + "' property", ex); } catch (IllegalAccessException ex) { throw new IllegalAccessError(ex.getMessage()); } catch (InvocationTargetException ex) { Throwable cause = ex.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else if (cause instanceof Error) { throw (Error) cause; } else { throw new RuntimeException(ex); } } } } }