當前位置: 首頁>>代碼示例>>Java>>正文


Java Descriptor類代碼示例

本文整理匯總了Java中javax.management.Descriptor的典型用法代碼示例。如果您正苦於以下問題:Java Descriptor類的具體用法?Java Descriptor怎麽用?Java Descriptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Descriptor類屬於javax.management包,在下文中一共展示了Descriptor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initDescriptorSectionFromModel

import javax.management.Descriptor; //導入依賴的package包/類
protected void initDescriptorSectionFromModel() {

        Descriptor descriptor = getJmxDescriptor();
        if (descriptor == null) {
            return;
        }

        Table table = getDescriptorTable();
        if (table == null) {
            return;
        }

        table.removeAll();

        for (String fieldName : descriptor.getFieldNames()) {
            TableItem item = new TableItem(table, SWT.NONE);
            Object value = descriptor.getFieldValue(fieldName);
            item.setText(0, fieldName);
            item.setText(1, String.valueOf(value));
        }

        packTable(table, DEFAULT_NAME_VALUE_COLUMN_WIDTHS);
    }
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:24,代碼來源:BaseJmxModelMainFormPage.java

示例2: populateMetricDescriptor

import javax.management.Descriptor; //導入依賴的package包/類
private void populateMetricDescriptor(Descriptor desc, ManagedMetric metric) {
	applyCurrencyTimeLimit(desc, metric.getCurrencyTimeLimit());

	if (StringUtils.hasLength(metric.getPersistPolicy())) {
		desc.setField(FIELD_PERSIST_POLICY, metric.getPersistPolicy());
	}
	if (metric.getPersistPeriod() >= 0) {
		desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(metric.getPersistPeriod()));
	}

	if (StringUtils.hasLength(metric.getDisplayName())) {
		desc.setField(FIELD_DISPLAY_NAME, metric.getDisplayName());
	}

	if(StringUtils.hasLength(metric.getUnit())) {
		desc.setField(FIELD_UNITS, metric.getUnit());
	}

	if(StringUtils.hasLength(metric.getCategory())) {
		desc.setField(FIELD_METRIC_CATEGORY, metric.getCategory());
	}

	String metricType = (metric.getMetricType() == null) ? MetricType.GAUGE.toString() : metric.getMetricType().toString();
	desc.setField(FIELD_METRIC_TYPE, metricType);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:MetadataMBeanInfoAssembler.java

示例3: makeGenericInfo

import javax.management.Descriptor; //導入依賴的package包/類
/**
 * Creates a default ModelMBeanNotificationInfo for GENERIC
 * notification.  (bug 4744667)
 **/
