Search in sources :

Example 1 with ResourceRefConfigCR

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" );
        }
    }
}
Also used : ResourceRefConfigCR(com.sun.appserv.management.config.ResourceRefConfigCR) ResourceConfig(com.sun.appserv.management.config.ResourceConfig) ResourceRefConfig(com.sun.appserv.management.config.ResourceRefConfig) DomainConfig(com.sun.appserv.management.config.DomainConfig)

Aggregations

DomainConfig (com.sun.appserv.management.config.DomainConfig)1 ResourceConfig (com.sun.appserv.management.config.ResourceConfig)1 ResourceRefConfig (com.sun.appserv.management.config.ResourceRefConfig)1 ResourceRefConfigCR (com.sun.appserv.management.config.ResourceRefConfigCR)1