/**
   * Adds descriptor fields from the <code>ManagedResource</code> attribute to the MBean descriptor.
   * Specifically, adds the <code>currencyTimeLimit</code>, <code>persistPolicy</code>, <code>
   * persistPeriod</code>, <code>persistLocation</code> and <code>persistName</code> descriptor
   * fields if they are present in the metadata.
   */
  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());
    }
  }
 /**
  * Reads managed resource description from the source level metadata. Returns an empty <code>
  * String</code> if no description can be found.
  */
 protected String getDescription(Object managedBean, String beanKey) {
   ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
   return (mr != null ? mr.getDescription() : "");
 }