Java 类javax.management.MBeanAttributeInfo 实例源码

项目:lazycat    文件:Registry.java   
/**
 * Get the type of an attribute of the object, from the metadata.
 *
 * @param oname
 * @param attName
 * @return null if metadata about the attribute is not found
 * @since 1.1
 */
public String getType(ObjectName oname, String attName) {
    String type = null;
    MBeanInfo info = null;
    try {
        info = server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info("Can't find metadata for object" + oname);
        return null;
    }

    MBeanAttributeInfo attInfo[] = info.getAttributes();
    for (int i = 0; i < attInfo.length; i++) {
        if (attName.equals(attInfo[i].getName())) {
            type = attInfo[i].getType();
            return type;
        }
    }
    return null;
}
项目:phone-simulator    文件:TestCheckImeiServerStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {

            new MBeanAttributeInfo("AutoEquipmentStatus", EquipmentStatusType.class.getName(), "EquipmentStatus parameter to be automatically send in CheckImeiResponse", true, true, false),
            new MBeanAttributeInfo("AutoEquipmentStatus_Value", String.class.getName(), "EquipmentStatus parameter to be automatically send in CheckImeiResponse", true, false, false),
            new MBeanAttributeInfo("OneNotificationFor100Dialogs", boolean.class.getName(),
                    "If true there will be only one notification per every 100 sent dialogs", true, true, true),
            new MBeanAttributeInfo("CurrentRequestDef", String.class.getName(), "Definition of the current request Dialog",
                    true, false, false),

    };

    MBeanParameterInfo[] putAutoEquipmentStatusParam = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(), "EquipmentStatus value") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo(
                    "putAutoEquipmentStatus",
                    "EquipmentStatus parameter to be automatically send in CheckImeiResponse: "
                            + "0:whiteListed,1:blackListed,2:greyListed",
                    putAutoEquipmentStatusParam, Void.TYPE.getName(), MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("closeCurrentDialog", "Closing the current dialog", null, String.class.getName(), MBeanOperationInfo.ACTION)
    };
    return new MBeanInfo(TestCheckImeiServerMan.class.getName(), "CheckImeiServer test parameters management", attributes, null, operations, null);
}
项目:phone-simulator    文件:TestMapLcsServerStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            new MBeanAttributeInfo("NetworkNodeNumberAddress", String.class.getName(),
                                   "NetworkNodeNumber address parameter for response",
                                   true, true, false), };

    MBeanParameterInfo[] performSRIResponseParam = new MBeanParameterInfo[] { };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performSendRoutingInfoForLCSResponse", "Send Routing Information for LCS response",
                                   performSRIResponseParam, String.class.getName(), MBeanOperationInfo.ACTION),
             };

    return new MBeanInfo(TestMapLcsServerMan.class.getName(), "MapLcsServer test parameters management", attributes, null, operations, null);
}
项目:phone-simulator    文件:TestMapLcsClientStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    // TODO: Put real attributes and operations

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            new MBeanAttributeInfo("AddressNature", AddressNatureType.class.getName(),
                                   "AddressNature parameter for mlcNumber creating",
                                   true, true, false),
            new MBeanAttributeInfo("NumberingPlanType", NumberingPlanMapType.class.getName(),
                                   "NumberingPlanType parameter for mlcNumber creating",
                                   true, true, false),
            new MBeanAttributeInfo("NumberingPlan", String.class.getName(),
                                   "NumberingPlan parameter for mlcNumber creating",
                                   true, true, false), };

    MBeanParameterInfo[] performSRIRequestParam = new MBeanParameterInfo[] {
                   new MBeanParameterInfo("addressIMSI", String.class.getName(), "Address for IMSI") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performSendRoutingInfoForLCSRequest", "Send Routing Information for LCS request",
                                   performSRIRequestParam, String.class.getName(), MBeanOperationInfo.ACTION),
             };

    return new MBeanInfo(TestMapLcsClientMan.class.getName(), "MapLcsClient test parameters management", attributes, null, operations, null);
}
项目:hadoop-oss    文件:MBeanInfoBuilder.java   
MBeanInfo get() {
  curRecNo = 0;
  for (MetricsRecordImpl rec : recs) {
    for (MetricsTag t : rec.tags()) {
      attrs.add(newAttrInfo("tag."+ t.name(), t.description(),
                "java.lang.String"));
    }
    for (AbstractMetric m : rec.metrics()) {
      m.visit(this);
    }
    ++curRecNo;
  }
  MetricsSystemImpl.LOG.debug(attrs);
  MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()];
  return new MBeanInfo(name, description, attrs.toArray(attrsArray),
                       null, null, null); // no ops/ctors/notifications
}
项目:eZooKeeper    文件:MBeanAttributeDoc.java   
@Override
public String getName() {
    if (_Name == null) {

        _Name = super.getName();

        if (_Name == null) {
            return _Name;
        }

        MBeanAttributeInfo info = getInfo();
        String prefix = NAME_PREFIX_GET;
        if (info.isIs()) {
            prefix = NAME_PREFIX_IS;
        }

        _Name = prefix + _Name;
    }

    return _Name;
}
项目:eZooKeeper    文件:MBeanDoc.java   
public List<MBeanAttributeDoc> getAttributes() {

        if (_Attributes == null) {
            MBeanAttributeInfo[] attributeInfos = getInfo().getAttributes();

            if (attributeInfos == null || attributeInfos.length == 0) {
                return Collections.emptyList();
            }

            _Attributes = new ArrayList<MBeanAttributeDoc>(attributeInfos.length);

            for (MBeanAttributeInfo attributeInfo : attributeInfos) {
                MBeanAttributeDoc attributeDoc = new MBeanAttributeDoc(attributeInfo);
                _Attributes.add(attributeDoc);
            }
        }

        return _Attributes;
    }