private static final ModelMBeanNotificationInfo makeGenericInfo() {
    final Descriptor genericDescriptor = new DescriptorSupport( new
        String[] {
            "name=GENERIC",
            "descriptorType=notification",
            "log=T",
            "severity=6",
            "displayName=jmx.modelmbean.generic"} );

    return new ModelMBeanNotificationInfo(new
        String[] {"jmx.modelmbean.generic"},
        "GENERIC",
        "A text notification has been issued by the managed resource",
        genericDescriptor);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:RequiredModelMBean.java

示例4: makeDescriptor

import javax.management.Descriptor; //導入依賴的package包/類
static <T> Descriptor makeDescriptor(OpenType<T> openType,
                                     T defaultValue,
                                     T[] legalValues,
                                     Comparable<T> minValue,
                                     Comparable<T> maxValue) {
    Map<String, Object> map = new HashMap<String, Object>();
    if (defaultValue != null)
        map.put("defaultValue", defaultValue);
    if (legalValues != null) {
        Set<T> set = new HashSet<T>();
        for (T v : legalValues)
            set.add(v);
        set = Collections.unmodifiableSet(set);
        map.put("legalValues", set);
    }
    if (minValue != null)
        map.put("minValue", minValue);
    if (maxValue != null)
        map.put("maxValue", maxValue);
    if (map.isEmpty()) {
        return openType.getDescriptor();
    } else {
        map.put("openType", openType);
        return new ImmutableDescriptor(map);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:OpenMBeanAttributeInfoSupport.java

示例5: getDescriptor

import javax.management.Descriptor; //導入依賴的package包/類
/**
 * Returns a copy of the associated Descriptor for the
 * ModelMBeanNotificationInfo.
 *
 * @return Descriptor associated with the
 * ModelMBeanNotificationInfo object.
 *
 * @see #setDescriptor
 **/
public Descriptor getDescriptor() {
    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
    }

    if (notificationDescriptor == null) {
        // Dead code. Should never happen.
        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
            MODELMBEAN_LOGGER.log(Level.TRACE,
                    "Descriptor value is null, " +
                    "setting descriptor to default values");
        }
        notificationDescriptor = validDescriptor(null);
    }

    return((Descriptor)notificationDescriptor.clone());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ModelMBeanNotificationInfo.java

示例6: getDescriptor

import javax.management.Descriptor; //導入依賴的package包/類
/**
 * Returns a copy of the associated Descriptor.
 *
 * @return Descriptor associated with the
 * ModelMBeanConstructorInfo object.
 *
 * @see #setDescriptor
 */


@Override
public Descriptor getDescriptor()
{
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanConstructorInfo.class.getName(),
                "getDescriptor()", "Entry");
    }
    if (consDescriptor == null){
        consDescriptor = validDescriptor(null);
    }
    return((Descriptor)consDescriptor.clone());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:ModelMBeanConstructorInfo.java

示例7: OpenMBeanParameterInfoSupport

import javax.management.Descriptor; //導入依賴的package包/類
private <T> OpenMBeanParameterInfoSupport(String name,
                                          String description,
                                          OpenType<T> openType,
                                          T defaultValue,
                                          T[] legalValues,
                                          Comparable<T> minValue,
                                          Comparable<T> maxValue)
        throws OpenDataException {
    super(name,
          (openType == null) ? null : openType.getClassName(),
          description,
          makeDescriptor(openType,
                         defaultValue, legalValues, minValue, maxValue));

    this.openType = openType;

    Descriptor d = getDescriptor();
    this.defaultValue = defaultValue;
    this.minValue = minValue;
    this.maxValue = maxValue;
    // We already converted the array into an unmodifiable Set
    // in the descriptor.
    this.legalValues = (Set<?>) d.getFieldValue("legalValues");

    check(this);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:OpenMBeanParameterInfoSupport.java

示例8: getMBeanDescriptorNoException

import javax.management.Descriptor; //導入依賴的package包/類
private Descriptor getMBeanDescriptorNoException() {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getMBeanDescriptorNoException()", "Entry");
    }

    if (modelMBeanDescriptor == null)
        modelMBeanDescriptor = validDescriptor(null);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getMBeanDescriptorNoException()",
                "Exit, returning: " + modelMBeanDescriptor);
    }
    return (Descriptor) modelMBeanDescriptor.clone();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ModelMBeanInfoSupport.java

示例9: makeAttributeChangeInfo

import javax.management.Descriptor; //導入依賴的package包/類
/**
 * Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE
 * notification.  (bug 4744667)
 **/
