Package org.rhq.core.pluginapi.inventory

Examples of org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException


    void validateJBossHomeDirProperty() {
        Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
        String jbossHome = getRequiredPropertyValue(pluginConfig, JBOSS_HOME_DIR_CONFIG_PROP);
        File jbossHomeDir = new File(jbossHome);
        if (!jbossHomeDir.isAbsolute()) {
            throw new InvalidPluginConfigurationException(
                JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP
                    + " connection property ('"
                    + jbossHomeDir
                    + "') is not an absolute path. Note, on Windows, absolute paths must start with the drive letter (e.g. C:).");
        }

        if (!jbossHomeDir.exists()) {
            throw new InvalidPluginConfigurationException(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP
                + " connection property ('" + jbossHomeDir + "') does not exist.");
        }

        if (!jbossHomeDir.isDirectory()) {
            throw new InvalidPluginConfigurationException(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP
                + " connection property ('" + jbossHomeDir + "') is a file, not a directory.");
        }
    }
View Full Code Here


        Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
        String javaHome = pluginConfig.getSimpleValue(JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP, null);
        if (javaHome != null) {
            File javaHomeDir = new File(javaHome);
            if (!javaHomeDir.isAbsolute()) {
                throw new InvalidPluginConfigurationException(
                    JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP
                        + " connection property ('"
                        + javaHomeDir
                        + "') is not an absolute path. Note, on Windows, absolute paths must start with the drive letter (e.g. C:).");
            }

            if (!javaHomeDir.exists()) {
                throw new InvalidPluginConfigurationException(JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP
                    + " connection property ('" + javaHomeDir + "') does not exist.");
            }

            if (!javaHomeDir.isDirectory()) {
                throw new InvalidPluginConfigurationException(JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP
                    + " connection property ('" + javaHomeDir + "') is not a directory.");
            }
        }
    }