项目:truevfs    文件:JmxBufferView.java   
@Override
protected String getDescription(final MBeanAttributeInfo info) {
    switch (info.getName()) {
    case "Name":
        return "The name of this buffer.";
    case "SizeOfData":
        return "The data size of this buffer.";
    case "SizeOfStorage":
        return "The storage size of this buffer.";
    case "TimeCreatedDate":
        return "The time this buffer has been created.";
    case "TimeCreatedMillis":
        return "The time this buffer has been created in milliseconds.";
    case "TimeReadDate":
        return "The last time this buffer has been read or accessed.";
    case "TimeReadMillis":
        return "The last time this buffer has been read or accessed in milliseconds.";
    case "TimeWrittenDate":
        return "The last time this buffer has been written.";
    case "TimeWrittenMillis":
        return "The last time this buffer has been written in milliseconds.";
    default:
        return null;
    }
}
项目:tomcat7    文件:Registry.java   
/** Get the type of an attribute of the object, from the metadata.
 *
 * @param oname
 * @param attName
 * @return null if metadata about the attribute is not found
 * @since 1.1
 */
public String getType( ObjectName oname, String attName )
{
    String type=null;
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata for object" + oname );
        return null;
    }

    MBeanAttributeInfo attInfo[]=info.getAttributes();
    for( int i=0; i<attInfo.length; i++ ) {
        if( attName.equals(attInfo[i].getName())) {
            type=attInfo[i].getType();
            return type;
        }
    }
    return null;
}
项目:monarch    文件:MX4JModelMBean.java   
public void addAttributeChangeNotificationListener(NotificationListener listener,
    String attributeName, Object handback)
    throws MBeanException, RuntimeOperationsException, IllegalArgumentException {
  if (listener == null)
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
  AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
  if (attributeName != null) {
    filter.enableAttribute(attributeName);
  } else {
    MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
    for (int i = 0; i < ai.length; i++) {
      Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor();
      filter.enableAttribute((String) d.getFieldValue("name"));
    }
  }

  getAttributeChangeBroadcaster().addNotificationListener(listener, filter, handback);

  Logger logger = getLogger();
  if (logger.isEnabledFor(Logger.DEBUG))
    logger.debug("Listener " + listener + " for attribute " + attributeName
        + " added successfully, handback is " + handback);
}
项目:monarch    文件:MX4JModelMBean.java   
private void removeAttributeChangeNotificationListener(NotificationListener listener,
    String attributeName, Object handback)
    throws MBeanException, RuntimeOperationsException, ListenerNotFoundException {
  if (listener == null)
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_LISTENER_CANNOT_BE_NULL.toLocalizedString()));
  AttributeChangeNotificationFilter filter = new AttributeChangeNotificationFilter();
  if (attributeName != null) {
    filter.enableAttribute(attributeName);
  } else {
    MBeanAttributeInfo[] ai = m_modelMBeanInfo.getAttributes();
    for (int i = 0; i < ai.length; i++) {
      Descriptor d = ((ModelMBeanAttributeInfo) ai[i]).getDescriptor();
      filter.enableAttribute((String) d.getFieldValue("name"));
    }
  }

  getAttributeChangeBroadcaster().removeNotificationListener(listener, filter, handback);

  Logger logger = getLogger();
  if (logger.isEnabledFor(Logger.DEBUG))
    logger.debug("Listener " + listener + " for attribute " + attributeName
        + " removed successfully, handback is " + handback);
}
项目:apache-tomcat-7.0.73-with-comment    文件:Registry.java   
/** Get the type of an attribute of the object, from the metadata.
 *
 * @param oname
 * @param attName
 * @return null if metadata about the attribute is not found
 * @since 1.1
 */
