Package org.rhq.core.clientapi.agent.metadata

Examples of org.rhq.core.clientapi.agent.metadata.PluginMetadataParser


    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static Resource discoverPlatform() throws Exception {
        PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(PluginLocation.PLATFORM_PLUGIN)
            .toURL());
        PluginMetadataParser parser = new PluginMetadataParser(descriptor,
            Collections.<String, PluginMetadataParser> emptyMap());

        List<ResourceType> platformTypes = parser.getAllTypes();

        //this is the default container name in case of no plugin explicit plugin configuration, which we don't have.
        String containerName = InetAddress.getLocalHost().getCanonicalHostName();

        for (ResourceType rt : platformTypes) {
            if (rt.getCategory() != ResourceCategory.PLATFORM) {
                continue;
            }

            Class discoveryClass = Class.forName(parser.getDiscoveryComponentClass(rt));

            ResourceDiscoveryComponent discoveryComponent = (ResourceDiscoveryComponent) discoveryClass.newInstance();

            ResourceDiscoveryContext context = new ResourceDiscoveryContext(rt, null, null,
                SystemInfoFactory.createSystemInfo(), Collections.emptyList(), Collections.emptyList(), containerName,
View Full Code Here


            "          class='org.rhq.plugins.test.TestServer'" + //
            "          discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        Map<ResourceType, List<String>> map = parser.getDiscoveryCallbackClasses();
        assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
        ResourceType rt = new ResourceType("testServerType", "TestServer", null, null);
        assertEquals(map.get(rt).get(0), "org.rhq.plugins.test.TestCallback", "incorrect classname in map: " + map);

        // in a second plugin, define a discovery callback that points back to a type in the first plugin
        PluginDescriptor pluginDescriptor2 = toPluginDescriptor("" + //
                "<plugin name='TestServer2' displayName='Test Server' package='org.rhq.plugins.test2'" + //
                "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
                "    xmlns='urn:xmlns:rhq-plugin'>" + //
                "  <discovery-callbacks>" + //
                "     <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback2' />" + //
                "  </discovery-callbacks>" + //
                "  <server name='testServerType2'" + //
                "          class='org.rhq.plugins.test2.TestServer2'" + //
                "          discovery='org.rhq.plugins.test2.TestServerDiscoveryComponent2'/>" + //
                "</plugin>");

        parsersByPlugin.put("TestServer", parser);
        PluginMetadataParser parser2 = new PluginMetadataParser(pluginDescriptor2, parsersByPlugin);
        map = parser2.getDiscoveryCallbackClasses();
        assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
        rt = new ResourceType("testServerType", "TestServer", null, null);
        assertEquals(map.get(rt).get(0), "org.rhq.plugins.test2.TestCallback2", "incorrect classname in map: " + map);

        // define multiple callbacks to multiple plugins
        PluginDescriptor pluginDescriptor3 = toPluginDescriptor("" + //
                "<plugin name='TestServer3' displayName='Test Server' package='org.rhq.plugins.test3'" + //
                "    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
                "    xmlns='urn:xmlns:rhq-plugin'>" + //
                "  <discovery-callbacks>" + //
                "     <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback31' />" + //
                "     <type-callback type='testServerType2' plugin='TestServer2' callbackClass='TestCallback32' />" + //
                "     <type-callback type='testServerType3' plugin='TestServer3' callbackClass='TestCallback33' />" + //
                "     <type-callback type='testServerType3' plugin='TestServer3' callbackClass='TestCallback34' />" + //
                "  </discovery-callbacks>" + //
                "  <server name='testServerType3'" + //
                "          class='org.rhq.plugins.test3.TestServer3'" + //
                "          discovery='org.rhq.plugins.test3.TestServerDiscoveryComponent3'/>" + //
                "</plugin>");

        parsersByPlugin.put("TestServer2", parser2);
        PluginMetadataParser parser3 = new PluginMetadataParser(pluginDescriptor3, parsersByPlugin);
        map = parser3.getDiscoveryCallbackClasses();
        assertEquals(map.size(), 3, "Should have three keys in discovery callbacks map: " + map);

        rt = new ResourceType("testServerType", "TestServer", null, null);
        List<String> list = map.get(rt);
        assertEquals(list.size(), 1);
View Full Code Here

            "          class='org.rhq.plugins.test.TestServer'" + //
            "          discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        assertEquals(parser.getAllTypes().size(), 1,
            "The allTypes property should have 1 element for descriptor with a single resource type.");
        assertEquals(parser.getAllTypes().get(0).getName(), "testServer",
            "Expected to find resource type named 'testServer' in allTypes.");
    }
View Full Code Here

            "             discovery='TestServiceDiscoveryComponent'/>" + //
            "  </server>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        assertEquals(parser.getAllTypes().size(), 2,
            "The allTypes property should have 2 elements for a descriptor with a server and a child service.");

        assertNotNull(findResourceType(parser, "testServer"));
        assertNotNull(findResourceType(parser, "testService"));
    }
View Full Code Here

            "          class='org.rhq.plugins.test.TestServer'" + //
            "          discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        assertEquals(parser.getRootResourceTypes().size(), 1,
            "rootResourceTypes property should have 1 element for descriptor with a single resource type.");
        Set<ResourceType> rootResourceTypes = parser.getRootResourceTypes();
        ResourceType root = null;
        for (ResourceType resourceType : rootResourceTypes) {
            if (resourceType.getName().equals("testServer")) {
                root = resourceType;
                break;
View Full Code Here

            "          class='org.rhq.plugins.test.TestServer'" + //
            "          discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
            "</plugin>");

        Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
        PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);

        ResourceType resourceType = findResourceType(parser, "testServer");

        String componentClass = parser.getComponentClass(resourceType);

        assertEquals(componentClass, "org.rhq.plugins.test.TestServer",
            "Expected the package and class name from the 'class' attribute when it includes the package name.");
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.agent.metadata.PluginMetadataParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.