View Full Code Here

        Class<?> connectionTypeDescriptorClass;
        try {
            connectionTypeDescriptorClass = Class.forName(connectionTypeDescriptorClassName);
        } catch (ClassNotFoundException e) {
            throw new InvalidPluginConfigurationException("Invalid connection type - class [" + connectionTypeDescriptorClassName
                            + "] not found.");
        }
        if (!(ConnectionTypeDescriptor.class.isAssignableFrom(connectionTypeDescriptorClass))) {
            throw new InvalidPluginConfigurationException("Invalid connection type - class [" + connectionTypeDescriptorClassName
                + "] does not implement the " + ConnectionTypeDescriptor.class.getName() + " interface.");
        }
        ConnectionTypeDescriptor connectionTypeDescriptor;
        try {
            connectionTypeDescriptor = (ConnectionTypeDescriptor) connectionTypeDescriptorClass.newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Failed to instantiate connection type descriptor of type [" + connectionTypeDescriptorClassName + "].", e);
        }

        ConnectionSettings settings = new ConnectionSettings();
        settings.initializeConnectionType(connectionTypeDescriptor);

        // Set principal and credentials.
        String principal = pluginConfig.getSimpleValue(JMXComponent.PRINCIPAL_CONFIG_PROP, null);
        settings.setPrincipal(principal);
        String credentials = pluginConfig.getSimpleValue(JMXComponent.CREDENTIALS_CONFIG_PROP, null);
        settings.setCredentials(credentials);

        if (connectionTypeDescriptor instanceof LocalVMTypeDescriptor) {
            // NOTE (ips, 01/19/12): This is not very reliable for long-term management of a JVM, since it uses the
            //                       command line from the time the JVM was originally discovered, which may have changed.
            String commandLine = pluginConfig.getSimpleValue(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY, null);
            if (commandLine == null) {
                throw new InvalidPluginConfigurationException("A command line is required for the "
                    + connectionTypeDescriptorClassName + " connection type.");
            }

            Map<Integer, LocalVirtualMachine> vms = LocalVMFinder.getManageableVirtualMachines();
            LocalVirtualMachine targetVm = null;
            if (vms != null) {
                for (LocalVirtualMachine vm : vms.values()) {
                    if (vm.getCommandLine().equals(commandLine)) {
                        targetVm = vm;
                        break;
                    }
                }
            }
            if (targetVm == null) {
                // This could just be because the JVM is not currently running.
                throw new Exception("JVM with command line [" + commandLine + "] not found.");
            }
            String vmId = String.valueOf(targetVm.getVmid());
            settings.setServerUrl(vmId);
        } else if (connectionTypeDescriptor instanceof J2SE5ConnectionTypeDescriptor) {
            // Connect via JMX Remoting, using the JVM Attach API to start up a JMX Remoting Agent if necessary.
            String jmxConnectorAddress = getJmxConnectorAddress(pluginConfig, process);
            settings.setServerUrl(jmxConnectorAddress);
        } else {
            // Handle internal connections (InternalVMTypeDescriptor) (i.e. the RHQ plugin container's own JVM), as
            // well as miscellaneous types of remote connections - WebSphere, WebLogic, etc.
            String connectorAddress = pluginConfig.getSimpleValue(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY,
                        null);
            if (connectorAddress == null) {
                throw new InvalidPluginConfigurationException("A connector address is required for the "
                    + connectionTypeDescriptorClassName + " connection type.");
            }
            settings.setServerUrl(connectorAddress);
            String installURI = pluginConfig.getSimpleValue(JMXDiscoveryComponent.INSTALL_URI, null);
            settings.setLibraryURI(installURI);
View Full Code Here

        // Figure out if the instance is AS or EAP, and reflect that in the Resource name.
        JBossInstallationInfo installInfo;
        try {
            installInfo = new JBossInstallationInfo(new File(homeDir));
        } catch (IOException e) {
            throw new InvalidPluginConfigurationException(e);
        }

        JBossProductType productType = installInfo.getProductType();
        String resourceName = productType.NAME;
        resourceName += " " + installInfo.getMajorVersion();
View Full Code Here

    public void start(ResourceContext<AgentServerComponent<?>> resourceContext) throws Exception {
        Configuration pc = resourceContext.getPluginConfiguration();
        PropertySimple pathnameProp = pc.getSimple(AgentEnvironmentScriptDiscoveryComponent.PLUGINCONFIG_PATHNAME);
        if (pathnameProp == null) {
            throw new InvalidPluginConfigurationException("Pathname property is missing");
        }
        if (pathnameProp.getStringValue() == null) {
            throw new InvalidPluginConfigurationException("Pathname property value is null");
        }

        script = new File(pathnameProp.getStringValue());
        if (!script.exists()) {
            throw new InvalidPluginConfigurationException("Script [" + script + "] does not exist");
        }

        log.debug("Starting agent env script component: " + script);

        // we've got the script pathname and it does exist, we are good to start
View Full Code Here

            if (includesPatternString != null) {
                try {
                    Pattern includesPattern = Pattern.compile(includesPatternString);
                    processor.setIncludesPattern(includesPattern);
                } catch (PatternSyntaxException e) {
                    throw new InvalidPluginConfigurationException("Includes pattern [" + includesPatternString
                        + "] is not a valid regular expression.");
                }
            }
            String minimumSeverityString = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY,
                null);
View Full Code Here

    static Connection buildConnection(Configuration pluginConfig) throws SQLException {
        String driverClass = "com.mysql.jdbc.Driver";
        try {
            Class.forName(driverClass);
        } catch (ClassNotFoundException e) {
            throw new InvalidPluginConfigurationException("Specified JDBC driver class (" + driverClass
                + ") not found.");
        }

        String url = buildConnectionURL(pluginConfig);
        String principal = pluginConfig.getSimple(PRINCIPAL_CONFIGURATION_PROPERTY).getStringValue();
View Full Code Here

        PropertySimple prop;

        prop = pc.getSimple(AgentJavaServiceWrapperDiscoveryComponent.PLUGINCONFIG_LAUNCHER_SCRIPT);
        if (prop == null) {
            throw new InvalidPluginConfigurationException("Missing Launcher Script");
        }
        if (prop.getStringValue() == null) {
            throw new InvalidPluginConfigurationException("Launcher Script property value is null");
        }

        launcherScript = new File(prop.getStringValue());
        if (!launcherScript.exists()) {
            throw new InvalidPluginConfigurationException("Launcher Script [" + launcherScript + "] does not exist");
        }

        prop = pc.getSimple(AgentJavaServiceWrapperDiscoveryComponent.PLUGINCONFIG_CONF_FILE);
        if (prop == null) {
            throw new InvalidPluginConfigurationException("Missing Configuration File");
        }
        if (prop.getStringValue() == null) {
            throw new InvalidPluginConfigurationException("Configuration File property value is null");
        }

        configFile = new File(prop.getStringValue());
        if (!configFile.exists()) {
            throw new InvalidPluginConfigurationException("Config file [" + configFile + "] does not exist");
        }

        log.debug("Starting agent JSW component: " + configFile);

        // get the optional files (these may remain null if the paths were left undefined)
View Full Code Here

    @Override
    public void start(ResourceContext context) throws Exception {
        Configuration pluginConfig = context.getPluginConfiguration();
        String connectionType = pluginConfig.getSimpleValue(JMXDiscoveryComponent.CONNECTION_TYPE, "");
        if (!connectionType.equals(JMXDiscoveryComponent.PARENT_TYPE)) {
            throw new InvalidPluginConfigurationException("The only legal connection type for embedded JVM Resources is \""
                    + JMXDiscoveryComponent.PARENT_TYPE + "\".");
        }

        super.start(context);
    }
View Full Code Here

           */
         String user = pluginConfig.getSimpleValue("user",null);
         String password = pluginConfig.getSimpleValue("password",null);
         String url = pluginConfig.getSimpleValue("baseurl","http://twitter.com/");
         if (user==null || password==null)
            throw new InvalidPluginConfigurationException("User or password were not set");

         DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
                discoveryContext.getResourceType(), // ResourceType
                url + "_"+ user, // ResourceKey
                url + " feed for " +user,
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException

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.