public String getType( ObjectName oname, String attName )
{
    String type=null;
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata for object" + oname );
        return null;
    }

    MBeanAttributeInfo attInfo[]=info.getAttributes();
    for( int i=0; i<attInfo.length; i++ ) {
        if( attName.equals(attInfo[i].getName())) {
            type=attInfo[i].getType();
            return type;
        }
    }
    return null;
}
项目:hadoop    文件:JMXGet.java   
/**
 * print all attributes' values
 */
public void printAllValues() throws Exception {
  err("List of all the available keys:");

  Object val = null;

  for (ObjectName oname : hadoopObjectNames) {
    err(">>>>>>>>jmx name: " + oname.getCanonicalKeyPropertyListString());
    MBeanInfo mbinfo = mbsc.getMBeanInfo(oname);
    MBeanAttributeInfo[] mbinfos = mbinfo.getAttributes();

    for (MBeanAttributeInfo mb : mbinfos) {
      val = mbsc.getAttribute(oname, mb.getName());
      System.out.format(format, mb.getName(), (val==null)?"":val.toString());
    }
  }
}
项目:hadoop    文件:JMXGet.java   
public void printAllMatchedAttributes(String attrRegExp) throws Exception {
  err("List of the keys matching " + attrRegExp + " :");
  Object val = null;
  Pattern p = Pattern.compile(attrRegExp);
  for (ObjectName oname : hadoopObjectNames) {
    err(">>>>>>>>jmx name: " + oname.getCanonicalKeyPropertyListString());
    MBeanInfo mbinfo = mbsc.getMBeanInfo(oname);
    MBeanAttributeInfo[] mbinfos = mbinfo.getAttributes();
    for (MBeanAttributeInfo mb : mbinfos) {
      if (p.matcher(mb.getName()).lookingAt()) {
        val = mbsc.getAttribute(oname, mb.getName());
        System.out.format(format, mb.getName(), (val == null) ? "" : val.toString());
      }
    }
  }
}
项目:openjdk-jdk10    文件:MXBeanInteropTest2.java   
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
项目:hadoop    文件:MBeanInfoBuilder.java   
MBeanInfo get() {
  curRecNo = 0;
  for (MetricsRecordImpl rec : recs) {
    for (MetricsTag t : rec.tags()) {
      attrs.add(newAttrInfo("tag."+ t.name(), t.description(),
                "java.lang.String"));
    }
    for (AbstractMetric m : rec.metrics()) {
      m.visit(this);
    }
    ++curRecNo;
  }
  MetricsSystemImpl.LOG.debug(attrs);
  MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()];
  return new MBeanInfo(name, description, attrs.toArray(attrsArray),
                       null, null, null); // no ops/ctors/notifications
}
项目:doctorkafka    文件:MetricsFetcher.java   
private static void fetchKafkaMetrics(String host, String jmxPort, String metric)
    throws Exception {

  Map<String, String[]> env = new HashMap<>();
  JMXServiceURL address = new JMXServiceURL(
      "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + jmxPort + "/jmxrmi");
  JMXConnector connector = JMXConnectorFactory.connect(address, env);
  MBeanServerConnection mbs = connector.getMBeanServerConnection();


  ObjectName name = ObjectName.getInstance(metric);
  MBeanInfo beanInfo = mbs.getMBeanInfo(name);
  for (MBeanAttributeInfo attributeInfo : beanInfo.getAttributes()) {
    Object obj = mbs.getAttribute(name, attributeInfo.getName());
    System.out.println(" attributeName = " + attributeInfo.getName() + " " + obj.toString());
  }
}
项目:jdk8u-jdk    文件:MustBeValidCommand.java   
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
项目:jdk8u-jdk    文件:MXBeanInteropTest2.java   
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
项目:metrics-tomcat    文件:AnnotatedStandardMBean.java   
/** {@inheritDoc} */
@Override
protected String getDescription(final MBeanAttributeInfo info) {
    String descr = info.getDescription();
    Method m = getMethod(getMBeanInterface(),
            "get" + info.getName().substring(0, 1).toUpperCase() + info.getName().substring(1));
    if (m == null) {
        m = getMethod(getMBeanInterface(),
                "is" + info.getName().substring(0, 1).toUpperCase() + info.getName().substring(1));
    }
    if (m == null) {
        m = getMethod(getMBeanInterface(),
                "does" + info.getName().substring(0, 1).toUpperCase() + info.getName().substring(1));
    }
    if (m != null) {
        Description d = m.getAnnotation(Description.class);
        if (d != null) {
            descr = d.value();
        }
    }
    return descr;
}
项目:openjdk-jdk10    文件:AnnotationTest.java   
private static void check(MBeanServer mbs, ObjectName on) throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);

    // check the MBean itself
    check(mbi);

    // check attributes
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    for (MBeanAttributeInfo attr : attrs) {
        check(attr);
        if (attr.getName().equals("ReadOnly"))
            check("@Full", attr.getDescriptor(), expectedFullDescriptor);
    }

    // check operations
    MBeanOperationInfo[] ops = mbi.getOperations();
    for (MBeanOperationInfo op : ops) {
        check(op);
        check(op.getSignature());
    }

    MBeanConstructorInfo[] constrs = mbi.getConstructors();
    for (MBeanConstructorInfo constr : constrs) {
        check(constr);
        check(constr.getSignature());
    }
}
项目:phone-simulator    文件:TestCheckImeiClientStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            // TODO mnowa: add/correct attributes here
            new MBeanAttributeInfo("Imei", String.class.getName(), "IMEI's digits string", true, true, false),
            new MBeanAttributeInfo("MapProtocolVersion", MapProtocolVersion.class.getName(), "MAP protocol version", true, true, false),
            new MBeanAttributeInfo("MapProtocolVersion_Value", String.class.getName(), "MAP protocol version", true, false, false),
            new MBeanAttributeInfo(
                    "CheckImeiClientAction",
                    CheckImeiClientAction.class.getName(),
                    "The mode of CheckImeiClient work. When manual response user can manually send CheckImei request, when VAL_AUTO_SendCheckImeiRequest the tester sends CheckImei requests without dealay (load test)",
                    true, true, false),
            new MBeanAttributeInfo(
                    "CheckImeiClientAction_Value",
                    String.class.getName(),
                    "The mode of CheckImeiClient work. When manual response user can manually send CheckImei request, when VAL_AUTO_SendCheckImeiRequest the tester sends CheckImei requests without dealay (load test)",
                    true, false, false),
            new MBeanAttributeInfo("MaxConcurrentDialogs", int.class.getName(), "The count of maximum active MAP dialogs when the auto sending mode", true,
                    true, false),
            new MBeanAttributeInfo("OneNotificationFor100Dialogs", boolean.class.getName(),
                    "If true there will be only one notification per every 100 sent dialogs (recommended for the auto sending mode)", true, true, true),

    };

    MBeanParameterInfo[] performCheckImeiParam = new MBeanParameterInfo[] { new MBeanParameterInfo("imei", String.class.getName(), "IMEI's digits string")};
    MBeanParameterInfo[] signString = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(), "Index number or value") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performCheckImeiRequest", "Send CheckIMEI request for provided IMEI", performCheckImeiParam/*signString*/ , String.class.getName(), MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("putMapProtocolVersion", "MAP protocol version: " + "1, 2 or 3", signString, Void.TYPE.getName(),
                    MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("closeCurrentDialog", "Closing the current dialog", null, String.class.getName(), MBeanOperationInfo.ACTION),

            new MBeanOperationInfo("putCheckImeiClientAction",
                    "The mode of CheckImeiClient work. 1:VAL_MANUAL_OPERATION,2:VAL_AUTO_SendCheckImeiRequest", signString, Void.TYPE.getName(),
                    MBeanOperationInfo.ACTION),
    };
    return new MBeanInfo(TestCheckImeiClientMan.class.getName(), "CheckImeiClient test parameters management", attributes, null, operations, null);
}
项目:Pogamut3    文件:DynamicMBeanToFolderAdapter.java   
@Override
protected Property[] computeProperties(DynamicProxy object) {
    MBeanInfo nfo = object.getMBeanInfo();
    MBeanAttributeInfo[] attrs = nfo.getAttributes();
    List<Property> props = new ArrayList<Property>();
    for (MBeanAttributeInfo attr : attrs) {
        props.add(new AttributeToPropertyAdapter(attr, object));
    }
    return props.toArray(new Property[0]);
}
项目:openjdk-jdk10    文件:MustBeValidCommand.java   
static private MBeanAttributeInfo[] makeAttInfos(String[][] spec) {
    final MBeanAttributeInfo[] result =
        new MBeanAttributeInfo[spec.length];
    for (int i=0;i<result.length;i++) {
        System.out.println("\tCreate an MBeanAttributeInfo: " +
                           spec[i][0]);
        final MBeanAttributeInfo item =
            new MBeanAttributeInfo(spec[i][2],spec[i][1],spec[i][0],
                                   true,true,false);
        result[i]=item;
    }
    return result;
}
项目:hadoop-oss    文件:TestMetricsSourceAdapter.java   
@Override
public void run() {
  try {
    // This will trigger updateJmxCache().
    MBeanInfo info = sa.getMBeanInfo();
    final String key = src.getKey();
    for (MBeanAttributeInfo mBeanAttributeInfo : info.getAttributes()) {
      // Found the new key, update the metric source and move on.
      if (mBeanAttributeInfo.getName().equals(key)) {
        LOG.info("found key/val=" + cnt + "/" + cnt);
        cnt++;
        src.setKV("key" + cnt, cnt);
        return;
      }
    }
    LOG.error("key=" + key + " not found. Stopping now.");
    hasError.set(true);
  } catch (Exception e) {
    // catch other errors
    hasError.set(true);
    LOG.error(e.getStackTrace());
  } finally {
    if (hasError.get()) {
      future.cancel(false);
    }
  }
}
项目:eZooKeeper    文件:JmxConnection.java   
public MBeanAttribute getMBeanAttribute(MBean mbean, String attributeName) {

        if (mbean == null) {
            throw new IllegalArgumentException("null MBean");
        }

        if (attributeName == null) {
            throw new IllegalArgumentException("null attributeName");
        }

        // TODO: Handle connection errors and try to reconnect.

        MBeanAttributeInfo attributeInfo = mbean.getAttributeInfo(attributeName);
        MBeanAttribute mbeanAttribute = new MBeanAttribute(attributeName);
        mbeanAttribute.setInfo(attributeInfo);

        Object value = null;

        try {
            value = _MBeanServerConnection.getAttribute(mbean.getObjectName(), attributeName);
        }
        catch (Throwable t) {
            String errorMessage = t.getLocalizedMessage();
            mbeanAttribute.setValueRetrievalErrorMessage(errorMessage);
        }

        mbeanAttribute.setValue(value);
        return mbeanAttribute;
    }
