use of com.google.errorprone.annotations.Var in project infrautils by opendaylight.
the class AbstractMXBean method readMBeanAttribute.
/**
* Read an mbean attribute from the platform MBean server.
*
* @return Object if successfully executed, "" otherwise.
*/
public Object readMBeanAttribute(String attribute) {
@Var Object attributeObj = "";
try {
ObjectName objectName = this.getMBeanObjectName();
MBeanServer platformMbeanServer = ManagementFactory.getPlatformMBeanServer();
attributeObj = platformMbeanServer.getAttribute(objectName, attribute);
} catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
LOG.info("Failed when reading MBean attribute", e);
}
return attributeObj;
}
use of com.google.errorprone.annotations.Var in project infrautils by opendaylight.
the class AbstractMXBean method invokeMBeanFunction.
/**
* invoke an mbean function with the platform MBean server.
*
* @return Object if successfully executed, "" otherwise.
*/
public Object invokeMBeanFunction(String functionName) {
@Var Object result = "";
try {
ObjectName objectName = this.getMBeanObjectName();
MBeanServer mplatformMbeanServer = ManagementFactory.getPlatformMBeanServer();
result = mplatformMbeanServer.invoke(objectName, functionName, null, null);
} catch (InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
LOG.error("Failed when executing MBean function", e);
}
return result;
}
Aggregations