Beispiel #1
0
  public void arrayChanged(TCObject source, int startPos, Object array, int length) {
    if (isTransactionLoggingDisabled()) {
      return;
    }
    try {
      disableTransactionLogging();
      Object pojo = source.getPeerObject();
      ClientTransaction tx = getTransaction(pojo);

      if (!ClassUtils.isPrimitiveArray(array)) {
        Object[] objArray = (Object[]) array;
        for (int i = 0; i < length; i++) {

          Object element = objArray[i];
          if (!literalValues.isLiteralInstance(element)) {
            if (element != null)
              objectManager.checkPortabilityOfField(element, String.valueOf(i), pojo);

            TCObject tco = objectManager.lookupOrCreate(element);
            objArray[i] = tco.getObjectID();
            // record the reference in this transaction -- This is to solve the race condition of
            // transactions
            // that reference objects newly "created" in other transactions that may not commit
            // before us
            if (element != null) tx.createObject(tco);
          }
        }
      }
      tx.arrayChanged(source, startPos, array, length);

    } finally {
      enableTransactionLogging();
    }
  }
Beispiel #2
0
  public void fieldChanged(
      TCObject source, String classname, String fieldname, Object newValue, int index) {
    if (isTransactionLoggingDisabled()) {
      return;
    }

    try {
      disableTransactionLogging();

      Object pojo = source.getPeerObject();

      ClientTransaction tx = getTransaction(pojo);
      logFieldChanged0(source, classname, fieldname, newValue, tx);

      if (newValue != null && literalValues.isLiteralInstance(newValue)) {
        tx.fieldChanged(source, classname, fieldname, newValue, index);
      } else {
        if (newValue != null) {
          objectManager.checkPortabilityOfField(newValue, fieldname, pojo);
        }

        TCObject tco = objectManager.lookupOrCreate(newValue);
        tx.fieldChanged(source, classname, fieldname, tco.getObjectID(), index);

        // record the reference in this transaction -- This is to solve the race condition of
        // transactions
        // that reference objects newly "created" in other transactions that may not commit before
        // us
        if (newValue != null) {
          tx.createObject(tco);
        }
      }
    } finally {
      enableTransactionLogging();
    }
  }