Package org.rhq.enterprise.server.xmlschema.generated.serverplugin

Examples of org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType


            throw new RuntimeException(e);
        }
    }
   
    public static ServerPlugin getPlugin(URL pluginUrl) throws Exception {
        ServerPluginDescriptorType type = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(pluginUrl);
       
        return getPlugin(pluginUrl, type);
    }
View Full Code Here


            try {
                Configuration pluginConfig = null;
                Configuration scheduledJobsConfig = null;
                ConfigurationDefinition configDef;

                ServerPluginDescriptorType pluginDescriptor = env.getPluginDescriptor();

                configDef = ServerPluginDescriptorMetadataParser.getPluginConfigurationDefinition(pluginDescriptor);
                if (configDef != null) {
                    pluginConfig = configDef.getDefaultTemplate().createConfiguration();
                }

                configDef = ServerPluginDescriptorMetadataParser.getScheduledJobsDefinition(pluginDescriptor);
                if (configDef != null) {
                    scheduledJobsConfig = configDef.getDefaultTemplate().createConfiguration();
                }

                File pluginFile = new File(env.getPluginUrl().toURI());
                ServerPlugin plugin = new ServerPlugin(0, env.getPluginKey().getPluginName(), pluginFile.getName(),
                    pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED, pluginDescriptor
                        .getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile), pluginDescriptor
                        .getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
                    new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(), System
                        .currentTimeMillis());
                return plugin;
            } catch (Exception e) {
                throw new RuntimeException(e);
View Full Code Here

     *
     * @param pluginFile the new server plugin file
     */
    private void registerServerPlugin(File pluginFile) {
        try {
            ServerPluginDescriptorType descriptor;
            descriptor = this.serverPluginsOnFilesystem.get(pluginFile).descriptor;

            String pluginName = descriptor.getName();
            String displayName = descriptor.getDisplayName();

            ComparableVersion version; // this must be non-null, the next line ensures this
            version = ServerPluginDescriptorUtil.getPluginVersion(pluginFile, descriptor);

            log.debug("Registering server plugin [" + pluginName + "], version " + version);

            ServerPlugin plugin = new ServerPlugin(pluginName, pluginFile.getName());
            plugin.setDisplayName((displayName != null) ? displayName : pluginName);
            plugin.setEnabled(!descriptor.isDisabledOnDiscovery());
            plugin.setDescription(descriptor.getDescription());
            plugin.setMtime(pluginFile.lastModified());
            plugin.setVersion(version.toString());
            plugin.setAmpsVersion(descriptor.getApiVersion());
            plugin.setMD5(MessageDigestGenerator.getDigestString(pluginFile));
            plugin.setPluginConfiguration(getDefaultPluginConfiguration(descriptor));
            plugin.setScheduledJobsConfiguration(getDefaultScheduledJobsConfiguration(descriptor));
            plugin.setType(new ServerPluginType(descriptor).stringify());

            if (descriptor.getHelp() != null && !descriptor.getHelp().getContent().isEmpty()) {
                plugin.setHelp(String.valueOf(descriptor.getHelp().getContent().get(0)));
            }

            ServerPluginManagerLocal serverPluginsManager = LookupUtil.getServerPluginManager();

            // see if this plugin has been deleted previously; if so, don't register and delete the file
View Full Code Here

    private ServerPlugin cacheFilesystemServerPluginJar(File pluginJar, @Nullable 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();
        ServerPluginDescriptorType descriptor = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(pluginUrl);
        String version = ServerPluginDescriptorUtil.getPluginVersion(pluginJar, descriptor).toString();
        String name = descriptor.getName();
        ServerPlugin plugin = new ServerPlugin(name, pluginJar.getName());
        plugin.setType(new ServerPluginType(descriptor).stringify());
        plugin.setMd5(md5);
        plugin.setVersion(version);
        plugin.setMtime(pluginJar.lastModified());
View Full Code Here

        try {
            Map<URL, ServerPluginDescriptorType> descriptors = new HashMap<URL, ServerPluginDescriptorType>();
            for (URL jar : jars) {
                try {
                    LOG.info("Parsing server plugin [" + jar + "]");
                    ServerPluginDescriptorType descriptor = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(jar);
                    descriptors.put(jar, descriptor);
                } catch (Exception e) {
                    LOG.error("Failed to parse descriptor from plugin [" + jar + "]", e);
                }
            }
            // make sure we successfully processed all the plugins that are in our finder
            boolean sizesMatch = (descriptors.size() == jars.size());
            if (!sizesMatch) {
                success = false;
                LOG.error("Only [" + descriptors.size() + "] out of [" + jars.size()
                    + "] plugin descriptors are valid.");
            } else {
                LOG.info("All [" + jars.size() + "] plugin descriptors are valid.");
            }

            classloaderManager = new ClassLoaderManager(descriptors, getClass().getClassLoader(), null);

            // examine all the resource types defined in all plugins and validate some things about them
            for (Map.Entry<URL, ServerPluginDescriptorType> entry : descriptors.entrySet()) {
                URL pluginUrl = entry.getKey();
                ServerPluginDescriptorType descriptor = entry.getValue();

                String pluginName = descriptor.getName();
                if (pluginName == null) {
                    LOG.error("No plugin name in [" + pluginUrl + "]");
                    success = false;
                    continue;
                } else {
View Full Code Here

     *                   in the plugin jar or the plugin jar is now missing
     */
    protected ServerPluginEnvironment rebuildServerPluginEnvironment(ServerPluginEnvironment env) throws Exception {
        URL url = env.getPluginUrl();
        ClassLoader classLoader = env.getPluginClassLoader();
        ServerPluginDescriptorType descriptor = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
        ServerPluginEnvironment newEnv = new ServerPluginEnvironment(url, classLoader, descriptor);
        return newEnv;
    }
View Full Code Here

    protected ServerPluginComponent createServerPluginComponent(ServerPluginEnvironment environment) throws Exception {

        String pluginName = environment.getPluginKey().getPluginName();
        ServerPluginComponent instance = null;

        ServerPluginDescriptorType descriptor = environment.getPluginDescriptor();
        String className = ServerPluginDescriptorMetadataParser.getPluginComponentClassName(descriptor);

        if (className != null) {
            log.debug("Creating plugin component [" + className + "] for plugin [" + pluginName + "]");
            instance = (ServerPluginComponent) instantiatePluginClass(environment, className);
View Full Code Here

    protected Class<?> loadPluginClass(ServerPluginEnvironment environment, String className, boolean initialize)
        throws Exception {

        ClassLoader loader = environment.getPluginClassLoader();

        ServerPluginDescriptorType descriptor = environment.getPluginDescriptor();
        className = ServerPluginDescriptorMetadataParser.getFullyQualifiedClassName(descriptor, className);

        log.debug("Loading server plugin class [" + className + "]...");

        Class<?> clazz;
View Full Code Here

        }

        File pluginsDir = LookupUtil.getServerPluginService().getServerPluginsDirectory();
        File pluginJar = new File(pluginsDir, plugin.getPath());
        URL url = pluginJar.toURI().toURL();
        ServerPluginDescriptorType descriptor = ServerPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
        return descriptor;
    }
View Full Code Here

        return allPlugins;
    }

    @Override
    public ConfigurationDefinition getServerPluginConfigurationDefinition(PluginKey pluginKey) throws Exception {
        ServerPluginDescriptorType descriptor = getServerPluginDescriptor(pluginKey);
        ConfigurationDefinition def;
        def = ConfigurationMetadataParser.parse("pc:" + pluginKey.getPluginName(), descriptor.getPluginConfiguration());
        return def;
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType

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.