use of java.beans.IntrospectionException in project adempiere by adempiere.
the class VTextBeanInfo method getPropertyDescriptors.
public PropertyDescriptor[] getPropertyDescriptors() {
try {
PropertyDescriptor _background = new PropertyDescriptor("background", beanClass, null, "setBackground");
PropertyDescriptor _border = new PropertyDescriptor("border", beanClass, null, "setBorder");
PropertyDescriptor _display = new PropertyDescriptor("display", beanClass, "getDisplay", null);
PropertyDescriptor _editable = new PropertyDescriptor("editable", beanClass, "isEditable", "setEditable");
PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, null, "setFont");
PropertyDescriptor _foreground = new PropertyDescriptor("foreground", beanClass, null, "setForeground");
PropertyDescriptor _mandatory = new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory");
PropertyDescriptor _value = new PropertyDescriptor("value", beanClass, "getValue", "setValue");
PropertyDescriptor[] pds = new PropertyDescriptor[] { _background, _border, _display, _editable, _font, _foreground, _mandatory, _value };
return pds;
} catch (IntrospectionException ex) {
ex.printStackTrace();
return null;
}
}
use of java.beans.IntrospectionException in project cloudstack by apache.
the class ReflectUtil method flattenProperties.
private static List<String> flattenProperties(final Object target, final Class<?> clazz, final ImmutableSet<String> excludedProperties) {
assert clazz != null;
if (target == null) {
return emptyList();
}
assert clazz.isAssignableFrom(target.getClass());
try {
final BeanInfo beanInfo = getBeanInfo(clazz);
final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
final List<String> serializedProperties = new ArrayList<String>();
for (final PropertyDescriptor descriptor : descriptors) {
if (excludedProperties.contains(descriptor.getName())) {
continue;
}
serializedProperties.add(descriptor.getName());
final Object value = descriptor.getReadMethod().invoke(target);
serializedProperties.add(value != null ? value.toString() : "null");
}
return unmodifiableList(serializedProperties);
} catch (IntrospectionException e) {
s_logger.warn("Ignored IntrospectionException when serializing class " + target.getClass().getCanonicalName(), e);
} catch (IllegalArgumentException e) {
s_logger.warn("Ignored IllegalArgumentException when serializing class " + target.getClass().getCanonicalName(), e);
} catch (IllegalAccessException e) {
s_logger.warn("Ignored IllegalAccessException when serializing class " + target.getClass().getCanonicalName(), e);
} catch (InvocationTargetException e) {
s_logger.warn("Ignored InvocationTargetException when serializing class " + target.getClass().getCanonicalName(), e);
}
return emptyList();
}
use of java.beans.IntrospectionException in project geode by apache.
the class MBeanProxyFactory method createProxy.
/**
* Creates a single proxy and adds a {@link ProxyInfo} to proxy repository
* {@link MBeanProxyInfoRepository}
*
* @param member {@link org.apache.geode.distributed.DistributedMember}
* @param objectName {@link javax.management.ObjectName} of the Bean
* @param monitoringRegion monitoring region containing the proxies
* @throws ManagementException
*/
public void createProxy(DistributedMember member, ObjectName objectName, Region<String, Object> monitoringRegion, Object newVal) {
try {
if (remoteFilterChain.isFiltered(objectName, member, "")) {
if (logger.isTraceEnabled()) {
logger.trace("Returning from filter");
}
return;
}
Class interfaceClass = ClassLoadUtil.classFromName(((FederationComponent) monitoringRegion.get(objectName.toString())).getMBeanInterfaceClass());
Object object = MBeanProxyInvocationHandler.newProxyInstance(member, monitoringRegion, objectName, interfaceClass);
jmxAdapter.registerMBeanProxy(object, objectName);
if (logger.isDebugEnabled()) {
logger.debug("Registered ObjectName : {}", objectName);
}
ProxyInfo proxyInfo = new ProxyInfo(interfaceClass, object, objectName);
proxyRepo.addProxyToRepository(member, proxyInfo);
service.afterCreateProxy(objectName, interfaceClass, object, (FederationComponent) newVal);
if (logger.isDebugEnabled()) {
logger.debug("Proxy Created for : {}", objectName);
}
} catch (ClassNotFoundException e) {
throw new ManagementException(e);
} catch (IntrospectionException e) {
throw new ManagementException(e);
} catch (ManagementException e) {
throw e;
}
}
use of java.beans.IntrospectionException in project yyl_example by Relucent.
the class Bean method main.
public static void main(String[] args) {
Bean bean = new Bean();
//PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(bean.getClass(),Introspector.USE_ALL_BEANINFO);
PropertyDescriptor[] descriptors = null;
try {
descriptors = Introspector.getBeanInfo(bean.getClass(), Introspector.IGNORE_ALL_BEANINFO).getPropertyDescriptors();
} catch (IntrospectionException e) {
descriptors = new PropertyDescriptor[0];
}
for (PropertyDescriptor pd : descriptors) {
System.out.println(pd.getDisplayName());
}
}
use of java.beans.IntrospectionException in project jmeter by apache.
the class CSVDataSet method setProperty.
/**
* Override the setProperty method in order to convert
* the original String shareMode property.
* This used the locale-dependent display value, so caused
* problems when the language was changed.
* If the "shareMode" value matches a resource value then it is converted
* into the resource key.
* To reduce the need to look up resources, we only attempt to
* convert values with spaces in them, as these are almost certainly
* not variables (and they are definitely not resource keys).
*/
@Override
public void setProperty(JMeterProperty property) {
if (property instanceof StringProperty) {
final String propName = property.getName();
if ("shareMode".equals(propName)) {
// The original name of the property
final String propValue = property.getStringValue();
if (propValue.contains(" ")) {
// variables are unlikely to contain spaces, so most likely a translation
try {
final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass());
final ResourceBundle rb = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
for (String resKey : CSVDataSetBeanInfo.getShareTags()) {
if (propValue.equals(rb.getString(resKey))) {
if (log.isDebugEnabled()) {
log.debug("Converted {}={} to {} using Locale: {}", propName, propValue, resKey, rb.getLocale());
}
// reset the value
((StringProperty) property).setValue(resKey);
super.setProperty(property);
return;
}
}
// This could perhaps be a variable name
log.warn("Could not translate {}={} using Locale: {}", propName, propValue, rb.getLocale());
} catch (IntrospectionException e) {
log.error("Could not find BeanInfo; cannot translate shareMode entries", e);
}
}
}
}
super.setProperty(property);
}
Aggregations