public Object getAttribute(String name)
throws AttributeNotFoundException, MBeanException,
ReflectionException {
// Validate the input parameters
if (name == null)
throw new RuntimeOperationsException
(new IllegalArgumentException("Attribute name is null"),
"Attribute name is null");
if( (resource instanceof DynamicMBean) &&
! ( resource instanceof BaseModelMBean )) {
return ((DynamicMBean)resource).getAttribute(name);
}
Method m=managedBean.getGetter(name, this, resource);
Object result = null;
try {
Class<?> declaring = m.getDeclaringClass();
// workaround for catalina weird mbeans - the declaring class is BaseModelMBean.
// but this is the catalina class.
if( declaring.isAssignableFrom(this.getClass()) ) {
result = m.invoke(this, NO_ARGS_PARAM );
} else {
result = m.invoke(resource, NO_ARGS_PARAM );
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null)
t = e;
if (t instanceof RuntimeException)
throw new RuntimeOperationsException
((RuntimeException) t, "Exception invoking method " + name);
else if (t instanceof Error)
throw new RuntimeErrorException
((Error) t, "Error invoking method " + name);
else