Class AuditRequestContext
- java.lang.Object
-
- org.forgerock.openam.audit.context.AuditRequestContext
-
public class AuditRequestContext extends Object
Thread-local context for Commons Audit state.- Since:
- 13.0.0
-
-
Constructor Summary
Constructors Constructor Description AuditRequestContext(org.forgerock.services.TransactionId transactionId)Construct a newRequestContext.AuditRequestContext(org.forgerock.services.TransactionId transactionId, Map<String,String> properties)Construct a newRequestContextwith a copy of the given properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidclear()Discards theRequestContextof the current thread.AuditRequestContextcopy()Create a new instance ofRequestContext, which will have a reference to the originalTransactionIdand a copy of the original properties.static StringcreateSubTransactionIdValue()Creates a sub transaction id from the transaction id of the current thread, for propagation to another process.static AuditRequestContextget()Gets the thread localRequestContext.static StringgetProperty(String key)Get the value for the specified property.org.forgerock.services.TransactionIdgetTransactionId()Gets the transaction id.static StringgetTransactionIdValue()Gets the transaction value of the current thread.static voidputProperty(String key, String value)Add a property to the request context.static StringremoveProperty(String key)Remove the value for the specified property.static voidset(AuditRequestContext auditRequestContext)SetsRequestContextof the current thread.
-
-
-
Constructor Detail
-
AuditRequestContext
public AuditRequestContext(org.forgerock.services.TransactionId transactionId)
Construct a newRequestContext.- Parameters:
transactionId- Non-null,TransactionId.
-
AuditRequestContext
public AuditRequestContext(org.forgerock.services.TransactionId transactionId, Map<String,String> properties)Construct a newRequestContextwith a copy of the given properties.- Parameters:
transactionId- Non-null,TransactionId.properties- Initial properties for this context.
-
-
Method Detail
-
copy
public AuditRequestContext copy()
Create a new instance ofRequestContext, which will have a reference to the originalTransactionIdand a copy of the original properties. A copy can be used to hand over the context from one thread to another and therefore we make a copy of the properties in order to keep the map thread-safe. The transactionId is thread-safe and we want to see the sequence of sub-transactionIds shared across threads.- Returns:
- a copy of this instance
-
getTransactionId
public org.forgerock.services.TransactionId getTransactionId()
Gets the transaction id.- Returns:
- Non-null,
TransactionId.
-
putProperty
public static void putProperty(String key, String value)
Add a property to the request context. Changing a property for the same transaction in separate threads will only affect the property on the current thread. Properties are copied when the context is passed on from one thread to another.- Parameters:
key- the name of the propertyvalue- the value of the property
-
getProperty
public static String getProperty(String key)
Get the value for the specified property.- Parameters:
key- the name of the property- Returns:
- the value of the property or null if it has not been set
-
removeProperty
public static String removeProperty(String key)
Remove the value for the specified property.- Parameters:
key- the name of the property- Returns:
- the value of the property or null if it has not been set
-
get
public static AuditRequestContext get()
Gets the thread localRequestContext.- Returns:
- Non-null, thread local
RequestContext.
-
set
public static void set(AuditRequestContext auditRequestContext)
SetsRequestContextof the current thread.- Parameters:
auditRequestContext- Non-null,RequestContext.
-
clear
public static void clear()
Discards theRequestContextof the current thread.
-
getTransactionIdValue
public static String getTransactionIdValue()
Gets the transaction value of the current thread.- Returns:
- Non-null,
TransactionIdvalue.
-
createSubTransactionIdValue
public static String createSubTransactionIdValue()
Creates a sub transaction id from the transaction id of the current thread, for propagation to another process.- Returns:
- Non-null, sub-
TransactionIdvalue.
-
-