/** * Apply the given JMX "currencyTimeLimit" value to the given descriptor. * <p>The default implementation sets a value {@code >0} as-is (as number of cache seconds), * turns a value of {@code 0} into {@code Integer.MAX_VALUE} ("always cache") * and sets the "defaultCurrencyTimeLimit" (if any, indicating "never cache") in case of * a value {@code <0}. This follows the recommendation in the JMX 1.2 specification. * @param desc the JMX attribute or operation descriptor * @param currencyTimeLimit the "currencyTimeLimit" value to apply * @see #setDefaultCurrencyTimeLimit(Integer) * @see #applyDefaultCurrencyTimeLimit(javax.management.Descriptor) */ protected void applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit) { if (currencyTimeLimit > 0) { // number of cache seconds desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(currencyTimeLimit)); } else if (currencyTimeLimit == 0) { // "always cache" desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(Integer.MAX_VALUE)); } else { // "never cache" applyDefaultCurrencyTimeLimit(desc); } }
/** * Set the {@code currencyTimeLimit} field to the specified * "defaultCurrencyTimeLimit", if any (by default none). * @param desc the JMX attribute or operation descriptor * @see #setDefaultCurrencyTimeLimit(Integer) */ protected final void applyDefaultCurrencyTimeLimit(Descriptor desc) { if (getDefaultCurrencyTimeLimit() != null) { desc.setField(FIELD_CURRENCY_TIME_LIMIT, getDefaultCurrencyTimeLimit().toString()); } }
/** * Apply the given JMX "currencyTimeLimit" value to the given descriptor. * <p>The default implementation sets a value {@code >0} as-is (as number of cache seconds), * turns a value of {@code 0} into {@code Integer.MAX_VALUE} ("always cache") * and sets the "defaultCurrencyTimeLimit" (if any, indicating "never cache") in case of * a value {@code <0}. This follows the recommendation in the JMX 1.2 specification. * @param desc the JMX attribute or operation descriptor * @param currencyTimeLimit the "currencyTimeLimit" value to apply * @see #setDefaultCurrencyTimeLimit(Integer) * @see #applyDefaultCurrencyTimeLimit(javax.management.Descriptor) */ protected void applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit) { if (currencyTimeLimit > 0) { // number of cache seconds desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(currencyTimeLimit)); } else if (currencyTimeLimit == 0) { // "always cache" desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(Integer.MAX_VALUE)); } else { // "never cache" applyDefaultCurrencyTimeLimit(desc); } }
/** * Set the {@code currencyTimeLimit} field to the specified * "defaultCurrencyTimeLimit", if any (by default none). * @param desc the JMX attribute or operation descriptor * @see #setDefaultCurrencyTimeLimit(Integer) */ protected final void applyDefaultCurrencyTimeLimit(Descriptor desc) { if (getDefaultCurrencyTimeLimit() != null) { desc.setField(FIELD_CURRENCY_TIME_LIMIT, getDefaultCurrencyTimeLimit().toString()); } }
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()); } desc.setField(FIELD_METRIC_TYPE, metric.getMetricType().toString()); }
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) { applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit())); Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue()); desc.setField(FIELD_DEFAULT, defaultValue); String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy()); if (StringUtils.hasLength(persistPolicy)) { desc.setField(FIELD_PERSIST_POLICY, persistPolicy); } int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod()); if (persistPeriod >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod)); } }
Descriptor desc = info.getDescriptor(); if (method.equals(pd.getReadMethod())) { desc.setField(FIELD_ROLE, ROLE_GETTER); desc.setField(FIELD_ROLE, ROLE_SETTER); desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY); if (isExposeClassDescriptor()) { desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName()); info = createModelMBeanOperationInfo(method, method.getName(), beanKey); Descriptor desc = info.getDescriptor(); desc.setField(FIELD_ROLE, ROLE_OPERATION); if (isExposeClassDescriptor()) { desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
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()); } desc.setField(FIELD_METRIC_TYPE, metric.getMetricType().toString()); }
desc.setField(FIELD_LOG, "true"); desc.setField(FIELD_LOG_FILE, mr.getLogFile()); desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation());
OpenType ot = OpenTypeUtils.typeToOpenType(field.getGenericType()); if (ot != null) { descriptor.setField("openType", ot);
Descriptor desc = info.getDescriptor(); if (method.equals(pd.getReadMethod())) { desc.setField(FIELD_ROLE, ROLE_GETTER); desc.setField(FIELD_ROLE, ROLE_SETTER); desc.setField(FIELD_VISIBILITY, ATTRIBUTE_OPERATION_VISIBILITY); if (isExposeClassDescriptor()) { desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName()); info = createModelMBeanOperationInfo(method, method.getName(), beanKey); Descriptor desc = info.getDescriptor(); desc.setField(FIELD_ROLE, ROLE_OPERATION); if (isExposeClassDescriptor()) { desc.setField(FIELD_CLASS, getClassForDescriptor(managedBean).getName());
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) { applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit())); Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue()); desc.setField(FIELD_DEFAULT, defaultValue); String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy()); if (StringUtils.hasLength(persistPolicy)) { desc.setField(FIELD_PERSIST_POLICY, persistPolicy); } int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod()); if (persistPeriod >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod)); } }
desc.setField(FIELD_LOG, "true"); desc.setField(FIELD_LOG_FILE, mr.getLogFile()); desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation());
m.getReturnType() .getName(), impact); info.getDescriptor().setField("visibility", Integer.toString(visibility)); infos.add(info);
@Override public ModelMBeanAttributeInfo createAttributeInfo() { Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName, "descriptorType=attribute", "currencyTimeLimit=-1", // always stale "displayName=" + this.displayName, "getMethod=getJmxValue", "setMethod=setJmxValue"}); Assert.assertTrue(this.config != null, "Config target object is null!"); desc.setField("targetObject", this.config); 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; } }
@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; } }