this.attributeInfo = attributeInfo;
this.name = attributeInfo.getName();
try {
this.type = ClassLoading.loadClass(attributeInfo.getType(), gbeanInstance.getBundle());
} catch (ClassNotFoundException e) {
throw new InvalidConfigurationException("Could not load attribute class: " + attributeInfo.getType(), e);
}
this.persistent = attributeInfo.isPersistent();
this.manageable = attributeInfo.isManageable();
this.encrypted = attributeInfo.getEncryptedSetting();
readable = attributeInfo.isReadable();
writable = attributeInfo.isWritable();
// If attribute is persistent or not tagged as unreadable, search for a
// getter method
if (attributeInfo instanceof DynamicGAttributeInfo) {
this.dynamic = true;
if (readable) {
getInvoker = new DynamicGetterMethodInvoker(name);
} else {
getInvoker = null;
}
if (writable) {
setInvoker = new DynamicSetterMethodInvoker(name);
} else {
setInvoker = null;
}
} else {
this.dynamic = false;
if (attributeInfo.getGetterName() != null) {
try {
String getterName = attributeInfo.getGetterName();
Method getterMethod = gbeanInstance.getType().getMethod(getterName, (Class[])null);
if (!getterMethod.getReturnType().equals(type)) {
if (getterMethod.getReturnType().getName().equals(type.getName())) {
throw new InvalidConfigurationException("Getter return type in wrong classloader: type: " + type + " wanted in classloader: " + type.getClassLoader() + " actual: " + getterMethod.getReturnType().getClassLoader());
} else {
throw new InvalidConfigurationException("Getter method of wrong type: " + getterMethod.getReturnType() + " expected " + getDescription());
}
}
if (AbstractGBeanReference.NO_PROXY) {
getInvoker = new ReflectionMethodInvoker(getterMethod);
} else {
getInvoker = new FastMethodInvoker(getterMethod);
}
} catch (NoSuchMethodException e) {
throw new InvalidConfigurationException("Getter method not found " + getDescription(), e);
} catch (NoClassDefFoundError e) {
throw new InvalidConfigurationException("Getter method not found " + getDescription(), e);
}
} else {
getInvoker = null;
}
// If attribute is persistent or not tagged as unwritable, search for a setter method
if (attributeInfo.getSetterName() != null) {
try {
String setterName = attributeInfo.getSetterName();
Method setterMethod = gbeanInstance.getType().getMethod(setterName, type);
if (AbstractGBeanReference.NO_PROXY) {
setInvoker = new ReflectionMethodInvoker(setterMethod);
} else {
setInvoker = new FastMethodInvoker(setterMethod);
}
} catch (NoSuchMethodException e) {
throw new InvalidConfigurationException("Setter method not found " + getDescription(), e);
}
} else {
setInvoker = null;
}
}