Class TransactionId

java.lang.Object
org.forgerock.services.TransactionId

public final class TransactionId extends Object
TransactionId value should be unique per request coming from an external agent so that all events occurring in response to the same external stimulus can be tied together. Calls to external systems should propagate the value returned by createSubTransactionId() so that Audit events reported by the external system can also be tied back to the original stimulus. Due to the fact that each TransactionId instance creates a sequence of sub-transaction IDs, the same TransactionId object should be used while fulfilling a given request; it is not appropriate to create multiple instances of TransactionId with the same value as this would lead to duplicate sub-transaction ID values. As such, two instances of TransactionId with the same value are not considered equal. This class is thread-safe.
Since:
2.0
  • Constructor Details

    • TransactionId

      public TransactionId()
      Construct a TransactionId with a random value.
    • TransactionId

      public TransactionId(String value)
      Construct a TransactionId with the specified value. The value must not be null nor empty.
      Parameters:
      value - The value to initialize the transactionId from.
  • Method Details

    • getValue

      public String getValue()
      Returns the value of this TransactionId.
      Returns:
      Non-null, TransactionId value.
    • createSubTransactionId

      public TransactionId createSubTransactionId()
      Creates a new TransactionId, child of this one.
      Returns:
      Non-null, TransactionId value that can be passed to an external system.
    • toJson

      public JsonValue toJson()
      Returns a representation of this TransactionId as a JsonValue. The JsonValue will be composed of 2 fields : value and subTransactionIdCounter.
      Returns:
      a representation of this TransactionId as a JsonValue.
    • valueOf

      public static TransactionId valueOf(JsonValue value)
      Creates a TransactionId from a JsonValue.
      Parameters:
      value - the JsonValue used to create the TransactionId, composed of 2 fields : value and subTransactionIdCounter.
      Returns:
      a TransactionId initialized with the values provided by the JsonValue.