private int getStaleness(Descriptor attribute, Descriptor mbean, String lastUpdateField) {
    Logger logger = getLogger();

    Long currencyTimeLimit = getFieldTimeValue(attribute, mbean, "currencyTimeLimit");
    if (currencyTimeLimit == null) {
      // No time limit defined
      if (logger.isEnabledFor(Logger.TRACE)) {
        logger.trace("No currencyTimeLimit defined, assuming always stale");
      }
      return ALWAYS_STALE;
    } else {
      long ctl = currencyTimeLimit * 1000;
      if (logger.isEnabledFor(Logger.TRACE)) {
        logger.trace("currencyTimeLimit is (ms): " + ctl);
      }

      if (ctl == 0) {
        // Never stale
        if (logger.isEnabledFor(Logger.TRACE)) {
          logger.trace("Never stale");
        }
        return NEVER_STALE;
      } else if (ctl < 0) // this should be == -1 but the other cases are in the air
      {
        // Always stale
        if (logger.isEnabledFor(Logger.TRACE)) {
          logger.trace("Always stale");
        }
        return ALWAYS_STALE;
      } else {
        Long timestamp = (Long) attribute.getFieldValue(lastUpdateField);
        long luts = 0;

        if (timestamp != null) {
          luts = timestamp;
        }
        if (logger.isEnabledFor(Logger.DEBUG)) {
          logger.debug(lastUpdateField + " is: " + luts);
        }

        long now = System.currentTimeMillis();
        if (now < luts + ctl) {
          // Seems to be not stale, but has been set at least once ?
          if (timestamp == null) {
            // Return stale to call it the first time
            if (logger.isEnabledFor(Logger.TRACE)) {
              logger.trace("Stale since was never set");
            }
            return STALE;
          } else {
            if (logger.isEnabledFor(Logger.TRACE)) {
              logger.trace("Not stale");
            }
            return NOT_STALE;
          }
        } else {
          // Stale
          if (logger.isEnabledFor(Logger.TRACE)) {
            logger.trace("Stale");
          }
          return STALE;
        }
      }
    }
  }
@author <a href="mailto:biorn_steedom@users.sourceforge.net">Simone Bordet</a>
@version $Revision: 1.14 $
geode-core/src/main/java/org/apache/geode/admin/jmx/internal/MX4JModelMBean.java