Package org.rhq.core.domain.plugin

Examples of org.rhq.core.domain.plugin.ServerPlugin


    }

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void purgeServerPlugin(int pluginId) {
        // get the reference to attach to em and use the em.remove. this cascade deletes too.
        ServerPlugin doomed = this.entityManager.find(ServerPlugin.class, pluginId);
        doomed.getServersAcknowledgedDelete().clear();
        this.entityManager.remove(doomed);

        log.info("Server plugin [" + doomed + "] has been purged from the db");
        return;
    }
View Full Code Here


            if (config != null) {
                config = entityManager.merge(config);
                plugin.setScheduledJobsConfiguration(config);
            }

            ServerPlugin pluginEntity = entityManager.getReference(ServerPlugin.class, plugin.getId());
            pluginEntity.setName(plugin.getName());
            pluginEntity.setPath(plugin.getPath());
            pluginEntity.setDisplayName(plugin.getDisplayName());
            pluginEntity.setEnabled(plugin.isEnabled());
            pluginEntity.setStatus(plugin.getStatus());
            pluginEntity.setMd5(plugin.getMD5());
            pluginEntity.setVersion(plugin.getVersion());
            pluginEntity.setAmpsVersion(plugin.getAmpsVersion());
            pluginEntity.setDeployment(plugin.getDeployment());
            pluginEntity.setPluginConfiguration(plugin.getPluginConfiguration());
            pluginEntity.setScheduledJobsConfiguration(plugin.getScheduledJobsConfiguration());
            pluginEntity.setType(plugin.getType());
            pluginEntity.setDescription(plugin.getDescription());
            pluginEntity.setHelp(plugin.getHelp());
            pluginEntity.setMtime(plugin.getMtime());

            try {
                entityManager.flush(); // make sure we push this out to the DB now
            } catch (Exception e) {
                throw new Exception("Failed to update a plugin that matches [" + plugin + "]", e);
View Full Code Here

        }
    }

    @Override
    public boolean isReadyForPurge(int pluginId) {
        ServerPlugin plugin = entityManager.find(ServerPlugin.class, pluginId);

        @SuppressWarnings("unchecked")
        List<Server> allServers = entityManager.createNamedQuery(Server.QUERY_FIND_ALL).getResultList();

        for (Server s : allServers) {
            if (!plugin.getServersAcknowledgedDelete().contains(s)) {
                if (log.isDebugEnabled()) {
                    log.debug(plugin + " is not ready to be purged. Server " + s +
                        " has not acknowledged it knows about its deletion.");
                }
                return false;
View Full Code Here

    public ServerPlugin getServerPlugin(PluginKey key) {
        Query query = entityManager.createNamedQuery(ServerPlugin.QUERY_FIND_BY_NAME);
        query.setParameter("name", key.getPluginName());
        try {
            ServerPlugin plugin = (ServerPlugin) query.getSingleResult();
            return plugin;
        } catch (NoResultException nre) {
            return null;
        }
    }
View Full Code Here

        }
        return lastConfigChangeTimestamp;
    }

    public ServerPluginDescriptorType getServerPluginDescriptor(PluginKey pluginKey) throws Exception {
        ServerPlugin plugin = getServerPlugin(pluginKey);
        if (plugin == null) {
            throw new IllegalArgumentException("Unknown plugin key: " + pluginKey);
        }

        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

        List<PluginKey> pluginKeys = new ArrayList<PluginKey>();
        List<ServerPlugin> toEnable = new ArrayList<ServerPlugin>();
        // first we read plugins from DB and check whether they are configured
        // (such plugin would fail to load - in this case we don't enable anything and just throw PluginConfigurationRequiredException)
        for (Integer pluginId : pluginIds) {
            ServerPlugin plugin = null;
            try {
                plugin = entityManager.getReference(ServerPlugin.class, pluginId);
            } catch (Exception e) {
                log.debug("Cannot enable plugin [" + pluginId + "]. Cause: " + ThrowableUtil.getAllMessages(e));
            }
View Full Code Here

        List<PluginKey> pluginKeys = new ArrayList<PluginKey>();

        for (Integer pluginId : pluginIds) {
            serverPluginsBean.setServerPluginEnabledFlag(subject, pluginId, false);

            ServerPlugin plugin = null;
            try {
                plugin = entityManager.getReference(ServerPlugin.class, pluginId);
            } catch (Exception e) {
                log.debug("Cannot disable plugin [" + pluginId + "]. Cause: " + ThrowableUtil.getAllMessages(e));
            }
View Full Code Here

        List<PluginKey> pluginKeys = new ArrayList<PluginKey>();

        for (Integer pluginId : pluginIds) {
            serverPluginsBean.setServerPluginEnabledFlag(subject, pluginId, false);

            ServerPlugin plugin = null;
            try {
                plugin = entityManager.getReference(ServerPlugin.class, pluginId);
            } catch (Exception e) {
                log.debug("Cannot undeploy plugin [" + pluginId + "]. Cause: " + ThrowableUtil.getAllMessages(e));
            }
            if (plugin != null) {
                PluginKey pluginKey = new PluginKey(plugin);
                boolean success = undeployServerPluginInMasterContainer(pluginKey);
                if (success) {
                    pluginKeys.add(pluginKey);
                }

                // if this plugin ever gets re-installed, let's support the use-case where the new plugin
                // will have different config metadata. Here we null out the old config so the new
                // config can be set to the new config definition's default values.
                if (plugin.getPluginConfiguration() != null) {
                    entityManager.remove(plugin.getPluginConfiguration());
                    plugin.setPluginConfiguration(null);
                }
                if (plugin.getScheduledJobsConfiguration() != null) {
                    entityManager.remove(plugin.getScheduledJobsConfiguration());
                    plugin.setScheduledJobsConfiguration(null);
                }
                plugin.setStatus(PluginStatusType.DELETED);

                // purge the file from the filesystem, we do not want this deployed again
                try {
                    File pluginDir = LookupUtil.getServerPluginService().getServerPluginsDirectory();
                    File currentFile = new File(pluginDir, plugin.getPath());
                    currentFile.delete();
                } catch (Exception e) {
                    log.error("Failed to delete the undeployed plugin file [" + plugin.getPath() + "]. Cause: "
                        + ThrowableUtil.getAllMessages(e));
                }
                log.info("Server plugin [" + pluginKey + "] has been undeployed");
            }
        }
View Full Code Here

        }
    }

    //    @RequestParameter("listName")
    public void setListName(String listName) {
        ServerPlugin plugin = getPlugin();

        if (listName != null && plugin != null) {
            if (hasListName(plugin.getPluginConfiguration(), listName)) {
                this.currentConfiguration = plugin.getPluginConfiguration();
                this.currentConfigurationDefinition = getPluginConfigurationDefinition();
            } else if (hasListName(plugin.getScheduledJobsConfiguration(), listName)) {
                this.currentConfiguration = plugin.getScheduledJobsConfiguration();
                this.currentConfigurationDefinition = getScheduledJobsDefinition();
            }
        }
    }
View Full Code Here

    public String updatePlugin() {
        try {
            ServerPluginManagerLocal serverPlugins = LookupUtil.getServerPluginManager();
            Subject subject = EnterpriseFacesContextUtility.getSubject();

            ServerPlugin plugin = serverPlugins.updateServerPluginExceptContent(subject, getPlugin());
            setPlugin(plugin);

            // Since the config has changed, we can tell the server to re-load the plugin now
            // in order for it to pick up the changes immediately. Any other servers in the HA Server Cloud
            // will pick up these changes later, when they scan for changes in the database.
            // Note that if the plugin is disabled, don't bother since the plugin isn't really running anyway.
            if (plugin.isEnabled()) {
                // enabling an already enabled plugin forces the plugin to reload
                serverPlugins.enableServerPlugins(subject, getPluginIdList());
            }

            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration settings saved.");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.plugin.ServerPlugin

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.