private static final
    ModelMBeanNotificationInfo makeAttributeChangeInfo() {
    final Descriptor attributeDescriptor = new DescriptorSupport(new
        String[] {
            "name=ATTRIBUTE_CHANGE",
            "descriptorType=notification",
            "log=T",
            "severity=6",
            "displayName=jmx.attribute.change"});

    return new ModelMBeanNotificationInfo(new
        String[] {"jmx.attribute.change"},
        "ATTRIBUTE_CHANGE",
        "Signifies that an observed MBean attribute value has changed",
        attributeDescriptor );
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:RequiredModelMBean.java

示例10: check

import javax.management.Descriptor; //導入依賴的package包/類
private static void check(Object x, Descriptor d, Descriptor expect) {
    String fail = null;
    try {
        Descriptor u = ImmutableDescriptor.union(d, expect);
        if (!u.equals(d))
            fail = "should contain " + expect + "; is " + d;
    } catch (IllegalArgumentException e) {
        fail = e.getMessage();
    }
    if (fail == null) {
        System.out.println("OK: " + x);
    } else {
        failed = "NOT OK: Incorrect descriptor for: " + x;
        System.out.println(failed);
        System.out.println("..." + fail);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:AnnotationTest.java

示例11: removeAttributeChangeNotificationListener

import javax.management.Descriptor; //導入依賴的package包/類
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);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:25,代碼來源:MX4JModelMBean.java

示例12: shouldPersistNow

import javax.management.Descriptor; //導入依賴的package包/類
private boolean shouldPersistNow(Descriptor attribute, Descriptor mbean, String lastUpdateField) {
  int persist = getPersistPolicy(attribute, mbean);
  if (persist == PERSIST_NO_MORE_OFTEN_THAN) {
    Long period = getFieldTimeValue(attribute, mbean, "persistPeriod");
    long now = System.currentTimeMillis();
    Long lastUpdate = (Long) attribute.getFieldValue(lastUpdateField);
    if (now - lastUpdate.longValue() < period.longValue())
      return false;
    else
      return true;
  } else if (persist == PERSIST_NEVER) {
    return false;
  } else if (persist == PERSIST_ON_TIMER) {
    return false;
  } else if (persist == PERSIST_ON_UPDATE) {
    return true;
  } else {
    throw new ImplementationException(
        LocalizedStrings.MX4JModelMBean_INVALID_PERSIST_VALUE.toLocalizedString());
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:MX4JModelMBean.java

示例13: test

import javax.management.Descriptor; //導入依賴的package包/類
private static boolean test(Object mbean, boolean expectImmutable)
        throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName on = new ObjectName("a:b=c");
    mbs.registerMBean(mbean, on);
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    Descriptor d = mbi.getDescriptor();
    String immutableValue = (String) d.getFieldValue("immutableInfo");
    boolean immutable = ("true".equals(immutableValue));
    if (immutable != expectImmutable) {
        System.out.println("FAILED: " + mbean.getClass().getName() +
                " -> " + immutableValue);
        return false;
    } else {
        System.out.println("OK: " + mbean.getClass().getName());
        return true;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:ImmutableNotificationInfoTest.java

示例14: createAttributeInfo

import javax.management.Descriptor; //導入依賴的package包/類
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
  Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
      "descriptorType=attribute", "currencyTimeLimit=-1", // always stale
      "displayName=" + this.displayName, "getMethod=getValue"});

  Assert.assertTrue(this.stat != null, "Stat target object is null!");
  desc.setField("targetObject", this.stat);

  ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
      this.type, // type
      this.description, // description
      this.readable, // isReadable
      this.writeable, // isWritable
      this.is, // isIs
      desc);

  return info;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:20,代碼來源:StatisticAttributeInfo.java

示例15: OpenMBeanAttributeInfoSupport

import javax.management.Descriptor; //導入依賴的package包/類
private <T> OpenMBeanAttributeInfoSupport(String name,
                                          String description,
                                          OpenType<T> openType,
                                          boolean isReadable,
                                          boolean isWritable,
                                          boolean isIs,
                                          T defaultValue,
                                          T[] legalValues,
                                          Comparable<T> minValue,
                                          Comparable<T> maxValue)
        throws OpenDataException {
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          makeDescriptor(openType,
                         defaultValue, legalValues, minValue, maxValue));

    this.openType = openType;

    Descriptor d = getDescriptor();
    this.defaultValue = defaultValue;
    this.minValue = minValue;
    this.maxValue = maxValue;
    // We already converted the array into an unmodifiable Set
    // in the descriptor.
    this.legalValues = (Set<?>) d.getFieldValue("legalValues");

    check(this);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:OpenMBeanAttributeInfoSupport.java


注:本文中的javax.management.Descriptor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。