Ejemplo n.º 1
0
  // only correct if invoked within a backing transaction.  Also this code
  // assumes a single global commit lock. Otherwise the counter might be set
  // backwards by a late-running thread.
  private void updatePersistentInstanceCounters() {
    Transaction current = FenixFramework.getTransaction();

    Set<DomainClassInfo> infos = current.getFromContext(KEY_INSTANTIATED_CLASSES);

    if (infos != null) {
      for (DomainClassInfo info : infos) {
        String key = makeKeyForMaxCounter(info);
        Integer max = (Integer) dataGrid.get(key);

        int newCounterValue = info.getLastKey();

        if (max == null || max < newCounterValue) {
          dataGrid.put(key, newCounterValue);
          logger.debug(
              "Update persistent counter for class {}: {}", info.domainClassName, newCounterValue);
        }
      }
    }
  }
Ejemplo n.º 2
0
 private String makeKeyForMaxCounter(DomainClassInfo domainClassInfo) {
   return String.valueOf(DomainClassInfo.getServerId()) + ":" + domainClassInfo.classId;
 }