use of com.sun.appserv.management.base.AMX in project Payara by payara.
the class AMXTest method checkAttributeTypes.
/**
* Verify:
* <ul>
* <li>that all Attributes are of standard types and Serializable</li>
* </ul>
*/
public void checkAttributeTypes(final ObjectName objectName) throws Exception {
final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
final MBeanInfo info = Util.getExtra(proxy).getMBeanInfo();
final MBeanAttributeInfo[] attributes = info.getAttributes();
boolean emittedName = false;
for (int i = 0; i < attributes.length; ++i) {
final MBeanAttributeInfo attrInfo = attributes[i];
final String type = attrInfo.getType();
if (!isSuitableReturnTypeForAPI(type)) {
if (!emittedName) {
emittedName = true;
}
if (!type.equals(CoverageInfo.class.getName())) {
trace("WARNING: unsuitable Attribute type in API: " + type + " " + attrInfo.getName() + " in " + objectName);
}
}
}
}
use of com.sun.appserv.management.base.AMX in project Payara by payara.
the class AMXTest method checkNameMatchesJ2EEName.
/**
* Verify that getName() is the same as the 'name' property in the ObjectName.
*/
public void checkNameMatchesJ2EEName(final ObjectName childObjectName) throws Exception {
final AMX childProxy = getProxyFactory().getProxy(childObjectName, AMX.class);
if (childProxy instanceof NamedConfigElement) {
final String j2eeName = childProxy.getName();
assertEquals(j2eeName, childProxy.getName());
}
}
use of com.sun.appserv.management.base.AMX in project Payara by payara.
the class AMXTest method testNoGoofyNames.
public void testNoGoofyNames() {
final long start = now();
final Set<AMX> all = getAllAMX();
for (final AMX amx : all) {
final ObjectName objectName = Util.getObjectName(amx);
final MBeanInfo mbeanInfo = Util.getExtra(amx).getMBeanInfo();
testNoGoofyNames(objectName, mbeanInfo.getAttributes());
testNoGoofyNames(objectName, mbeanInfo.getOperations());
}
printElapsed("testNoGoofyNames", all.size(), start);
}
use of com.sun.appserv.management.base.AMX in project Payara by payara.
the class AMXTest method checkReturnTypes.
/**
* Verify:
* <ul>
* <li>that all return types are suitable for the API</li>
* </ul>
*/
public void checkReturnTypes(final ObjectName objectName) throws Exception {
final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
final MBeanInfo info = Util.getExtra(proxy).getMBeanInfo();
final MBeanOperationInfo[] operations = info.getOperations();
boolean emittedName = false;
for (int i = 0; i < operations.length; ++i) {
final MBeanOperationInfo opInfo = operations[i];
final String returnType = opInfo.getReturnType();
if (!isSuitableReturnTypeForAPI(returnType)) {
if (!emittedName) {
emittedName = true;
trace("\n" + objectName);
}
trace("WARNING: unsuitable return type in API: " + returnType + " " + opInfo.getName() + "(...)");
}
}
}
use of com.sun.appserv.management.base.AMX in project Payara by payara.
the class AMXTest method checkCreateRemoveGet.
/**
* Verify:
* <ul>
* <li>each create() or createAbc() method ends in "Config" if it returns an AMXConfig subclass</li>
* <li>each remove() or removeAbc() method ends in "Config"</li>
* </ul>
*/
public void checkCreateRemoveGet(final ObjectName objectName) throws Exception {
final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
if (proxy instanceof Container) {
final Method[] methods = getInterfaceClass(proxy).getMethods();
final MBeanInfo mbeanInfo = Util.getExtra(proxy).getMBeanInfo();
final MBeanOperationInfo[] operations = mbeanInfo.getOperations();
for (int methodIdx = 0; methodIdx < methods.length; ++methodIdx) {
final Method method = methods[methodIdx];
final String methodName = method.getName();
if (methodName.startsWith("create") && !methodName.endsWith("Config")) {
if (AMXConfig.class.isAssignableFrom(method.getReturnType()) && (!(proxy instanceof SecurityMapConfig))) {
trace("WARNING: method " + methodName + " does not end in 'Config': " + objectName);
}
} else if (methodName.startsWith("remove") && !methodName.endsWith("Config") && proxy instanceof AMXConfig) {
if (// method.getReturnType() == Void.class &&
method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == String.class && !method.getName().equals("removeProperty") && !method.getName().equals("removeSystemProperty") && (!(proxy instanceof SecurityMapConfig))) {
trace("WARNING: method " + methodName + " does not end in 'Config': " + methodName);
}
}
}
}
}
Aggregations