Java Code Examples for javax.management.Descriptor#setField()
The following examples show how to use
javax.management.Descriptor#setField() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: StatisticAttributeInfo.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: ModelMBeanBuilder.java From attic-polygene-java with Apache License 2.0 | 6 votes |
public RequiredModelMBean newModelMBean() throws MBeanException { Descriptor mmbDesc = new DescriptorSupport(); mmbDesc.setField( "name", objectName.toString() ); mmbDesc.setField( "descriptorType", "mbean" ); mmbDesc.setField( "displayName", displayName ); ModelMBeanInfo modelMBeanInfo = new ModelMBeanInfoSupport( className, displayName, attributes.toArray( new ModelMBeanAttributeInfo[attributes.size()]), constructors.toArray( new ModelMBeanConstructorInfo[constructors.size()]), operations.toArray( new ModelMBeanOperationInfo[operations.size()]), notifications.toArray( new ModelMBeanNotificationInfo[notifications.size()]) ); modelMBeanInfo.setMBeanDescriptor( mmbDesc ); return new RequiredModelMBean(modelMBeanInfo); }
Example 4
Source File: ConfigAttributeInfo.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
@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; }
Example 5
Source File: MetadataMBeanInfoAssembler.java From spring-analysis-note with MIT License | 5 votes |
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)); } }
Example 6
Source File: RequiredModelMBean.java From JDKSourceCode1.8 with MIT License | 5 votes |
private void cacheResult(ModelMBeanOperationInfo opInfo, Descriptor opDescr, Object result) throws MBeanException { Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor(); Object objctl = opDescr.getFieldValue("currencyTimeLimit"); String ctl; if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } if ((ctl == null) && (mmbDesc != null)) { objctl = mmbDesc.getFieldValue("currencyTimeLimit"); if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } } if ((ctl != null) && !(ctl.equals("-1"))) { opDescr.setField("value", result); opDescr.setField("lastUpdatedTimeStamp", String.valueOf((new Date()).getTime())); modelMBeanInfo.setDescriptor(opDescr, "operation"); if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "invoke(String,Object[],Object[])", "new descriptor is " + opDescr); } } }
Example 7
Source File: RequiredModelMBean.java From Java8CN with Apache License 2.0 | 5 votes |
private void cacheResult(ModelMBeanOperationInfo opInfo, Descriptor opDescr, Object result) throws MBeanException { Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor(); Object objctl = opDescr.getFieldValue("currencyTimeLimit"); String ctl; if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } if ((ctl == null) && (mmbDesc != null)) { objctl = mmbDesc.getFieldValue("currencyTimeLimit"); if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } } if ((ctl != null) && !(ctl.equals("-1"))) { opDescr.setField("value", result); opDescr.setField("lastUpdatedTimeStamp", String.valueOf((new Date()).getTime())); modelMBeanInfo.setDescriptor(opDescr, "operation"); if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "invoke(String,Object[],Object[])", "new descriptor is " + opDescr); } } }
Example 8
Source File: RequiredModelMBean.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void cacheResult(ModelMBeanOperationInfo opInfo, Descriptor opDescr, Object result) throws MBeanException { Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor(); Object objctl = opDescr.getFieldValue("currencyTimeLimit"); String ctl; if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } if ((ctl == null) && (mmbDesc != null)) { objctl = mmbDesc.getFieldValue("currencyTimeLimit"); if (objctl != null) { ctl = objctl.toString(); } else { ctl = null; } } if ((ctl != null) && !(ctl.equals("-1"))) { opDescr.setField("value", result); opDescr.setField("lastUpdatedTimeStamp", String.valueOf((new Date()).getTime())); modelMBeanInfo.setDescriptor(opDescr, "operation"); if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "invoke(String,Object[],Object[])", "new descriptor is " + opDescr); } } }
Example 9
Source File: AbstractReflectiveMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 10
Source File: MetadataMBeanInfoAssembler.java From java-technology-stack with MIT License | 5 votes |
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)); } }
Example 11
Source File: MetadataMBeanInfoAssembler.java From java-technology-stack with MIT License | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = obtainAttributeSource().getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example 12
Source File: MetadataMBeanInfoAssembler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example 13
Source File: MetadataMBeanInfoAssembler.java From lams with GNU General Public License v2.0 | 5 votes |
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)); } }
Example 14
Source File: ModelMBeanInfoSupporter.java From cxf with Apache License 2.0 | 4 votes |
public Descriptor buildMBeanDescriptor(ManagedResource mr) { Descriptor desc = new DescriptorSupport(); if (mr.componentName() != null) { desc.setField("name", mr.componentName()); } desc.setField("descriptorType", "mbean"); if (mr.description() != null) { desc.setField("displayName", mr.description()); } if (mr.persistLocation() != null) { desc.setField("persistLocation", mr.persistLocation()); } if (mr.persistName() != null) { desc.setField("persistName", mr.persistName()); } if (mr.log()) { desc.setField("log", "true"); } else { desc.setField("log", "false"); } if (mr.persistPolicy() != null) { desc.setField("persistPolicy", mr.persistPolicy()); } if (mr.persistPeriod() >= -1) { desc.setField("persistPeriod", mr.persistPeriod()); } if (mr.logFile() != null) { desc.setField("logFile", mr.logFile()); } if (mr.currencyTimeLimit() >= -1) { desc.setField("currencyTimeLimit", mr.currencyTimeLimit()); } return desc; }
Example 15
Source File: DescriptorSupportTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static boolean caseTest(Descriptor d, String what) { boolean ok = true; System.out.println("..." + what); String[] names = d.getFieldNames(); if (names.length != 1 || !names[0].equals("NAME")) { ok = false; System.out.println("...getFieldNames() fails: " + Arrays.asList(names)); } String[] fields = d.getFields(); if (fields.length != 1 || !fields[0].equals("NAME=blah")) { ok = false; System.out.println("...getFields() fails: " + Arrays.asList(fields)); } Object value = d.getFieldValue("namE"); if (!"blah".equals(value)) { ok = false; System.out.println("...getFieldValue(\"namE\") fails: " + value); } Object[] values = d.getFieldValues(new String[] {"namE"}); if (values.length != 1 || !"blah".equals(values[0])) { ok = false; System.out.println("...getFieldValues({\"namE\"}) fails: " + Arrays.asList(values)); } d.setField("namE", "newblah"); Object newblah = d.getFieldValue("Name"); if (!"newblah".equals(newblah)) { ok = false; System.out.println("...setField value not returned: " + newblah); } d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"}); Object newerblah = d.getFieldValue("naMe"); if (!"newerblah".equals(newerblah)) { ok = false; System.out.println("...setFields value not returned: " + newerblah); } Descriptor d1 = (Descriptor) d.clone(); newerblah = d1.getFieldValue("NAMe"); if (!"newerblah".equals(newerblah)) { ok = false; System.out.println("...clone incorrect: " + newerblah); } d.removeField("NAme"); names = d.getFieldNames(); if (names.length != 0) { ok = false; System.out.println("...removeField failed: " + Arrays.asList(names)); } if (ok) System.out.println("...succeeded"); return ok; }
Example 16
Source File: AbstractReflectiveMBeanInfoAssembler.java From java-technology-stack with MIT License | 4 votes |
/** * Iterate through all properties on the MBean class and gives subclasses * the chance to vote on the inclusion of both the accessor and mutator. * If a particular accessor or mutator is voted for inclusion, the appropriate * metadata is assembled and passed to the subclass for descriptor population. * @param managedBean the bean instance (might be an AOP proxy) * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the attribute metadata * @throws JMException in case of errors * @see #populateAttributeDescriptor */ @Override protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException { PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean)); List<ModelMBeanAttributeInfo> infos = new ArrayList<>(); for (PropertyDescriptor prop : props) { Method getter = prop.getReadMethod(); if (getter != null && getter.getDeclaringClass() == Object.class) { continue; } if (getter != null && !includeReadAttribute(getter, beanKey)) { getter = null; } Method setter = prop.getWriteMethod(); if (setter != null && !includeWriteAttribute(setter, beanKey)) { setter = null; } if (getter != null || setter != null) { // If both getter and setter are null, then this does not need exposing. String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing()); String description = getAttributeDescription(prop, beanKey); ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter); Descriptor desc = info.getDescriptor(); if (getter != null) { desc.setField(FIELD_GET_METHOD, getter.getName()); } if (setter != null) { desc.setField(FIELD_SET_METHOD, setter.getName()); } populateAttributeDescriptor(desc, getter, setter, beanKey); info.setDescriptor(desc); infos.add(info); } } return infos.toArray(new ModelMBeanAttributeInfo[0]); }
Example 17
Source File: AbstractReflectiveMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Iterate through all properties on the MBean class and gives subclasses * the chance to vote on the inclusion of both the accessor and mutator. * If a particular accessor or mutator is voted for inclusion, the appropriate * metadata is assembled and passed to the subclass for descriptor population. * @param managedBean the bean instance (might be an AOP proxy) * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the attribute metadata * @throws JMException in case of errors * @see #populateAttributeDescriptor */ @Override protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException { PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean)); List<ModelMBeanAttributeInfo> infos = new ArrayList<ModelMBeanAttributeInfo>(); for (PropertyDescriptor prop : props) { Method getter = prop.getReadMethod(); if (getter != null && getter.getDeclaringClass() == Object.class) { continue; } if (getter != null && !includeReadAttribute(getter, beanKey)) { getter = null; } Method setter = prop.getWriteMethod(); if (setter != null && !includeWriteAttribute(setter, beanKey)) { setter = null; } if (getter != null || setter != null) { // If both getter and setter are null, then this does not need exposing. String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing()); String description = getAttributeDescription(prop, beanKey); ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter); Descriptor desc = info.getDescriptor(); if (getter != null) { desc.setField(FIELD_GET_METHOD, getter.getName()); } if (setter != null) { desc.setField(FIELD_SET_METHOD, setter.getName()); } populateAttributeDescriptor(desc, getter, setter, beanKey); info.setDescriptor(desc); infos.add(info); } } return infos.toArray(new ModelMBeanAttributeInfo[infos.size()]); }
Example 18
Source File: DescriptorSupportTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static boolean caseTest(Descriptor d, String what) { boolean ok = true; System.out.println("..." + what); String[] names = d.getFieldNames(); if (names.length != 1 || !names[0].equals("NAME")) { ok = false; System.out.println("...getFieldNames() fails: " + Arrays.asList(names)); } String[] fields = d.getFields(); if (fields.length != 1 || !fields[0].equals("NAME=blah")) { ok = false; System.out.println("...getFields() fails: " + Arrays.asList(fields)); } Object value = d.getFieldValue("namE"); if (!"blah".equals(value)) { ok = false; System.out.println("...getFieldValue(\"namE\") fails: " + value); } Object[] values = d.getFieldValues(new String[] {"namE"}); if (values.length != 1 || !"blah".equals(values[0])) { ok = false; System.out.println("...getFieldValues({\"namE\"}) fails: " + Arrays.asList(values)); } d.setField("namE", "newblah"); Object newblah = d.getFieldValue("Name"); if (!"newblah".equals(newblah)) { ok = false; System.out.println("...setField value not returned: " + newblah); } d.setFields(new String[] {"NaMe"}, new Object[] {"newerblah"}); Object newerblah = d.getFieldValue("naMe"); if (!"newerblah".equals(newerblah)) { ok = false; System.out.println("...setFields value not returned: " + newerblah); } Descriptor d1 = (Descriptor) d.clone(); newerblah = d1.getFieldValue("NAMe"); if (!"newerblah".equals(newerblah)) { ok = false; System.out.println("...clone incorrect: " + newerblah); } d.removeField("NAme"); names = d.getFieldNames(); if (names.length != 0) { ok = false; System.out.println("...removeField failed: " + Arrays.asList(names)); } if (ok) System.out.println("...succeeded"); return ok; }
Example 19
Source File: AbstractReflectiveMBeanInfoAssembler.java From spring-analysis-note with MIT License | 4 votes |
/** * Iterate through all properties on the MBean class and gives subclasses * the chance to vote on the inclusion of both the accessor and mutator. * If a particular accessor or mutator is voted for inclusion, the appropriate * metadata is assembled and passed to the subclass for descriptor population. * @param managedBean the bean instance (might be an AOP proxy) * @param beanKey the key associated with the MBean in the beans map * of the {@code MBeanExporter} * @return the attribute metadata * @throws JMException in case of errors * @see #populateAttributeDescriptor */ @Override protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException { PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean)); List<ModelMBeanAttributeInfo> infos = new ArrayList<>(); for (PropertyDescriptor prop : props) { Method getter = prop.getReadMethod(); if (getter != null && getter.getDeclaringClass() == Object.class) { continue; } if (getter != null && !includeReadAttribute(getter, beanKey)) { getter = null; } Method setter = prop.getWriteMethod(); if (setter != null && !includeWriteAttribute(setter, beanKey)) { setter = null; } if (getter != null || setter != null) { // If both getter and setter are null, then this does not need exposing. String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing()); String description = getAttributeDescription(prop, beanKey); ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter); Descriptor desc = info.getDescriptor(); if (getter != null) { desc.setField(FIELD_GET_METHOD, getter.getName()); } if (setter != null) { desc.setField(FIELD_SET_METHOD, setter.getName()); } populateAttributeDescriptor(desc, getter, setter, beanKey); info.setDescriptor(desc); infos.add(info); } } return infos.toArray(new ModelMBeanAttributeInfo[0]); }
Example 20
Source File: AbstractReflectiveMBeanInfoAssembler.java From spring-analysis-note with MIT License | 2 votes |
/** * 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()); } }