Package org.rhq.plugins.jbossas5

Examples of org.rhq.plugins.jbossas5.ApplicationServerComponent


                LOG.error("Failed to process JBoss AS command line: " + Arrays.asList(processInfo.getCommandLine()), e);
                continue;
            }

            // Skip it if it's an AS/EAP/SOA-P version we don't support.
            JBossInstallationInfo installInfo = jbossInstanceInfo.getInstallInfo();
            if (!isSupportedProduct(installInfo)) {
                continue;
            }

            File installHome = new File(jbossInstanceInfo.getSystemProperties().getProperty(JBossProperties.HOME_DIR));
View Full Code Here


        String resourceKey = serverHomeDir;

        // homeDir is the full path to the JBoss installation dir used by this instance, e.g. "/opt/jboss-5.1.0.GA".
        String homeDir = (String) ManagedComponentUtils.getSimplePropertyValue(serverConfigComponent, "homeDir");
        // 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();
        resourceName += " (" + serverName + ")";

        String description = productType.DESCRIPTION;

        String version = (String) ManagedComponentUtils.getSimplePropertyValue(serverConfigComponent,
View Full Code Here

        for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
            ProcessInfo processInfo = autoDiscoveryResult.getProcessInfo();
            if (LOG.isDebugEnabled())
                LOG.debug("Discovered JBoss AS process: " + processInfo);

            JBossInstanceInfo jbossInstanceInfo;
            try {
                jbossInstanceInfo = new JBossInstanceInfo(processInfo);
            } catch (Exception e) {
                LOG.error("Failed to process JBoss AS command line: " + Arrays.asList(processInfo.getCommandLine()), e);
                continue;
            }

            // Skip it if it's an AS/EAP/SOA-P version we don't support.
            JBossInstallationInfo installInfo = jbossInstanceInfo.getInstallInfo();
            if (!isSupportedProduct(installInfo)) {
                continue;
            }

            File installHome = new File(jbossInstanceInfo.getSystemProperties().getProperty(JBossProperties.HOME_DIR));
            File configDir = new File(jbossInstanceInfo.getSystemProperties().getProperty(
                JBossProperties.SERVER_HOME_DIR));

            // The config dir might be a symlink - call getCanonicalFile() to resolve it if so, before
            // calling isDirectory() (isDirectory() returns false for a symlink, even if it points at
            // a directory).
            try {
                if (!configDir.getCanonicalFile().isDirectory()) {
                    LOG.warn("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                        + configDir + "' does not exist or is not a directory.");
                    continue;
                }
            } catch (IOException e) {
                LOG.error("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                    + configDir + "' could not be canonicalized.", e);
                continue;
            }

            Configuration pluginConfiguration = discoveryContext.getDefaultPluginConfiguration();

            // TODO? Set the connection type - local or remote

            // Set the required props...
            String jnpURL = getJnpURL(jbossInstanceInfo, installHome, configDir);
            PropertySimple namingUrlProp = new PropertySimple(
                ApplicationServerPluginConfigurationProperties.NAMING_URL, jnpURL);
            if (jnpURL == null) {
                namingUrlProp.setErrorMessage("RHQ failed to discover the naming provider URL.");
            }
            pluginConfiguration.put(namingUrlProp);
            pluginConfiguration.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.HOME_DIR,
                installHome.getAbsolutePath()));
            pluginConfiguration.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR,
                configDir));

            // Set the optional props...
            pluginConfiguration.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.SERVER_NAME,
                jbossInstanceInfo.getSystemProperties().getProperty(JBossProperties.SERVER_NAME)));
            pluginConfiguration.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.BIND_ADDRESS,
                jbossInstanceInfo.getSystemProperties().getProperty(JBossProperties.BIND_ADDRESS)));

            JBossASDiscoveryUtils.UserInfo userInfo = JBossASDiscoveryUtils.getJmxInvokerUserInfo(configDir);
            if (userInfo != null) {
                pluginConfiguration.put(new PropertySimple(ApplicationServerPluginConfigurationProperties.PRINCIPAL,
                    userInfo.getUsername()));
View Full Code Here

            };
        }
    }

    public void testSysProps() throws Exception {
        JBossInstanceInfo instanceInfo = new JBossInstanceInfo(new TestProcessInfo());
        Properties sysprops = instanceInfo.getSystemProperties();
        Assert.assertNotNull(sysprops);
        Assert.assertEquals(sysprops.size(), 16, sysprops.toString());
        Assert.assertEquals(sysprops.get("[Standalone]"), "");
        Assert.assertEquals(sysprops.get("prop1"), "delta");
        Assert.assertEquals(sysprops.get("prop2"), "zeta");
View Full Code Here

            if (uri.getPort() != -1) {
                namingPort = String.valueOf(uri.getPort());
            }
        }

        final JBossProductType productType = installInfo.getProductType();
        String description = productType.DESCRIPTION + " " + installInfo.getMajorVersion();
        File deployDir = new File(absoluteConfigPath, "deploy");

        File rhqInstallerWar = new File(deployDir, "rhq-installer.war");
        File rhqInstallerWarUndeployed = new File(deployDir, "rhq-installer.war.rej");
        boolean isRhqServer = rhqInstallerWar.exists() || rhqInstallerWarUndeployed.exists();
        if (isRhqServer) {
            description += " hosting the RHQ Server";
            // We know this is an RHQ Server. Let's add an event source for its server log file, but disable it by default.
            configureEventSourceForServerLogFile(pluginConfig);
        }
        final String PRODUCT_PREFIX = productType.name() + " ";
        String name = PRODUCT_PREFIX
            + formatServerName(bindAddress, namingPort, discoveryContext.getSystemInformation().getHostname(),
                absoluteConfigPath.getName(), isRhqServer);

        // If we are discovering plugin config via processInfo, then in addition to everything we discover above,
