Package org.mc4j.ems.connection

Examples of org.mc4j.ems.connection.EmsConnection


    }

    // JMXComponent Implementation  --------------------------------------------

    public EmsConnection getEmsConnection() {
        EmsConnection emsConnection = null;

        try {
            emsConnection = loadConnection();
        } catch (Exception e) {
            log.error("Component attempting to access a connection that could not be loaded");
View Full Code Here


        System.out.println("Enable Destination Statistics..");
        Resource asResource = AppServerUtils.getASResource();
        ApplicationServerComponent asResourceComponenet = (ApplicationServerComponent) PluginContainer.getInstance()
            .getInventoryManager().getResourceComponent(asResource);

        EmsConnection emsConnection = asResourceComponenet.getEmsConnection();
        if (emsConnection == null) {
            throw new RuntimeException("Can not connect to the server");
        }
        EmsBean bean = emsConnection.getBean("jboss.messaging:service=ServerPeer");

        EmsOperation operation = bean.getOperation("enableMessageCounters");
        List<EmsParameter> params = operation.getParameters();
        int count = params.size();
        if (count == 0)
View Full Code Here

     *
     * @see #loadBean()
     */
    public EmsBean getEmsBean() {
        // make sure the connection used to cache the bean is still the current connection. if not, re-cache the bean
        EmsConnection beanConn = (null != this.bean) ? this.bean.getConnectionProvider().getExistingConnection() : null;
        EmsConnection currConn = (null != this.bean) ? getEmsConnection() : null;

        if ((null == this.bean) || !beanConn.equals(currConn)) {
            this.bean = loadBean();
            if (null == this.bean)
                throw new IllegalStateException("EMS bean was null for Resource with type ["
View Full Code Here

     *
     * @param objectName the name of the bean to load
     * @return the bean that is loaded
     */
    protected EmsBean loadBean(String objectName) {
        EmsConnection emsConnection = getEmsConnection();

        if (emsConnection != null) {
            EmsBean bean = emsConnection.getBean(objectName);
            if (bean == null) {
                // In some cases, this resource component may have been discovered by some means other than querying its
                // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a filesystem to discover EARs and
                // WARs that are not yet deployed). In such cases, getBean() will return null, since EMS won't have the
                // bean in its cache. To cover such cases, make an attempt to query the underlying MBeanServer for the
                // bean before giving up.
                emsConnection.queryBeans(objectName);
                bean = emsConnection.getBean(objectName);
            }

            return bean;
        }

View Full Code Here

        }
        jmxConfig.put(new PropertySimple(JmxConnectionHelper.CONNECTOR_DESCRIPTOR_TYPE, connectorDescriptorType));
        jmxConfig.put(new PropertySimple(JmxConnectionHelper.JBOSS_HOME_DIR, jbossHomeDir));

        this.jmxConnectionHelper = new JmxConnectionHelper(!runningEmbedded, resourceContext.getTemporaryDirectory());
        EmsConnection conn = this.jmxConnectionHelper.getEmsConnection(jmxConfig);
        if (conn != null) {
            log.info("Successfully obtained a JMX connection to "
                + jmxConfig.getSimpleValue(JmxConnectionHelper.CONNECTOR_ADDRESS, "-n/a-"));
        }
    }
View Full Code Here

        return Collections.singleton(resourceDetails);
    }

    @Nullable
    private EmsBean getRuntimeMXBean(ResourceDiscoveryContext<JMXComponent<?>> context) {
        EmsConnection emsConnection = context.getParentResourceComponent().getEmsConnection();
        if (emsConnection == null) {
            log.debug("Parent EMS connection is null for [" + context.getParentResourceContext().getResourceKey() + "] "
                                + context.getParentResourceContext().getResourceType() + " JVM.");
            return null;
        }

        // EmsConnection caches the list MBeans it previously found
        // See https://bugzilla.redhat.com/show_bug.cgi?id=924903
        emsConnection.refresh();

        EmsBean runtimeMBean = emsConnection.getBean(ManagementFactory.RUNTIME_MXBEAN_NAME);
        if (runtimeMBean == null) {
            log.debug("MBean [" + ManagementFactory.RUNTIME_MXBEAN_NAME + "] not found for ["
                    + context.getParentResourceContext().getResourceKey() + "] "
                    + context.getParentResourceContext().getResourceType() + " JVM.");
        }
View Full Code Here

        Set<DiscoveredResourceDetails> jmxResources = super.discoverResources(context);

        // JMX resources don't set the filename property, so munge them before going on
        JMXComponent parentComponent = context.getParentResourceComponent();
        ApplicationServerComponent applicationServerComponent = (ApplicationServerComponent) parentComponent;
        EmsConnection emsConnection = parentComponent.getEmsConnection();
        String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath()
            .getPath());

        List<String> earNames = new ArrayList<String>();
        for (DiscoveredResourceDetails jmxResource : jmxResources) {
View Full Code Here

        if (connectorAddress == null) {
            throw new InvalidPluginConfigurationException("A connector address must be specified when manually adding a JVM.");
        }

        ConnectionProvider connectionProvider;
        EmsConnection connection;
        try {
            connectionProvider = ConnectionProviderFactory.createConnectionProvider(pluginConfig, null,
                discoveryContext.getParentResourceContext().getTemporaryDirectory());
            connection = connectionProvider.connect();
            connection.loadSynchronous(false);
        } catch (Exception e) {
            if (e.getCause() instanceof SecurityException) {
                throw new InvalidPluginConfigurationException("Failed to authenticate to JVM with connector address ["
                        + connectorAddress + "] - principal and/or credentials connection properties are not set correctly.");
            }
View Full Code Here

        /*
         * Lookup all jboss.web:type=GlobalRequestProcessor,* MBeans in order to associate them later with the
         * corresponding jboss.web:type=Connector,* primary connector MBeans.
         */
        EmsConnection connection = context.getParentResourceComponent().getEmsConnection();
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(
            "jboss.web:type=GlobalRequestProcessor,name=%name%");
        List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());

        // We can't populate the name and scheme in the plugin config if the GlobalRequestProcessor MBeans aren't
        // deployed yet, so just abort and try again the next time the PC calls us.
        if (beans.size() != resourceDetails.size()) {
            if (log.isDebugEnabled())
View Full Code Here

        PropertySimple nameTemplateProp = report.getPluginConfiguration().getSimple("nameTemplate");
        String rName = nameTemplateProp.getStringValue();
        //noinspection ConstantConditions
        rName = rName.replace("{name}", name);

        EmsConnection connection = parentResourceComponent.getEmsConnection();

        if (DeploymentUtility.isDuplicateJndiName(connection, objectNamePreString, name)) {
            report.setStatus(CreateResourceStatus.FAILURE);
            report.setErrorMessage("Duplicate JNDI Name, a resource with that name already exists");
            return report;
View Full Code Here

TOP

Related Classes of org.mc4j.ems.connection.EmsConnection

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.