use of com.sun.appserv.management.config.ResourceRefConfigCR in project Payara by payara.
the class DanglingRefsTest method _testDanglingResourceRefConfigs.
private void _testDanglingResourceRefConfigs() throws ClassNotFoundException {
final DomainConfig domainConfig = getDomainConfig();
final Set<ResourceConfig> resourcesSet = getQueryMgr().queryInterfaceSet(ResourceConfig.class.getName(), null);
final Set<ResourceRefConfig> refs = RefHelper.findAllResourceRefConfigs(getQueryMgr());
final Map<String, ResourceConfig> resourcesMap = Util.createNameMap(resourcesSet);
for (final ResourceRefConfig ref : refs) {
final String name = ref.getName();
final ResourceConfig resourceConfig = resourcesMap.get(name);
if (resourceConfig == null) {
String msg = "Resource reference '" + Util.getObjectName(ref) + "' refers to a non-existent resource";
boolean removedOK = false;
try {
final ResourceRefConfigCR container = (ResourceRefConfigCR) ref.getContainer();
container.removeResourceRefConfig(name);
removedOK = true;
} catch (Exception e) {
msg = msg + ", and trying to remove it throws an Exception " + "(remove it manually from domain.xml)" + ", see bug #6298512";
}
if (!removedOK) {
warning(msg);
}
} else {
// printVerbose( "ResourceRefConfig '" + name + "' is OK" );
}
}
}
Aggregations