Examples of AlertPluginDescriptorType


Examples of org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType

        AlertSenderInfo senderInfo = pluginmanager.getAlertSenderInfo(shortName);
        String pluginName = senderInfo.getPluginName();
        PluginKey key = senderInfo.getPluginKey();

        try {
            AlertPluginDescriptorType descriptor = (AlertPluginDescriptorType) serverPluginsBean
                .getServerPluginDescriptor(key);
            //ConfigurationDefinition pluginConfigurationDefinition = ConfigurationMetadataParser.parse("pc:" + pluginName, descriptor.getPluginConfiguration());
            ConfigurationDescriptor alertConfiguration = descriptor.getAlertConfiguration();
            if (alertConfiguration==null || alertConfiguration.getConfigurationProperty()== null || alertConfiguration.getConfigurationProperty().isEmpty()) {
                // User either provided no <alert-configuration> or an empty one
                return new ConfigurationDefinition("alerts:"+pluginName,"No properties given");
            }
            else {
View Full Code Here

Examples of org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType

    public boolean validate(ServerPluginEnvironment env) {

        Log log = LogFactory.getLog(AlertPluginValidator.class);

        AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();

        String className = type.getPluginClass();
        if (!className.contains(".")) {
            className = type.getPackage() + "." + className;
        }
        try {
            Class.forName(className, false, env.getPluginClassLoader());
        }
        catch (Exception e) {
            log.error("Can't find pluginClass " + className + " for plugin " + env.getPluginKey().getPluginName());
            return false;
        }

        // The short name is basically the key into the plugin
        String shortName = type.getShortName();

        //
        // Ok, we have a valid plugin class, so we can look for other things
        // and store the info
        //

        String uiSnippetPath;
        String beanName;
        CustomUi customUI = type.getCustomUi();
        if (customUI != null) {
            uiSnippetPath = customUI.getUiSnippetName();

            try {
                URL uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath);
                log.info("UI snipped for " + shortName + " is at " + uiSnippetUrl);
            }
            catch (Exception e) {
                log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName +
                        "Error is " + e.getMessage());
                return false;
            }

            // Get the backing bean class
            className = customUI.getBackingBeanClass();
            if (!className.contains(".")) {
                className = type.getPackage() + "." + className;
            }
            try {
                Class.forName(className, true, env.getPluginClassLoader());
            }
            catch (Throwable t) {
View Full Code Here

Examples of org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType

        super.loadPlugin(env, enabled);

        if (enabled) {

            AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor();

            // make sure the alert sender class name is valid
            String className = type.getPluginClass();
            try {
                loadPluginClass(env, className, false);
            } catch (Exception e) {
                log.error("Alert sender class [" + className + "] defined in plugin ["
                    + env.getPluginKey().getPluginName() + "] is invalid and will be ignored. Cause: "
                    + ThrowableUtil.getAllMessages(e));
                try {
                    unloadPlugin(env.getPluginKey().getPluginName());
                } catch (Throwable t) {
                    log.warn("  +--> unload failed too. Cause: " + ThrowableUtil.getAllMessages(t));
                }
                throw e;
            }

            //
            // Ok, we have a valid plugin class, so we can look for other things and store the info
            //

            // The short name is basically the key into the plugin
            String shortName = type.getShortName();
            pluginClassByName.put(shortName, className);

            // UI snippet path allows the plugin to inject user interface fragments to the alert pages
            String uiSnippetPath = null;
            URL uiSnippetUrl = null;
            CustomUi customUI = type.getCustomUi();
            if (customUI != null) {
                uiSnippetPath = customUI.getUiSnippetName();

                try {
                    uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath);
                    if (uiSnippetUrl == null) {
                        throw new Exception("plugin is missing alert ui snippet named [" + uiSnippetPath + "]");
                    }
                    log.debug("Alert plugin UI snippet for [" + shortName + "] is at: " + uiSnippetUrl);
                } catch (Exception e) {
                    log.error("Invalid alert UI snippet provided inside <custom-ui> for alert plugin [" + shortName
                        + "]. Plugin will be ignored. Cause: " + ThrowableUtil.getAllMessages(e));
                    throw e;
                }

                className = customUI.getBackingBeanClass();
                try {
                    loadPluginClass(env, className, true); // TODO how make this available to Seam and the Web-CL ?
                    backingBeanByName.put(shortName, className);
                } catch (Throwable t) {
                    String errMsg = "Backing bean [" + className + "] not found for plugin [" + shortName + ']';
                    log.error(errMsg);
                    throw new Exception(errMsg, t);
                }

                String beanName = customUI.getBackingBeanName();

                // Default to <backing-bean-class> value if name is not provided
                if (beanName == null || beanName.length() == 0) {
                    beanName = className;
                }

                backingBeanNameByName.put(shortName, beanName);
            }

            AlertSenderInfo info = new AlertSenderInfo(shortName, type.getDescription(), env.getPluginKey());
            info.setUiSnippetUrl(uiSnippetUrl);
            info.setUiSnippetShortPath(uiSnippetPath);
            senderInfoByName.put(shortName, info);
            pluginEnvByName.put(shortName, env);
        }
View Full Code Here

Examples of org.rhq.enterprise.server.xmlschema.generated.serverplugin.alert.AlertPluginDescriptorType

    public void testAlertPluginDescriptor() throws Exception {
        String testXml = "test-serverplugin-alert.xml";
        ServerPluginDescriptorType data = parseTestXml(testXml);
        assert data instanceof AlertPluginDescriptorType;
        AlertPluginDescriptorType descriptor = (AlertPluginDescriptorType) data;

        assert descriptor.getApiVersion().equals("11.22");
        assert descriptor.getVersion().equals("100.999");
        assert descriptor.getName().equals("alert plugin name");
        assert descriptor.getDisplayName().equals("alert plugin display name");
        assert descriptor.getDescription().equals("alert plugin wotgorilla?");
        assert descriptor.getPackage().equals("org.alert.package.name.here");
        assert descriptor.isDisabledOnDiscovery() == true;

        ServerPluginComponentType pluginComponent = descriptor.getPluginComponent();
        assert pluginComponent.getClazz().equals("alertPluginComponent");

        assert descriptor.getScheduledJobs() == null;
        assert ServerPluginDescriptorMetadataParser.getScheduledJobs(descriptor).size() == 0;

        ConfigurationDescriptor configDescriptor = descriptor.getPluginConfiguration();
        assert configDescriptor != null;
        assert configDescriptor.getConfigurationProperty().get(0).getValue().getName().equals("alertprop1");

        ConfigurationDefinition config;
        config = ServerPluginDescriptorMetadataParser.getPluginConfigurationDefinition(descriptor);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.