use of javax.management.MBeanParameterInfo in project kernel by exoplatform.
the class TestExoMBeanAttribute method test3.
public void test3(Bean bean, String getterName, String setterName) throws Exception {
MBeanOperationInfo[] operationInfos = bean.info.getOperations();
assertNotNull(operationInfos);
assertEquals(2, operationInfos.length);
MBeanOperationInfo setStringInfo = bean.info.getOperation(setterName);
assertNotNull(setStringInfo);
assertEquals(setterName, setStringInfo.getName());
assertEquals("void", setStringInfo.getReturnType());
MBeanParameterInfo[] setStringParameterInfos = setStringInfo.getSignature();
assertEquals(1, setStringParameterInfos.length);
MBeanParameterInfo attributeParameterInfo = setStringParameterInfos[0];
assertEquals("java.lang.String", attributeParameterInfo.getType());
MBeanOperationInfo getStringInfo = bean.info.getOperation(getterName);
assertNotNull(getStringInfo);
assertEquals(getterName, getStringInfo.getName());
assertEquals("java.lang.String", getStringInfo.getReturnType());
assertEquals(0, getStringInfo.getSignature().length);
MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
assertNotNull(attributeInfos);
assertEquals(1, attributeInfos.length);
MBeanAttributeInfo attributeInfo = attributeInfos[0];
assertEquals("String", attributeInfo.getName());
assertEquals("java.lang.String", attributeInfo.getType());
assertEquals(true, attributeInfo.isReadable());
assertEquals(true, attributeInfo.isWritable());
MBean3_0.string = null;
assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
assertEquals("Foo", MBean3_0.string);
server.setAttribute(bean.name, new Attribute("String", "Bar"));
assertEquals("Bar", MBean3_0.string);
MBean3_0.string = "Juu";
assertEquals("Juu", server.invoke(bean.name, getterName, new Object[0], new String[0]));
MBean3_0.string = "Daa";
assertEquals("Daa", server.getAttribute(bean.name, "String"));
}
use of javax.management.MBeanParameterInfo in project kernel by exoplatform.
the class TestExoMBeanAttribute method test2.
public void test2(Bean bean, String setterName) throws Exception {
MBeanOperationInfo[] operationInfos = bean.info.getOperations();
assertNotNull(operationInfos);
assertEquals(1, operationInfos.length);
MBeanOperationInfo operationInfo = operationInfos[0];
assertNotNull(operationInfo);
assertEquals(setterName, operationInfo.getName());
assertEquals("void", operationInfo.getReturnType());
MBeanParameterInfo[] attributeParameterInfos = operationInfo.getSignature();
assertEquals(1, attributeParameterInfos.length);
MBeanParameterInfo attributeParameterInfo = attributeParameterInfos[0];
assertEquals("java.lang.String", attributeParameterInfo.getType());
MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
assertNotNull(attributeInfos);
assertEquals(1, attributeInfos.length);
MBeanAttributeInfo attributeInfo = attributeInfos[0];
assertEquals("String", attributeInfo.getName());
assertEquals("java.lang.String", attributeInfo.getType());
assertEquals(false, attributeInfo.isReadable());
assertEquals(true, attributeInfo.isWritable());
MBean2_0.string = null;
assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
assertEquals("Foo", MBean2_0.string);
server.setAttribute(bean.name, new Attribute("String", "Bar"));
assertEquals("Bar", MBean2_0.string);
}
use of javax.management.MBeanParameterInfo in project Payara by payara.
the class ConfigBeanJMXSupport method duckTypedToMBeanOperationInfo.
/**
* DuckTyped methods are <em>always</em> exposed as operations, never as Attributes.
*/
public MBeanOperationInfo duckTypedToMBeanOperationInfo(final DuckTypedInfo info) {
final Descriptor descriptor = descriptor(info.duckTyped());
final String name = info.name();
final Class<?> type = remoteType(info.returnType());
final String description = "@DuckTyped " + name + " of " + mIntf.getName();
// how to tell?
final int impact = MBeanOperationInfo.UNKNOWN;
final List<MBeanParameterInfo> paramInfos = new ArrayList<MBeanParameterInfo>();
int i = 0;
for (final Class<?> paramClass : info.signature()) {
final String paramName = "p" + i;
final String paramType = remoteType(paramClass).getName();
final String paramDescription = "parameter " + i;
final MBeanParameterInfo paramInfo = new MBeanParameterInfo(paramName, paramType, paramDescription, null);
paramInfos.add(paramInfo);
++i;
}
final MBeanParameterInfo[] paramInfosArray = CollectionUtil.toArray(paramInfos, MBeanParameterInfo.class);
return new MBeanOperationInfo(name, description, paramInfosArray, type.getName(), impact, descriptor);
}
use of javax.management.MBeanParameterInfo in project Payara by payara.
the class MBeanInterfaceGenerator method generateOperations.
protected String generateOperations(MBeanOperationInfo[] infos) {
final StringBuilder buf = new StringBuilder();
for (int i = 0; i < infos.length; ++i) {
final MBeanOperationInfo info = infos[i];
final String name = info.getName();
final String returnType = info.getReturnType();
final MBeanParameterInfo[] paramInfos = info.getSignature();
final String[] paramTypes = new String[paramInfos.length];
for (int p = 0; p < paramInfos.length; ++p) {
paramTypes[p] = paramInfos[p].getType();
}
final String[] paramNames = getParamNames(info);
if (mEmitComments) {
final String comment = getOperationComment(info, paramNames);
if (comment.length() != 0) {
buf.append(NEWLINE).append(indent(comment)).append(NEWLINE);
}
}
final String method = formMethod(returnType, name, paramTypes, paramNames);
buf.append(indent(method)).append(NEWLINE);
}
return (buf.toString());
}
Aggregations