use of com.sun.appserv.management.base.Container in project Payara by payara.
the class ConfigMgrTestBase method getProgeny.
public AMXConfig getProgeny(final String name) {
final Container container = getProgenyContainer();
final String progenyType = getProgenyJ2EEType();
// trace( "getProgeny: " + progenyType + "=" + name );
final Object progeny = container.getContainee(progenyType, name);
if (progeny != null && !(progeny instanceof AMXConfig)) {
assert (progeny instanceof AMX);
failure("getProgeny: " + progenyType + "=" + name + " not an AMXConfig, interface = " + Util.getExtra(Util.asAMX(progeny)).getInterfaceName());
}
return ((AMXConfig) progeny);
}
use of com.sun.appserv.management.base.Container in project Payara by payara.
the class AMXTest method checkMaps.
/**
* Verify that a proxy getAbcMap(...) Attribute or operation has an appropriate
* MBean getAbcObjectNameMap() method.
*/
public void checkMaps(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();
for (int methodIdx = 0; methodIdx < methods.length; ++methodIdx) {
final Method method = methods[methodIdx];
final String methodName = method.getName();
if (isMapGetter(method)) {
if (methodName.endsWith(OBJECTNAME_MAP_SUFFIX)) {
warning("method should exist in MBeanInfo, not interface: " + methodName);
continue;
}
// verify that a corresponding peer method exists and
// has the right return type and same number and type of parameters
final String peerMethodName = StringUtil.replaceSuffix(methodName, MAP_SUFFIX, OBJECTNAME_MAP_SUFFIX);
checkCompatibleOperationExists(Util.getObjectName(proxy), method, peerMethodName, mbeanInfo);
} else if (isMapGetterName(methodName)) {
warning("operation " + methodName + " does not return a Map!");
}
}
}
}
use of com.sun.appserv.management.base.Container in project Payara by payara.
the class AMXTest method checkContainerChild.
/**
* Verify that each child's Container actually claims the child as a child.
*/
public void checkContainerChild(final String childJ2EEType) {
final QueryMgr queryMgr = getQueryMgr();
final Set children = queryMgr.queryJ2EETypeSet(childJ2EEType);
final Iterator iter = children.iterator();
while (iter.hasNext()) {
final AMX containee = Util.asAMX(iter.next());
Container container = null;
final ObjectName objectName = Util.getObjectName(containee);
if (!shouldTest(objectName)) {
continue;
}
try {
container = (Container) containee.getContainer();
} catch (Exception e) {
trace("Can't get container for: " + objectName);
}
if (container == null) {
assert (containee.getJ2EEType().equals(XTypes.DOMAIN_ROOT)) : "container is null for: " + objectName;
continue;
}
final Set<AMX> containeeSet = container.getContaineeSet(childJ2EEType);
final Set<ObjectName> containeeObjectNameSet = Util.toObjectNames(containeeSet);
assert (containeeObjectNameSet.contains(Util.getExtra(containee).getObjectName()));
}
}
use of com.sun.appserv.management.base.Container in project Payara by payara.
the class ContainerTest method checkContainerContainsChild.
public void checkContainerContainsChild(final ObjectName containeeObjectName) throws Exception {
final MBeanServerConnection conn = getMBeanServerConnection();
assert (containeeObjectName != null);
assert (conn.isRegistered(containeeObjectName));
final AMX containedProxy = getProxyFactory().getProxy(containeeObjectName, AMX.class);
if (containedProxy instanceof DomainRoot) {
// DomainRoot has no Container
return;
}
final ObjectName containerObjectName = (ObjectName) conn.getAttribute(containeeObjectName, "ContainerObjectName");
if (!conn.isRegistered(containerObjectName)) {
warning("Container " + StringUtil.quote(containerObjectName) + " for " + StringUtil.quote(containeeObjectName) + " is not registered.");
return;
}
final AMX parentProxy = containedProxy.getContainer();
if (parentProxy instanceof Container) {
if (!(parentProxy instanceof Container)) {
trace("WARNING: proxy is instance of Container, but not Container: " + Util.getExtra(parentProxy).getObjectName());
} else {
final Container container = (Container) parentProxy;
if (container != null) {
final Set<AMX> containees = container.getContaineeSet();
final Set<ObjectName> containeeObjectNames = Util.toObjectNames(containees);
if (!containeeObjectNames.contains(Util.getExtra(containedProxy).getObjectName())) {
trace("ERROR: Container " + Util.getExtra(parentProxy).getObjectName() + " does not contain its child: " + containeeObjectName);
assertTrue(false);
}
}
}
}
}
use of com.sun.appserv.management.base.Container 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