项目:eZooKeeper    文件:MBean.java   
/**
 * TODO: Comment.
 * 
 * @param attributeName
 * @return
 */
public MBeanAttributeInfo getAttributeInfo(String attributeName) {
    if (_AttributeInfoMap == null) {
        initAttributeCollections();
    }
    return _AttributeInfoMap.get(attributeName);
}
项目:lazycat    文件:JMXAccessorSetTask.java   
/**
 * Get MBean Attribute from Mbean Server
 * 
 * @param jmxServerConnection
 * @param name
 * @param attribute
 * @return The type
 * @throws Exception
 */
protected String getMBeanAttributeType(MBeanServerConnection jmxServerConnection, String name, String attribute)
        throws Exception {
    ObjectName oname = new ObjectName(name);
    String mattrType = null;
    MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
    MBeanAttributeInfo attrs[] = minfo.getAttributes();
    for (int i = 0; mattrType == null && i < attrs.length; i++) {
        if (attribute.equals(attrs[i].getName()))
            mattrType = attrs[i].getType();
    }
    return mattrType;
}
项目:openjdk-jdk10    文件:ModelMBeanInfoSupport.java   
/**
 * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
 */
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
    if (compat) {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
        modelMBeanDescriptor =
                (Descriptor) fields.get("modelMBeanDescriptor", null);
        if (fields.defaulted("modelMBeanDescriptor")) {
            throw new NullPointerException("modelMBeanDescriptor");
        }
        modelMBeanAttributes =
                (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
        if (fields.defaulted("mmbAttributes")) {
            throw new NullPointerException("mmbAttributes");
        }
        modelMBeanConstructors =
                (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
        if (fields.defaulted("mmbConstructors")) {
            throw new NullPointerException("mmbConstructors");
        }
        modelMBeanNotifications =
                (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
        if (fields.defaulted("mmbNotifications")) {
            throw new NullPointerException("mmbNotifications");
        }
        modelMBeanOperations =
                (MBeanOperationInfo[]) fields.get("mmbOperations", null);
        if (fields.defaulted("mmbOperations")) {
            throw new NullPointerException("mmbOperations");
        }
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
    }
}
项目:eZooKeeper    文件:MBeanAttributeModelElementType.java   
@Override
public String getColumnText(Object element, int columnIndex) {

    // 0:Name | 1:Value | 2:Type | 3:Description

    MBeanAttributeModel model = (MBeanAttributeModel) element;
    MBeanAttribute mbeanAttribute = model.getData();
    MBeanAttributeInfo info = mbeanAttribute.getInfo();
    switch (columnIndex) {

    case 0:
        return mbeanAttribute.getName();

    case 1:

        String valueError = mbeanAttribute.getValueRetrievalErrorMessage();
        if (valueError != null) {
            return valueError;
        }
        else {
            return mbeanAttribute.getValueAsString();
        }

    case 2:
        return info.getType();

    case 3:
        return info.getDescription();

    }

    return null;
}
项目:alfresco-repository    文件:JmxDumpUtil.java   
/**
 * Dumps the details of a single MBean.
 * 
 * @param connection
 *            the server connection (or server itself)
 * @param objectName
 *            the object name
 * @param out
 *            PrintWriter to write the output to
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws JMException
 *             Signals a JMX error
 */
private static void printMBeanInfo(MBeanServerConnection connection, ObjectName objectName, PrintWriter out)
        throws IOException, JMException
{
    Map<String, Object> attributes = new TreeMap<String, Object>();
    MBeanInfo info = connection.getMBeanInfo(objectName);
    attributes.put("** Object Name", objectName.toString());
    attributes.put("** Object Type", info.getClassName());
    for (MBeanAttributeInfo element : info.getAttributes())
    {
        Object value;
        if (element.isReadable())
        {
            try
            {
                value = connection.getAttribute(objectName, element.getName());
            }
            catch (Exception e)
            {
                value = JmxDumpUtil.PROTECTED_VALUE;
            }
        }
        else
        {
            value = JmxDumpUtil.PROTECTED_VALUE;
        }
        attributes.put(element.getName(), value);
    }
    if (objectName.getCanonicalName().equals("Alfresco:Name=SystemProperties"))
    {
        String osName = (String) attributes.get(OS_NAME);
        if (osName != null && osName.toLowerCase().startsWith("linux"))
        {
            attributes.put(OS_NAME, updateOSNameAttributeForLinux(osName));
        }
    }
    tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, 0);
}
项目:truevfs    文件:JmxManagerView.java   
@Override
protected String getDescription(final MBeanAttributeInfo info) {
    switch (info.getName()) {
    case "FileSystemsMounted":
        return "The number of file systems which have been mounted.";
    case "FileSystemsTotal":
        return "The total number of file systems.";
    case "TopLevelArchiveFileSystemsMounted":
        return "The number of top level archive file systems which have been mounted.";
    case "TopLevelArchiveFileSystemsTotal":
        return "The total number of top level archive file systems.";
    default:
        return null;
    }
}
项目:truevfs    文件:JmxModelView.java   
@Override
protected String getDescription(final MBeanAttributeInfo info) {
    switch (info.getName()) {
    case "Mounted":
        return "Whether or not this file system is mounted.";
    case "MountPoint":
        return "The mount point URI of this file system.";
    case "MountPointOfParent":
        return "The mount point URI of the parent file system.";
    case "SizeOfData":
        return "The data size of this file system.";
    case "SizeOfStorage":
        return "The storage size of this file system.";
    case "TimeCreatedDate":
        return "The time this file system has been created.";
    case "TimeCreatedMillis":
        return "The time this file system has been created in milliseconds.";
    case "TimeReadDate":
        return "The last time this file system has been read or accessed.";
    case "TimeReadMillis":
        return "The last time this file system has been read or accessed in milliseconds.";
    case "TimeWrittenDate":
        return "The last time this file system has been written.";
    case "TimeWrittenMillis":
        return "The last time this file system has been written in milliseconds.";
    default:
        return null;
    }
}
项目:tomcat7    文件:JMXAccessorSetTask.java   
/**
 * Get MBean Attribute from Mbean Server
 * @param jmxServerConnection
 * @param name
 * @param attribute
 * @return The type
 * @throws Exception
 */
protected String getMBeanAttributeType(
        MBeanServerConnection jmxServerConnection,
        String name,
        String attribute) throws Exception {
    ObjectName oname = new ObjectName(name);
    String mattrType = null;
    MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
    MBeanAttributeInfo attrs[] = minfo.getAttributes();
    for (int i = 0; mattrType == null && i < attrs.length; i++) {
        if (attribute.equals(attrs[i].getName()))
            mattrType = attrs[i].getType();
    }
    return mattrType;
}
项目:flume-release-1.7.0    文件:JMXPollUtil.java   
public static Map<String, Map<String, String>> getAllMBeans() {
  Map<String, Map<String, String>> mbeanMap = Maps.newHashMap();
  Set<ObjectInstance> queryMBeans = null;
  try {
    queryMBeans = mbeanServer.queryMBeans(null, null);
  } catch (Exception ex) {
    LOG.error("Could not get Mbeans for monitoring", ex);
    Throwables.propagate(ex);
  }
  for (ObjectInstance obj : queryMBeans) {
    try {
      if (!obj.getObjectName().toString().startsWith("org.apache.flume")) {
        continue;
      }
      MBeanAttributeInfo[] attrs = mbeanServer.getMBeanInfo(obj.getObjectName()).getAttributes();
      String[] strAtts = new String[attrs.length];
      for (int i = 0; i < strAtts.length; i++) {
        strAtts[i] = attrs[i].getName();
      }
      AttributeList attrList = mbeanServer.getAttributes(obj.getObjectName(), strAtts);
      String component = obj.getObjectName().toString().substring(
          obj.getObjectName().toString().indexOf('=') + 1);
      Map<String, String> attrMap = Maps.newHashMap();

      for (Object attr : attrList) {
        Attribute localAttr = (Attribute) attr;
        if (localAttr.getName().equalsIgnoreCase("type")) {
          component = localAttr.getValue() + "." + component;
        }
        attrMap.put(localAttr.getName(), localAttr.getValue().toString());
      }
      mbeanMap.put(component, attrMap);
    } catch (Exception e) {
      LOG.error("Unable to poll JMX for metrics.", e);
    }
  }
  return mbeanMap;
}
项目:lams    文件:MBeanClientInterceptor.java   
private Object invokeAttribute(PropertyDescriptor pd, MethodInvocation invocation)
        throws JMException, IOException {

    String attributeName = JmxUtils.getAttributeName(pd, this.useStrictCasing);
    MBeanAttributeInfo inf = this.allowedAttributes.get(attributeName);
    // If no attribute is returned, we know that it is not defined in the
    // management interface.
    if (inf == null) {
        throw new InvalidInvocationException(
                "Attribute '" + pd.getName() + "' is not exposed on the management interface");
    }
    if (invocation.getMethod().equals(pd.getReadMethod())) {
        if (inf.isReadable()) {
            return this.serverToUse.getAttribute(this.objectName, attributeName);
        }
        else {
            throw new InvalidInvocationException("Attribute '" + attributeName + "' is not readable");
        }
    }
    else if (invocation.getMethod().equals(pd.getWriteMethod())) {
        if (inf.isWritable()) {
            this.serverToUse.setAttribute(this.objectName, new Attribute(attributeName, invocation.getArguments()[0]));
            return null;
        }
        else {
            throw new InvalidInvocationException("Attribute '" + attributeName + "' is not writable");
        }
    }
    else {
        throw new IllegalStateException(
                "Method [" + invocation.getMethod() + "] is neither a bean property getter nor a setter");
    }
}
项目:lams    文件:JMXAccessorSetTask.java   
/**
 * Get MBean Attriute from Mbean Server
 * @param jmxServerConnection
 * @param name
 * @param attribute
 * @return The type
 * @throws Exception
 */
protected String getMBeanAttributeType(
        MBeanServerConnection jmxServerConnection,
        String name,
        String attribute) throws Exception {
    ObjectName oname = new ObjectName(name);
    String mattrType = null;
    MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
    MBeanAttributeInfo attrs[] = minfo.getAttributes();
    if (attrs != null) {
        for (int i = 0; mattrType == null && i < attrs.length; i++) {
            if (attribute.equals(attrs[i].getName()))
                mattrType = attrs[i].getType();
        }
    }
    return mattrType;
}
项目:hashsdn-controller    文件:AbstractDynamicWrapper.java   
private static MBeanInfo generateMBeanInfo(final Module module,
        final Map<String, AttributeHolder> attributeHolderMap, final MBeanOperationInfo[] operations,
        final Set<Class<?>> jmxInterfaces) {

    String description = findDescription(module.getClass(), jmxInterfaces);
    MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[0];
    List<MBeanAttributeInfo> attributes = new ArrayList<>(attributeHolderMap.size());
    for (AttributeHolder attributeHolder : attributeHolderMap.values()) {
        attributes.add(attributeHolder.toMBeanAttributeInfo());
    }
    return new MBeanInfo(module.getClass().getName(), description, attributes.toArray(new MBeanAttributeInfo[0]),
            constructors, operations, new MBeanNotificationInfo[0]);
}
项目:OpenJSharp    文件:StandardMBeanIntrospector.java   
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
项目:OpenJSharp    文件:MBeanIntrospector.java   
public void visitAttribute(String attributeName,
        M getter,
        M setter) {
    MBeanAttributeInfo mbai =
            getMBeanAttributeInfo(attributeName, getter, setter);

    attrs.add(mbai);
}