Package org.rhq.core.clientapi.descriptor.plugin

Examples of org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor


            for (File current_plugin : current_plugins) {
                String plugin_name;
                String plugin_display_name;
                try {
                    URL url = current_plugin.toURI().toURL();
                    PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
                    plugin_name = descriptor.getName();
                    plugin_display_name = descriptor.getDisplayName();
                    installed_plugins.add(plugin_name);
                } catch (Throwable t) {
                    plugin_name = "?cannot-parse-descriptor?";
                    plugin_display_name = "?cannot-parse-descriptor?";
                }
View Full Code Here


    private Plugin cacheFilesystemAgentPluginJar(File pluginJar, String md5) throws Exception {
        if (md5 == null) { // don't calculate the MD5 is we've already done it before
            md5 = MessageDigestGenerator.getDigestString(pluginJar);
        }
        URL pluginUrl = pluginJar.toURI().toURL();
        PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(pluginUrl);
        String version = AgentPluginDescriptorUtil.getPluginVersion(pluginJar, descriptor).toString();
        String name = descriptor.getName();
        Plugin plugin = new Plugin(name, pluginJar.getName());
        plugin.setMd5(md5);
        plugin.setVersion(version);
        plugin.setMtime(pluginJar.lastModified());
        this.agentPluginsOnFilesystem.put(pluginJar, plugin);
View Full Code Here

            // if a plugin used to exist but now doesn't, it should be deleted - we should not fail when this occurs
            List<String> pluginsToDelete = new ArrayList<String>();

            // in all likelihood, the new plugins have different filenames; but since the descriptors
            // will have the same plugin names, we'll be able to key off of plugin name
            PluginDescriptor descriptor;
            Map<String, File> existingPluginFiles = new HashMap<String, File>(); // keyed on plugin name
            for (File file : this.agentPluginDeployer.getPluginDir().listFiles()) {
                if (file.getName().endsWith(".jar")) {
                    try {
                        descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(file.toURI().toURL());
                        existingPluginFiles.put(descriptor.getName(), file);
                    } catch (Exception e) {
                        log.warn("File [" + file + "] is not a valid plugin and will be ignored: " + e);
                    }
                }
            }
View Full Code Here

                for (File plugin : plugins) {
                    String pluginName;
                    String pluginDisplayName;
                    try {
                        URL url = plugin.toURI().toURL();
                        PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
                        pluginName = descriptor.getName();
                        pluginDisplayName = descriptor.getDisplayName();
                    } catch (Exception t) {
                        pluginName = "?cannot-parse-descriptor?".intern();
                        pluginDisplayName = "?cannot-parse-descriptor?".intern();
                    }
View Full Code Here

                for (File plugin : plugins) {
                    String pluginDisplayName;
                    String pluginNameToReturn;
                    try {
                        URL url = plugin.toURI().toURL();
                        PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
                        pluginDisplayName = pluginDescriptor.getDisplayName();
                        pluginNameToReturn = pluginDescriptor.getName();
                    } catch (Exception t) {
                        continue;
                    }

                    if (pluginNameToReturn.toLowerCase().equals(pluginName.toLowerCase())) {
View Full Code Here

            PluginMetadataManager metadataManager = getPluginMetadataManager();
            Map<String, PluginDescriptor> extensions = metadataManager.getEmbeddedExtensions(plugin.getName());
            if (extensions != null && extensions.size() > 0) {
                for (Map.Entry<String, PluginDescriptor> entry : extensions.entrySet()) {
                    String extPluginName = entry.getKey();
                    PluginDescriptor extPluginDescriptor = entry.getValue();
                    log.debug("Plugin [" + extPluginName
                        + "] will be re-registered because it embeds types from plugin [" + plugin.getName() + "]");
                    registerPluginTypes(extPluginName, extPluginDescriptor, false, true);
                    resourceMetadataManager.removeObsoleteTypes(subjectMgr.getOverlord(), extPluginName,
                        metadataManager);
View Full Code Here

            // first, we need to parse all descriptors so we can build the dependency graph
            for (URL url : pluginUrls) {
                log.debug("Plugin found at: " + url);
                try {
                    PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
                    if (!disabledPlugins.contains(descriptor.getName())) {
                        AgentPluginDescriptorUtil.addPluginToDependencyGraph(graph, descriptor);
                        pluginNamesUrls.put(descriptor.getName(), url);
                        descriptors.put(url, descriptor);
                    } else {
                        log.info("Not loading disabled plugin: " + url);
                    }
                } catch (Throwable t) {
                    // probably due to invalid XML syntax in the deployment descriptor - the plugin will be ignored
                    log.error("Plugin at [" + url + "] could not be loaded and will therefore not be deployed.", t);
                    continue;
                }
            }

            // our graph is complete, get the order that we have to deploy the plugins
            List<String> deploymentOrder = graph.getDeploymentOrder();

            // now deploy the plugins in the proper order, making sure we build the proper classloaders
            for (String nextPlugin : deploymentOrder) {
                URL pluginUrl = pluginNamesUrls.get(nextPlugin);

                try {
                    ClassLoader pluginClassLoader = this.classLoaderManager.obtainPluginClassLoader(nextPlugin);
                    PluginDescriptor descriptor = descriptors.get(pluginUrl);
                    loadPlugin(pluginUrl, pluginClassLoader, descriptor);
                } catch (Throwable t) {
                    // for some reason, the plugin failed to load - it will be ignored, and its depending plugins will also fail later
                    log.error("Plugin [" + nextPlugin + "] at [" + pluginUrl
                        + "] could not be loaded and will therefore not be deployed.", t);
View Full Code Here

        JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);

        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        ValidationEventCollector vec = new ValidationEventCollector();
        unmarshaller.setEventHandler(vec);
        PluginDescriptor plugin = (PluginDescriptor) unmarshaller.unmarshal(new File(
            "src/test/xml/rhq-plugin-jmx-server-test.xml"));

        for (ValidationEvent event : vec.getEvents()) {
            System.out.println(event.getSeverity() + ":" + event.getMessage() + "    " + event.getLinkedException());
        }

        System.out.println(plugin.getDisplayName());
    }
View Full Code Here

        System.out.println(plugin.getDisplayName());
    }

    @Test
    public void writeDescriptor() throws JAXBException {
        PluginDescriptor p = new PluginDescriptor();
        p.setName("Postgres");
        p.setDisplayName("Postgres");
        p.setPackage("org.rhq.plugins.postgres");

        ServiceDescriptor table = new ServiceDescriptor();
        table.setName("Table");
        table.setClazz("org.rhq.plugins.postgres.TableServiceComponent");

        p.getServices().add(table);

        JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);

        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //JMMarshallerImpl.JAXME_INDENTATION_STRING, "\r\n");
View Full Code Here

   
        return null;
    }
   
    private static List<ResourceType> getResourceTypesInPlugin(String pluginUri) throws Exception {
        PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(new URI(pluginUri).toURL());
        PluginMetadataParser parser = new PluginMetadataParser(descriptor,
            Collections.<String, PluginMetadataParser> emptyMap());
   
        return parser.getAllTypes();
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor

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.