Package org.mc4j.ems.connection.bean

Examples of org.mc4j.ems.connection.bean.EmsBean


        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)
            operation.invoke(new Object[0]);
        else { // overloaded operation
            operation.invoke(new Object[] { 0 }); // return code of 0
        }

        //reset counters
        operation = bean.getOperation("resetAllMessageCounters");
        params = operation.getParameters();
        count = params.size();
        if (count == 0)
            operation.invoke(new Object[0]);
        else { // overloaded operation
            operation.invoke(new Object[] { 0 }); // return code of 0
        }

        operation = bean.getOperation("resetAllMessageCounterHistories");
        params = operation.getParameters();
        count = params.size();
        if (count == 0)
            operation.invoke(new Object[0]);
        else { // overloaded operation
View Full Code Here


        when(mockResourcePackageDetails.getDeploymentTimeConfiguration()).thenReturn(mockConfiguration);
        PropertySimple mockPropertySimple = mock(PropertySimple.class);
        when(mockConfiguration.getSimple(any(String.class))).thenReturn(mockPropertySimple);
        when(mockPropertySimple.getBooleanValue()).thenReturn(Boolean.TRUE);

        EmsBean mockEmsBean = mock(EmsBean.class);
        when(objectUnderTest.getEmsBean()).thenReturn(mockEmsBean);
        EmsAttribute mockEmsAttribute = mock(EmsAttribute.class);
        when(mockEmsBean.getAttribute(anyString())).thenReturn(mockEmsAttribute);
        when(mockEmsAttribute.getValue()).thenReturn(Boolean.TRUE);

        File deploymentDirectory = new File(this.getClass().getResource("/").getFile() + "deploymentDirectory");
        deleteRecursive(deploymentDirectory);
        when(objectUnderTest.getConfigurationPath()).thenReturn(deploymentDirectory);
View Full Code Here

     * @return the bean that is loaded
     */
    protected EmsBean loadBean() {
        Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
        String objectName = pluginConfig.getSimple(OBJECT_NAME_PROP).getStringValue();
        EmsBean loadedBean = loadBean(objectName);
        return loadedBean;
    }
View Full Code Here

     */
    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
View Full Code Here

            }
        }
    }

    private boolean isMBeanAvailable() {
        EmsBean emsBean = getEmsBean();
        boolean isAvailable = emsBean.isRegistered();
        if (isAvailable == false) {
            // in some buggy situations, a remote server might tell us an MBean isn't registered but it really is.
            // see JBPAPP-2031 for more
            String emsBeanName = emsBean.getBeanName().getCanonicalName();
            int size = emsBean.getConnectionProvider().getExistingConnection().queryBeans(emsBeanName).size();
            isAvailable = (size == 1);
        }
        return isAvailable;
    }
View Full Code Here

        // First do the default properties against this component's main bean
        getBeanProperties(report, bean, defaultBeanRequests);

        for (String beanNameTemplate : beansMap.keySet()) {
            String transformedbeanName = transformBeanName(beanNameTemplate);
            EmsBean otherBean = getEmsConnection().getBean(transformedbeanName);
            if (otherBean == null) {
                log.info("Unable to retrieve associated MBean: " + transformedbeanName);
            } else {
                getBeanProperties(report, otherBean, beansMap.get(beanNameTemplate));
            }
View Full Code Here

    private final Log log = LogFactory.getLog(EmbeddedJMXServerDiscoveryComponent.class);

    public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context)
        throws Exception {
        // Only inventory a JVM that has the platform MXBeans exposed.
        EmsBean runtimeMBean = getRuntimeMXBean(context);
        if (runtimeMBean == null) {
            return Collections.emptySet();
        }

        String name = ParentDefinedJMXServerNamingUtility.getJVMName(context);
View Full Code Here

        // 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

    }

    private String getJavaVersion(EmsConnection connection) {
        String version = null;
        try {
            EmsBean runtimeMXBean = connection.getBean(ManagementFactory.RUNTIME_MXBEAN_NAME);
            if (runtimeMXBean != null) {
                EmsAttribute systemPropertiesAttribute = runtimeMXBean.getAttribute("systemProperties");
                TabularData systemProperties = (TabularData) systemPropertiesAttribute.getValue();
                CompositeData compositeData = systemProperties.get(new String[]{"java.version"});
                if (compositeData != null) {
                    version = (String) compositeData.get("value");
                }
View Full Code Here

            String beanName = name.substring(0, name.lastIndexOf(':'));
            String attributeName = name.substring(name.lastIndexOf(':') + 1);

            try {
                // Bean is cached by EMS, so no problem with getting the bean from the connection on each call
                EmsBean eBean = loadBean(beanName);
                if (eBean == null) {
                    log.warn("Bean " + beanName + " not found, skipping ...");
                    continue;
                }

                EmsAttribute attribute = eBean.getAttribute(attributeName);
                Object valueObject = attribute.refresh();
               
                if (valueObject != null) {
                    if (request.getDataType() == DataType.TRAIT) {
                        report.addData(new MeasurementDataTrait(request, valueObject.toString()));
View Full Code Here

TOP

Related Classes of org.mc4j.ems.connection.bean.EmsBean

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.