View Full Code Here

        }
    }

    private boolean isSupportedProduct(JBossInstallationInfo installInfo) {
        ComparableVersion version = new ComparableVersion(installInfo.getVersion());
        JBossProductType productType = installInfo.getProductType();
        ComparableVersion minimumVersion = MINIMUM_PRODUCT_VERSIONS.get(productType);
        boolean supported;
        if (minimumVersion != null) {
            // The product is supported if the version is greater than or equal to the minimum version.
            supported = (version.compareTo(minimumVersion) >= 0);
View Full Code Here

            installInfo = new JBossInstallationInfo(new File(homeDir));
        } catch (IOException e) {
            throw new InvalidPluginConfigurationException(e);
        }

        JBossProductType productType = installInfo.getProductType();
        String resourceName = productType.NAME;
        resourceName += " " + installInfo.getMajorVersion();
        resourceName += " (" + serverName + ")";

        String description = productType.DESCRIPTION;
View Full Code Here

        PackageType mockPackageType = mock(PackageType.class);
        when(mockPackageType.getName()).thenReturn("script");

        //create object to test and inject required dependencies
        ScriptComponent objectUnderTest = new ScriptComponent();
        objectUnderTest.start(mockResourceContext);

        //run code under test
        Set<ResourcePackageDetails> result = objectUnderTest.discoverDeployedPackages(mockPackageType);

        //verify the results (Assert and mock verification)
        Assert.assertEquals(result.size(), 1);

        ResourcePackageDetails resultPackageDetails = (ResourcePackageDetails) result.toArray()[0];
View Full Code Here

        public String getExpectedResourceKey() {
            return "HelloWorldBean";
        }

        public MethodArgDef[] getTestedMethodArgs() {
            return new MethodArgDef[] { new MethodArgDef(String.class, "John Doe") };
        }
View Full Code Here

            Object entityHome = AppServerUtils.getRemoteObject(JNDI_NAME, Object.class);

            //create the entities
            ArrayList<Object> entities = new ArrayList<Object>();
            for (int i = 0; i < CREATE_COUNT; ++i) {
                entities.add(AppServerUtils.invokeMethod("create", entityHome, new MethodArgDef[] { new MethodArgDef(String.class,
                    KEY_PREFIX + i) }));
            }

            //try to find the entities
            for (int i = 0; i < CREATE_COUNT; ++i) {
                AppServerUtils.invokeMethod("findByPrimaryKey", entityHome, new MethodArgDef[] { new MethodArgDef(String.class,
                    KEY_PREFIX + i) });
            }

            //update some
            for (int i = 0; i < UPDATE_COUNT; ++i) {
                Object entity = entities.get(i);
                AppServerUtils.invokeMethod("setInt", entity, new MethodArgDef[] { new MethodArgDef(int.class, i) });
            }

            //delete some
            for (int i = 0; i < DELETE_COUNT; ++i) {
                AppServerUtils.invokeMethod("remove", entities.get(i), (MethodArgDef[]) null);
View Full Code Here

TOP

Related Classes of org.rhq.plugins.jbossas5.ApplicationServerComponent

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.