use of org.directwebremoting.impl.PropertyDescriptorProperty in project ma-core-public by infiniteautomation.
the class ExceptionConverter method fixMissingThrowableProperty.
/**
* Make sure Throwable's standard properties are added
* (fix for Bean Introspector peculiarities)
* @param descriptors The Map of the known descriptors
* @param name The name of the property to add
* @param readMethodName A method name to use when getting said property
* @throws IntrospectionException If we fail to build a PropertyDescriptor
*/
protected void fixMissingThrowableProperty(Map descriptors, String name, String readMethodName) throws IntrospectionException {
if (!descriptors.containsKey(name) && isAllowedByIncludeExcludeRules(name)) {
PropertyDescriptor descriptor = new PropertyDescriptor(name, Throwable.class, readMethodName, null);
descriptors.put(name, new PropertyDescriptorProperty(descriptor));
}
}
use of org.directwebremoting.impl.PropertyDescriptorProperty in project ma-core-public by infiniteautomation.
the class BeanConverter method getPropertyMapFromClass.
/* (non-Javadoc)
* @see org.directwebremoting.extend.NamedConverter#getPropertyMap(java.lang.Class, boolean, boolean)
*/
public Map getPropertyMapFromClass(Class type, boolean readRequired, boolean writeRequired) throws MarshallException {
try {
BeanInfo info = Introspector.getBeanInfo(type);
PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
Map properties = new HashMap();
for (int i = 0; i < descriptors.length; i++) {
PropertyDescriptor descriptor = descriptors[i];
String name = descriptor.getName();
// We don't marshall getClass()
if (name.equals("class")) {
continue;
}
// Access rules mean we might not want to do this one
if (!isAllowedByIncludeExcludeRules(name)) {
continue;
}
if (readRequired && descriptor.getReadMethod() == null) {
continue;
}
if (writeRequired && descriptor.getWriteMethod() == null) {
continue;
}
properties.put(name, new PropertyDescriptorProperty(descriptor));
}
return properties;
} catch (IntrospectionException ex) {
throw new MarshallException(type, ex);
}
}
Aggregations