use of javax.management.AttributeNotFoundException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method getAttribute.
public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("Object name cannot be null"), "Exception occurred trying to invoke the getter on the MBean");
}
if (attribute == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("Attribute cannot be null"), "Exception occurred trying to invoke the getter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "getAttribute", "Attribute = " + attribute + ", ObjectName = " + name);
}
final DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, attribute, name, "getAttribute");
try {
return instance.getAttribute(attribute);
} catch (AttributeNotFoundException e) {
throw e;
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
// not reached
throw new AssertionError();
}
}
use of javax.management.AttributeNotFoundException in project tomcat70 by apache.
the class ContextResourceLinkMBean method getAttribute.
// ----------------------------------------------------- Instance Variables
// ------------------------------------------------------------- Attributes
/**
* Obtain and return the value of a specific attribute of this MBean.
*
* @param name Name of the requested attribute
*
* @exception AttributeNotFoundException if this attribute is not
* supported by this MBean
* @exception MBeanException if the initializer of an object
* throws an exception
* @exception ReflectionException if a Java reflection exception
* occurs when invoking the getter
*/
@Override
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");
ContextResourceLink cl = null;
try {
cl = (ContextResourceLink) getManagedResource();
} catch (InstanceNotFoundException e) {
throw new MBeanException(e);
} catch (InvalidTargetObjectTypeException e) {
throw new MBeanException(e);
}
String value = null;
if ("global".equals(name)) {
return (cl.getGlobal());
} else if ("description".equals(name)) {
return (cl.getDescription());
} else if ("name".equals(name)) {
return (cl.getName());
} else if ("type".equals(name)) {
return (cl.getType());
} else {
value = (String) cl.getProperty(name);
if (value == null) {
throw new AttributeNotFoundException("Cannot find attribute " + name);
}
}
return value;
}
use of javax.management.AttributeNotFoundException in project tomcat70 by apache.
the class ManagedBean method getGetter.
Method getGetter(String aname, BaseModelMBean mbean, Object resource) throws AttributeNotFoundException, ReflectionException {
Method m = null;
AttributeInfo attrInfo = attributes.get(aname);
// Look up the actual operation to be used
if (attrInfo == null)
throw new AttributeNotFoundException(" Cannot find attribute " + aname + " for " + resource);
String getMethod = attrInfo.getGetMethod();
if (getMethod == null)
throw new AttributeNotFoundException("Cannot find attribute " + aname + " get method name");
Object object = null;
NoSuchMethodException exception = null;
try {
object = mbean;
m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
} catch (NoSuchMethodException e) {
exception = e;
}
if (m == null && resource != null) {
try {
object = resource;
m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
exception = null;
} catch (NoSuchMethodException e) {
exception = e;
}
}
if (exception != null)
throw new ReflectionException(exception, "Cannot find getter method " + getMethod);
return m;
}
use of javax.management.AttributeNotFoundException in project tomcat70 by apache.
the class BaseModelMBean method getAttribute.
// key: operation val: invoke method
// private Hashtable invokeAttMap=new Hashtable();
/**
* Obtain and return the value of a specific attribute of this MBean.
*
* @param name Name of the requested attribute
*
* @exception AttributeNotFoundException if this attribute is not
* supported by this MBean
* @exception MBeanException if the initializer of an object
* throws an exception
* @exception ReflectionException if a Java reflection exception
* occurs when invoking the getter
*/
@Override
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();
// 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
throw new MBeanException(e, "Exception invoking method " + name);
} catch (Exception e) {
throw new MBeanException(e, "Exception invoking method " + name);
}
// FIXME - should we validate the return type?
return (result);
}
use of javax.management.AttributeNotFoundException in project acs-aem-commons by Adobe-Consulting-Services.
the class ThrottledTaskRunnerImpl method getMemoryUsage.
@Override
public final double getMemoryUsage() {
try {
Object memoryusage = mbs.getAttribute(memBeanName, "HeapMemoryUsage");
CompositeData cd = (CompositeData) memoryusage;
long max = (Long) cd.get("max");
long used = (Long) cd.get("used");
return (double) used / (double) max;
} catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e) {
LOG.error("No Memory stats found for HeapMemoryUsage", e);
return -1;
}
}
Aggregations