Package org.mc4j.ems.connection.bean.attribute

Examples of org.mc4j.ems.connection.bean.attribute.EmsAttribute


        report.setStatus(ConfigurationUpdateStatus.SUCCESS);

        for (String key : report.getConfiguration().getSimpleProperties().keySet()) {
            PropertySimple property = report.getConfiguration().getSimple(key);
            if (property != null) {
                EmsAttribute attribute = this.bean.getAttribute(key);
                try {
                    PropertyDefinitionSimple def = configurationDefinition.getPropertyDefinitionSimple(property
                        .getName());
                    if (!(ignoreReadOnly && def.isReadOnly())) {
                        switch (def.getType()) {
                        case INTEGER: {
                            attribute.setValue(property.getIntegerValue());
                            break;
                        }

                        case LONG: {
                            attribute.setValue(property.getLongValue());
                            break;
                        }

                        case BOOLEAN: {
                            attribute.setValue(property.getBooleanValue());
                            break;
                        }

                        case FLOAT: {
                            attribute.setValue(property.getFloatValue());
                            break;
                        }

                        case DOUBLE: {
                            attribute.setValue(property.getDoubleValue());
                            break;
                        }

                        default: {
                            attribute.setValue(property.getStringValue());
                            break;
                        }
                        }
                    }
                } catch (Exception e) {
View Full Code Here


        try {
            String baseName = getBaseName(context.getSystemInformation());

            if (baseName != null) {
                EmsAttribute attrib = context.getParentResourceComponent().getAgentBean().getAttribute("Version");
                attrib.refresh();
                String version;
                if (attrib.getValue() != null) {
                    version = attrib.getValue().toString();
                } else {
                    version = Version.getProductVersion(); // just use the one we can get statically, its probably the correct version
                }

                // we know our agent plugin is running in the same process as our agent
View Full Code Here

     */
    private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version,
        String baseName, HashSet<DiscoveredResourceDetails> discoveries) {

        try {
            EmsAttribute home = context.getParentResourceComponent().getAgentBean().getAttribute("AgentHomeDirectory");
            home.refresh();
            Object agentHome = home.getValue();
            if (agentHome != null) {
                File file = new File(agentHome.toString(), baseName);
                if (file.exists()) {
                    discoveries.add(createDetails(context, version, file));
                }
View Full Code Here

    }

    private static String getSystemProperty(EmsBean runtimeMBean, String propertyName) throws Exception {
        // We must use reflection for the Open MBean classes (TabularData and CompositeData) to avoid
        // ClassCastExceptions due to EMS having used a different classloader than us to load them.
        EmsAttribute systemPropertiesAttribute = runtimeMBean.getAttribute("systemProperties");
        Object tabularDataObj = systemPropertiesAttribute.refresh();
        Method getMethod = tabularDataObj.getClass().getMethod("get",
            new Class[] { Class.forName("[Ljava.lang.Object;") });
        // varargs don't work out when the arg itself is an array, so specify the parameters explicitly using arrays.
        Object compositeDataObj = getMethod.invoke(tabularDataObj, new Object[] { new Object[] { propertyName } });
        getMethod = compositeDataObj.getClass().getMethod("get", String.class);
View Full Code Here

                    + "] - it can be enabled in the Resource's Inventory > Connection tab.");
                return null;
            }
        }

        EmsAttribute namesAttribute = getEmsBean().getAttribute("LoggerNames");

        String[] names = (String[]) namesAttribute.refresh();

        //There should only be 50 elements (checked against jmx-console, but it is returning 51 the first element is blank
        //so I put code in the for loop to not add if the name is blank
        Arrays.sort(names);
View Full Code Here

            //            name = getAttributeName(name);

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

            try {
                EmsAttribute attribute = getEmsBean().getAttribute(attributeName);

                Object valueObject = attribute.refresh();

                if (attributeName.equals("aliases")) {
                    String[] vals = (String[]) valueObject;
                    MeasurementDataTrait mdt = new MeasurementDataTrait(request, Arrays.toString(vals));
                    report.addData(mdt);
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

                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()));
                  } else { // numeric
View Full Code Here

      for (MeasurementDefinition metricDefinition : metricDefinitions) {

        String compValue = TestHelper.getMetricValue(metricDefinition,
            measurementFacet);
        EmsAttribute atr = relatedBean.getAttribute(metricDefinition
            .getName());
        log.info("            Validating Metric "
            + metricDefinition.getName() + ". (plugin value=" +compValue + ", bean value=" + atr.getValue() + ")");
        String beanValue = String.valueOf(atr.getValue());

        assert (TestHelper.compareValues(compValue, atr.getType(), atr
            .getValue()));
      }
    }
  }
View Full Code Here

    return operation.getReturnType();
  }

  protected Object getEmsAttribute(String beanName, String attName) {
    EmsBean bean = connection.getBean(beanName);
    EmsAttribute att = bean.getAttribute(attName);

    Object obj = att.getValue();
    return obj;
  }
View Full Code Here

TOP

Related Classes of org.mc4j.ems.connection.bean.attribute.EmsAttribute

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.