All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rhq.plugins.byteman.BytemanScriptDiscoveryComponent Maven / Gradle / Ivy

The newest version!
package org.rhq.plugins.byteman;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;

public class BytemanScriptDiscoveryComponent implements ResourceDiscoveryComponent {

    public Set discoverResources(ResourceDiscoveryContext context)
        throws Exception {

        Set details = new HashSet();

        Map allScripts = context.getParentResourceComponent().getAllKnownScripts();
        if (allScripts != null && !allScripts.isEmpty()) {
            for (String scriptName : allScripts.keySet()) {
                int startShortName = scriptName.lastIndexOf("\\");
                if (startShortName == -1) {
                    startShortName = scriptName.lastIndexOf("/");
                }
                String shortScriptName = scriptName.substring(startShortName + 1); // script names never end with \ or /, so this is OK
                details.add(new DiscoveredResourceDetails(context.getResourceType(), scriptName, shortScriptName,
                    "unversioned", "A script with Byteman rules", null, null));
            }
        }

        return details;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy