use of javax.management.modelmbean.ModelMBeanOperationInfo in project jdk8u_jdk by JetBrains.
the class RequiredModelMBeanGetAttributeTest method main.
public static void main(String[] args) throws Exception {
boolean ok = true;
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
// Resource methods
Method nullGetter = Resource.class.getMethod("getNull", (Class[]) null);
Method integerGetter = Resource.class.getMethod("getInteger", (Class[]) null);
Method hashtableGetter = Resource.class.getMethod("getHashtable", (Class[]) null);
Method mapGetter = Resource.class.getMethod("getMap", (Class[]) null);
// ModelMBeanOperationInfo
Descriptor nullOperationDescriptor = new DescriptorSupport(new String[] { "name=getNull", "descriptorType=operation", "role=getter" });
ModelMBeanOperationInfo nullOperationInfo = new ModelMBeanOperationInfo("Null attribute", nullGetter, nullOperationDescriptor);
Descriptor integerOperationDescriptor = new DescriptorSupport(new String[] { "name=getInteger", "descriptorType=operation", "role=getter" });
ModelMBeanOperationInfo integerOperationInfo = new ModelMBeanOperationInfo("Integer attribute", integerGetter, integerOperationDescriptor);
Descriptor hashtableOperationDescriptor = new DescriptorSupport(new String[] { "name=getHashtable", "descriptorType=operation", "role=getter" });
ModelMBeanOperationInfo hashtableOperationInfo = new ModelMBeanOperationInfo("Hashtable attribute", hashtableGetter, hashtableOperationDescriptor);
Descriptor mapOperationDescriptor = new DescriptorSupport(new String[] { "name=getMap", "descriptorType=operation", "role=getter" });
ModelMBeanOperationInfo mapOperationInfo = new ModelMBeanOperationInfo("Map attribute", mapGetter, mapOperationDescriptor);
// ModelMBeanAttributeInfo
Descriptor nullAttributeDescriptor = new DescriptorSupport(new String[] { "name=Null", "descriptorType=attribute", "getMethod=getNull" });
ModelMBeanAttributeInfo nullAttributeInfo = new ModelMBeanAttributeInfo("Null", "java.lang.Object", "Null attribute", true, false, false, nullAttributeDescriptor);
Descriptor integerAttributeDescriptor = new DescriptorSupport(new String[] { "name=Integer", "descriptorType=attribute", "getMethod=getInteger" });
ModelMBeanAttributeInfo integerAttributeInfo = new ModelMBeanAttributeInfo("Integer", "int", "Integer attribute", true, false, false, integerAttributeDescriptor);
Descriptor hashtableAttributeDescriptor = new DescriptorSupport(new String[] { "name=Hashtable", "descriptorType=attribute", "getMethod=getHashtable" });
ModelMBeanAttributeInfo hashtableAttributeInfo = new ModelMBeanAttributeInfo("Hashtable", "java.util.Hashtable", "Hashtable attribute", true, false, false, hashtableAttributeDescriptor);
Descriptor mapAttributeDescriptor = new DescriptorSupport(new String[] { "name=Map", "descriptorType=attribute", "getMethod=getMap" });
ModelMBeanAttributeInfo mapAttributeInfo = new ModelMBeanAttributeInfo("Map", "java.util.Map", "Map attribute", true, false, false, mapAttributeDescriptor);
Descriptor null2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Null2", "descriptorType=attribute" });
null2AttributeDescriptor.setField("default", null);
ModelMBeanAttributeInfo null2AttributeInfo = new ModelMBeanAttributeInfo("Null2", "java.lang.Object", "Null2 attribute", true, false, false, null2AttributeDescriptor);
Descriptor integer2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Integer2", "descriptorType=attribute" });
integer2AttributeDescriptor.setField("default", 10);
ModelMBeanAttributeInfo integer2AttributeInfo = new ModelMBeanAttributeInfo("Integer2", "int", "Integer2 attribute", true, false, false, integer2AttributeDescriptor);
Descriptor hashtable2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Hashtable2", "descriptorType=attribute" });
hashtable2AttributeDescriptor.setField("default", new Hashtable());
ModelMBeanAttributeInfo hashtable2AttributeInfo = new ModelMBeanAttributeInfo("Hashtable2", "java.util.Hashtable", "Hashtable2 attribute", true, false, false, hashtable2AttributeDescriptor);
Descriptor map2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Map2", "descriptorType=attribute" });
map2AttributeDescriptor.setField("default", new Hashtable());
ModelMBeanAttributeInfo map2AttributeInfo = new ModelMBeanAttributeInfo("Map2", "java.util.Map", "Map2 attribute", true, false, false, map2AttributeDescriptor);
// ModelMBeanInfo
ModelMBeanInfo mmbi = new ModelMBeanInfoSupport(Resource.class.getName(), "Resource MBean", new ModelMBeanAttributeInfo[] { nullAttributeInfo, integerAttributeInfo, hashtableAttributeInfo, mapAttributeInfo, null2AttributeInfo, integer2AttributeInfo, hashtable2AttributeInfo, map2AttributeInfo }, null, new ModelMBeanOperationInfo[] { nullOperationInfo, integerOperationInfo, hashtableOperationInfo, mapOperationInfo }, null);
// RequiredModelMBean
ModelMBean mmb = new RequiredModelMBean(mmbi);
mmb.setManagedResource(resource, "ObjectReference");
ObjectName mmbName = new ObjectName(":type=ResourceMBean");
mbs.registerMBean(mmb, mmbName);
// Run tests
System.out.println("\nTesting that we can call getNull()... ");
try {
Object o = mbs.getAttribute(mmbName, "Null");
System.out.println("getNull() = " + o);
System.out.println("Attribute's declared type = java.lang.Object");
System.out.println("Returned value's type = null");
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getInteger()... ");
try {
Integer i = (Integer) mbs.getAttribute(mmbName, "Integer");
System.out.println("getInteger() = " + i);
System.out.println("Attribute's declared type = int");
System.out.println("Returned value's type = " + i.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getHashtable()... ");
try {
Hashtable h = (Hashtable) mbs.getAttribute(mmbName, "Hashtable");
System.out.println("getHashtable() = " + h);
System.out.println("Attribute's declared type = " + "java.util.Hashtable");
System.out.println("Returned value's type = " + h.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getMap()... ");
try {
Map m = (Map) mbs.getAttribute(mmbName, "Map");
System.out.println("getMap() = " + m);
System.out.println("Attribute's declared type = " + "java.util.Map");
System.out.println("Returned value's type = " + m.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getNull2()... ");
try {
Object o = mbs.getAttribute(mmbName, "Null2");
System.out.println("getNull2() = " + o);
System.out.println("Attribute's declared type = java.lang.Object");
System.out.println("Returned value's type = null");
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getInteger2()... ");
try {
Integer i = (Integer) mbs.getAttribute(mmbName, "Integer2");
System.out.println("getInteger2() = " + i);
System.out.println("Attribute's declared type = int");
System.out.println("Returned value's type = " + i.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getHashtable2()... ");
try {
Hashtable h = (Hashtable) mbs.getAttribute(mmbName, "Hashtable2");
System.out.println("getHashtable2() = " + h);
System.out.println("Attribute's declared type = " + "java.util.Hashtable");
System.out.println("Returned value's type = " + h.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
System.out.println("\nTesting that we can call getMap2()... ");
try {
Map m = (Map) mbs.getAttribute(mmbName, "Map2");
System.out.println("getMap2() = " + m);
System.out.println("Attribute's declared type = " + "java.util.Map");
System.out.println("Returned value's type = " + m.getClass().getName());
} catch (Exception e) {
System.out.println("TEST FAILED: Caught exception:");
e.printStackTrace(System.out);
ok = false;
}
if (ok)
System.out.println("\nTest passed.\n");
else {
System.out.println("\nTest failed.\n");
System.exit(1);
}
}
use of javax.management.modelmbean.ModelMBeanOperationInfo in project jdk8u_jdk by JetBrains.
the class MBeanInfoInteropTest method init.
private static void init() throws Exception {
mbai = new MBeanAttributeInfo("name", "type", "descr", true, false, false);
mbpi = new MBeanParameterInfo("name", "type", "descr");
MBeanParameterInfo[] params = new MBeanParameterInfo[] { mbpi };
mbci1 = new MBeanConstructorInfo("name", "descr", null);
mbci2 = new MBeanConstructorInfo("name", "descr", params);
mbni1 = new MBeanNotificationInfo(null, "name", "descr");
mbni2 = new MBeanNotificationInfo(new String[] { "type" }, "name", "descr");
mboi1 = new MBeanOperationInfo("name", "descr", null, "type", ACTION);
mboi2 = new MBeanOperationInfo("name", "descr", params, "type", INFO);
mbi1 = new MBeanInfo("class", "descr", null, null, null, null);
mbi2 = new MBeanInfo("class", "descr", new MBeanAttributeInfo[] { mbai }, new MBeanConstructorInfo[] { mbci1, mbci2 }, new MBeanOperationInfo[] { mboi1, mboi2 }, new MBeanNotificationInfo[] { mbni1, mbni2 });
ombai1 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false);
ombai2 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5);
ombai3 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5, 1, 6);
ombai4 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5, new Integer[] { 2, 3, 5, 7 });
ombpi1 = new OpenMBeanParameterInfoSupport("name1", "descr", INTEGER);
ombpi2 = new OpenMBeanParameterInfoSupport("name2", "descr", INTEGER, 5);
ombpi3 = new OpenMBeanParameterInfoSupport("name3", "descr", INTEGER, 5, 1, 6);
ombpi4 = new OpenMBeanParameterInfoSupport("name4", "descr", INTEGER, 5, new Integer[] { 2, 3, 5, 7 });
OpenMBeanParameterInfo[] oparams = { ombpi1, ombpi2, ombpi3, ombpi4 };
ombci1 = new OpenMBeanConstructorInfoSupport("name", "descr", null);
ombci2 = new OpenMBeanConstructorInfoSupport("name", "descr", oparams);
omboi1 = new OpenMBeanOperationInfoSupport("name", "descr", null, INTEGER, ACTION);
omboi2 = new OpenMBeanOperationInfoSupport("name", "descr", oparams, INTEGER, ACTION);
ombi1 = new OpenMBeanInfoSupport("class", "descr", null, null, null, null);
ombi2 = new OpenMBeanInfoSupport("class", "descr", new OpenMBeanAttributeInfo[] { ombai1, ombai2, ombai3, ombai4 }, new OpenMBeanConstructorInfo[] { ombci1, ombci2 }, new OpenMBeanOperationInfo[] { omboi1, omboi2 }, new MBeanNotificationInfo[] { mbni1, mbni2 });
Descriptor attrd = new DescriptorSupport(new String[] { "name=name", "descriptorType=attribute" });
mmbai1 = new ModelMBeanAttributeInfo("name", "type", "descr", true, false, false);
mmbai2 = new ModelMBeanAttributeInfo("name", "type", "descr", true, false, false, attrd);
Descriptor constrd = new DescriptorSupport(new String[] { "name=name", "descriptorType=operation", "role=constructor" });
mmbci1 = new ModelMBeanConstructorInfo("name", "descr", null);
mmbci2 = new ModelMBeanConstructorInfo("name", "descr", null, constrd);
mmbci3 = new ModelMBeanConstructorInfo("name", "descr", params);
mmbci4 = new ModelMBeanConstructorInfo("name", "descr", params, constrd);
Descriptor operd = new DescriptorSupport(new String[] { "name=name", "descriptorType=operation" });
mmboi1 = new ModelMBeanOperationInfo("name", "descr", null, "type", ACTION);
mmboi2 = new ModelMBeanOperationInfo("name", "descr", null, "type", ACTION, operd);
mmboi3 = new ModelMBeanOperationInfo("name", "descr", params, "type", ACTION);
mmboi4 = new ModelMBeanOperationInfo("name", "descr", params, "type", ACTION, operd);
Descriptor notifd = new DescriptorSupport(new String[] { "name=name", "descriptorType=notification" });
mmbni1 = new ModelMBeanNotificationInfo(null, "name", "descr");
mmbni2 = new ModelMBeanNotificationInfo(null, "name", "descr", notifd);
mmbni3 = new ModelMBeanNotificationInfo(new String[] { "type" }, "name", "descr");
mmbni4 = new ModelMBeanNotificationInfo(new String[] { "type" }, "name", "descr", notifd);
Descriptor mbeand = new DescriptorSupport(new String[] { "name=name", "descriptorType=mbean" });
mmbi1 = new ModelMBeanInfoSupport("class", "descr", null, null, null, null);
mmbi2 = new ModelMBeanInfoSupport("class", "descr", null, null, null, null, mbeand);
mmbi3 = new ModelMBeanInfoSupport("class", "descr", new ModelMBeanAttributeInfo[] { mmbai1, mmbai2 }, new ModelMBeanConstructorInfo[] { mmbci1, mmbci2, mmbci3, mmbci4 }, new ModelMBeanOperationInfo[] { mmboi1, mmboi2, mmboi3, mmboi4 }, new ModelMBeanNotificationInfo[] { mmbni1, mmbni2, mmbni3, mmbni4 });
mmbi4 = new ModelMBeanInfoSupport("class", "descr", new ModelMBeanAttributeInfo[] { mmbai1, mmbai2 }, new ModelMBeanConstructorInfo[] { mmbci1, mmbci2, mmbci3, mmbci4 }, new ModelMBeanOperationInfo[] { mmboi1, mmboi2, mmboi3, mmboi4 }, new ModelMBeanNotificationInfo[] { mmbni1, mmbni2, mmbni3, mmbni4 }, mbeand);
objects = new Serializable[] { mbai, mbpi, mbci1, mbci2, mbni1, mbni2, mboi1, mboi2, mbi1, mbi2, ombai1, ombai2, ombai3, ombai4, ombpi1, ombpi2, ombpi3, ombpi4, ombci1, ombci2, omboi1, omboi2, ombi1, ombi2, mmbai1, mmbai2, mmbci1, mmbci2, mmbci3, mmbci4, mmboi1, mmboi2, mmboi3, mmboi4, mmbni1, mmbni2, mmbni3, mmbni4 };
}
use of javax.management.modelmbean.ModelMBeanOperationInfo in project Activiti by Activiti.
the class MBeanInfoAssembler method extractMbeanAttributes.
private void extractMbeanAttributes(Object managedBean, Map<String, ManagedAttributeInfo> attributes, Set<ModelMBeanAttributeInfo> mBeanAttributes, Set<ModelMBeanOperationInfo> mBeanOperations) throws IntrospectionException {
for (ManagedAttributeInfo info : attributes.values()) {
ModelMBeanAttributeInfo mbeanAttribute = new ModelMBeanAttributeInfo(info.getKey(), info.getDescription(), info.getGetter(), info.getSetter());
// add missing attribute descriptors, this is needed to have attributes accessible
Descriptor desc = mbeanAttribute.getDescriptor();
if (info.getGetter() != null) {
desc.setField("getMethod", info.getGetter().getName());
// attribute must also be added as mbean operation
ModelMBeanOperationInfo mbeanOperation = new ModelMBeanOperationInfo(info.getKey(), info.getGetter());
Descriptor opDesc = mbeanOperation.getDescriptor();
mbeanOperation.setDescriptor(opDesc);
mBeanOperations.add(mbeanOperation);
}
if (info.getSetter() != null) {
desc.setField("setMethod", info.getSetter().getName());
// attribute must also be added as mbean operation
ModelMBeanOperationInfo mbeanOperation = new ModelMBeanOperationInfo(info.getKey(), info.getSetter());
mBeanOperations.add(mbeanOperation);
}
mbeanAttribute.setDescriptor(desc);
mBeanAttributes.add(mbeanAttribute);
LOG.trace("Assembled attribute: {}", mbeanAttribute);
}
}
use of javax.management.modelmbean.ModelMBeanOperationInfo in project Activiti by Activiti.
the class MBeanInfoAssembler method getMBeanInfo.
public ModelMBeanInfo getMBeanInfo(Object defaultManagedBean, Object customManagedBean, String objectName) throws JMException {
if ((defaultManagedBean == null && customManagedBean == null) || objectName == null)
return null;
// skip proxy classes
if (defaultManagedBean != null && Proxy.isProxyClass(defaultManagedBean.getClass())) {
LOG.trace("Skip creating ModelMBeanInfo due proxy class {}", defaultManagedBean.getClass());
return null;
}
// maps and lists to contain information about attributes and operations
Map<String, ManagedAttributeInfo> attributes = new LinkedHashMap<String, ManagedAttributeInfo>();
Set<ManagedOperationInfo> operations = new LinkedHashSet<ManagedOperationInfo>();
Set<ModelMBeanAttributeInfo> mBeanAttributes = new LinkedHashSet<ModelMBeanAttributeInfo>();
Set<ModelMBeanOperationInfo> mBeanOperations = new LinkedHashSet<ModelMBeanOperationInfo>();
Set<ModelMBeanNotificationInfo> mBeanNotifications = new LinkedHashSet<ModelMBeanNotificationInfo>();
// extract details from default managed bean
if (defaultManagedBean != null) {
extractAttributesAndOperations(defaultManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(defaultManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(defaultManagedBean, operations, mBeanOperations);
extractMbeanNotifications(defaultManagedBean, mBeanNotifications);
}
// extract details from custom managed bean
if (customManagedBean != null) {
extractAttributesAndOperations(customManagedBean.getClass(), attributes, operations);
extractMbeanAttributes(customManagedBean, attributes, mBeanAttributes, mBeanOperations);
extractMbeanOperations(customManagedBean, operations, mBeanOperations);
extractMbeanNotifications(customManagedBean, mBeanNotifications);
}
// create the ModelMBeanInfo
String name = getName(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
String description = getDescription(customManagedBean != null ? customManagedBean : defaultManagedBean, objectName);
ModelMBeanAttributeInfo[] arrayAttributes = mBeanAttributes.toArray(new ModelMBeanAttributeInfo[mBeanAttributes.size()]);
ModelMBeanOperationInfo[] arrayOperations = mBeanOperations.toArray(new ModelMBeanOperationInfo[mBeanOperations.size()]);
ModelMBeanNotificationInfo[] arrayNotifications = mBeanNotifications.toArray(new ModelMBeanNotificationInfo[mBeanNotifications.size()]);
ModelMBeanInfo info = new ModelMBeanInfoSupport(name, description, arrayAttributes, null, arrayOperations, arrayNotifications);
LOG.trace("Created ModelMBeanInfo {}", info);
return info;
}
use of javax.management.modelmbean.ModelMBeanOperationInfo in project geode by apache.
the class MX4JModelMBean method invoke.
public Object invoke(String method, Object[] arguments, String[] params) throws MBeanException, ReflectionException {
if (method == null)
throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_METHOD_NAME_CANNOT_BE_NULL.toLocalizedString()));
if (arguments == null)
arguments = new Object[0];
if (params == null)
params = new String[0];
Logger logger = getLogger();
// Find operation descriptor
ModelMBeanInfo info = getModelMBeanInfo();
if (info == null)
throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_MODELMBEANINFO_IS_NULL.toLocalizedString()));
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("ModelMBeanInfo is: " + info);
// This is a clone, we use it read only
ModelMBeanOperationInfo operInfo = info.getOperation(method);
if (operInfo == null)
throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_CANNOT_FIND_MODELMBEANOPERATIONINFO_FOR_OPERATION_0.toLocalizedString(method)));
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Operation info is: " + operInfo);
// This descriptor is a clone
Descriptor operationDescriptor = operInfo.getDescriptor();
if (operationDescriptor == null)
throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_OPERATION_DESCRIPTOR_FOR_OPERATION_0_CANNOT_BE_NULL.toLocalizedString(method)));
String role = (String) operationDescriptor.getFieldValue("role");
if (role == null || !role.equals("operation"))
throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_OPERATION_DESCRIPTOR_FIELD_ROLE_MUST_BE_OPERATION_NOT_0.toLocalizedString(role)));
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Operation descriptor is: " + operationDescriptor);
// This returns a clone of the mbean descriptor, we use it read only
Descriptor mbeanDescriptor = info.getMBeanDescriptor();
if (mbeanDescriptor == null)
throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_MBEAN_DESCRIPTOR_CANNOT_BE_NULL.toLocalizedString()));
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("MBean descriptor is: " + mbeanDescriptor);
Object returnValue = null;
String lastUpdateField = "lastReturnedTimeStamp";
// Check if the method should be invoked given the cache settings
int staleness = getStaleness(operationDescriptor, mbeanDescriptor, lastUpdateField);
if (staleness == ALWAYS_STALE || staleness == STALE) {
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Value is stale");
// Find parameters classes
Class[] parameters = null;
try {
parameters = Utils.loadClasses(Thread.currentThread().getContextClassLoader(), params);
} catch (ClassNotFoundException x) {
logger.error(LocalizedStrings.MX4JModelMBean_CANNOT_FIND_OPERATIONS_PARAMETER_CLASSES, x);
throw new ReflectionException(x);
}
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Invoking operation...");
// Find target object
Object target = resolveTargetObject(operationDescriptor);
returnValue = invokeMethod(target, method, parameters, arguments);
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Returned value is: " + returnValue);
if (returnValue != null) {
Class parameter = returnValue.getClass();
Class declared = loadClassWithContextClassLoader(operInfo.getReturnType());
checkAssignability(parameter, declared);
}
// Cache the new value only if caching is needed
if (staleness != ALWAYS_STALE) {
operationDescriptor.setField("lastReturnedValue", returnValue);
operationDescriptor.setField(lastUpdateField, Long.valueOf(System.currentTimeMillis()));
if (logger.isEnabledFor(Logger.TRACE)) {
logger.trace("Returned value has been cached");
}
// And now replace the descriptor with the updated clone
info.setDescriptor(operationDescriptor, "operation");
}
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("invoke for operation " + method + " returns invoked value: " + returnValue);
} else {
// Return cached value
returnValue = operationDescriptor.getFieldValue("lastReturnedValue");
if (returnValue != null) {
Class parameter = returnValue.getClass();
Class declared = loadClassWithContextClassLoader(operInfo.getReturnType());
checkAssignability(parameter, declared);
}
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("invoke for operation " + method + " returns cached value: " + returnValue);
}
// As an extension, persist this model mbean also after operation invocation, but using only
// settings provided in the operation descriptor, without falling back to defaults set in
// the MBean descriptor
boolean persistNow = shouldPersistNow(operationDescriptor, null, lastUpdateField);
int impact = operInfo.getImpact();
if (persistNow && impact != MBeanOperationInfo.INFO) {
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("Persisting this ModelMBean...");
try {
store();
if (logger.isEnabledFor(Logger.TRACE))
logger.trace("ModelMBean persisted successfully");
} catch (Exception x) {
logger.error(LocalizedStrings.MX4JModelMBean_CANNOT_STORE_MODELMBEAN_AFTER_OPERATION_INVOCATION, x);
if (x instanceof MBeanException)
throw (MBeanException) x;
else
throw new MBeanException(x);
}
}
return returnValue;
}
Aggregations