}
@Override
public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException {
try {
InjectableProperty prop = propertyMap.get(attribute);
if (prop.isArray()) {
// todo - will return a collection instead of an array
return null;
} else if (prop.isCollection()) {
Collection collection = (Collection) prop.getValue(instance);
if (ReflectionInjectableProperty.isReference(prop.getArrayOrCollectionComponentType())) {
return getRefNames(collection);
} else {
return collection;
}
} else if (prop.isMap()) {
Map map = (Map) prop.getValue(instance);
return getRefNames(map, prop);
} else if (prop.isReference()) {
Object ref = prop.getValue(instance);
return loader.findRefName(ref);
} else {
return prop.getValue(instance);
}
} catch (Exception e) {
LOGGER.error("Cannot get attribute", e);
throw new IllegalArgumentException(e.getMessage());
}