Class Context
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Pausable, Loggeable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckPoint(String detail) add a checkpoint to the profilerclone()Creates a copy of the current Context object.Creates a clone of the current Context instance, including only the specified keys.voiddump(PrintStream p, String indent) protected voidprotected voiddumpMap(PrintStream p, String indent) booleanvoidEvicts a persistent entry<T> TGet object instance from transaction context.<T> Tpersistent get with timeout<T> TGet object instance from transaction context.return a LogEvent used to store trace information about this transaction.getMap()return (or creates) a Profiler objectreturn (or creates) a Resultr objectlonginthashCode()booleanCheck if key presentbooleanDetermines whether the specified keys are all present in the map.booleanhasPersistedKey(Object key) Check key exists present persisted mapbooleanisTrace()keysNotPresent(Object... keys) Returns a comma-separated string of keys that are not present in the map.voidadds a trace messagevoidMerges the entries from the provided Context object into the current Context.<T> TMove entry to new key namepause()voidPersists a transient entryvoidputs an Object in the transient Mapvoidputs an Object in the transient Mapvoid<T> TTransient removevoidreset()voidresume(int result) voidsetTimeout(long timeout) voidsetTrace(boolean trace) void
-
Constructor Details
-
Context
public Context()
-
-
Method Details
-
put
-
put
-
persist
-
evict
-
get
-
hasKey
-
hasKeys
Determines whether the specified keys are all present in the map. This method accepts a variable number of key arguments and supports both Object[] and String keys. When the key is a String, it can contain multiple keys separated by a '|' character, and the method will return true if any of those keys is present in the map. The method does not support nested arrays of keys.- Parameters:
keys- A variable-length array of keys to check for in the map. These keys can be of any Object type or String containing multiple keys separated by '|'.- Returns:
- true if all specified keys (or any of the '|' separated keys within a String key) are present in the map, false otherwise.
-
keysNotPresent
Returns a comma-separated string of keys that are not present in the map. This method accepts a variable number of key arguments and supports both Object[] and String keys. When the key is a String, it can contain multiple keys separated by a '|' character, and the method will return the keys not present in the map. The method does not support nested arrays of keys.- Parameters:
keys- A variable-length array of keys to check for their absence in the map. These keys can be of any Object type or String containing multiple keys separated by '|'.- Returns:
- A comma-separated string of keys that are not present in the map. If all the specified keys (or any of the '|' separated keys within a String key) are present in the map, an empty string is returned.
-
hasPersistedKey
Check key exists present persisted map- Parameters:
key- the key- Returns:
- true if present
-
move
-
get
Get object instance from transaction context.- Type Parameters:
T- desired type of object instance- Parameters:
key- the key of object instancedefValue- default value returned if there is no value in context- Returns:
- object instance if exist in context or
defValueotherwise
-
remove
-
getString
-
getString
-
dump
-
get
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
clone
Creates a copy of the current Context object.This method clones the Context object, creating new synchronized map containers that are independent of the original. However, the keys and values themselves are not cloned - both Context instances will share references to the same key/value objects. Structural changes (add/remove operations) to one Context's maps will not affect the other, but modifications to mutable key/value objects will be visible in both Contexts.
The cloned Context preserves the thread-safety characteristics through
Collections.synchronizedMapwrappers.- Overrides:
clonein classObject- Returns:
- a copy of the current Context object with independent map containers
- Throws:
AssertionError- if cloning is not supported, which should not happen
-
clone
Creates a clone of the current Context instance, including only the specified keys. This method accepts a variable number of key arguments and supports both Object[] and String keys. When the key is a String, it can contain multiple keys separated by a '|' character. The method does not support nested arrays of keys.- Parameters:
keys- A variable-length array of keys to include in the cloned context. These keys can be of any Object type or String containing multiple keys separated by '|'.- Returns:
- A cloned Context instance containing only the specified keys and their associated values from the original context. If none of the specified keys are present in the original context, an empty Context instance is returned.
-
merge
Merges the entries from the provided Context object into the current Context.This method iterates over the entries in the given Context object 'c' and adds or updates the entries in the current Context. If an entry already exists in the current Context, its value will be updated. If an entry is marked as persisted in the given Context object, it will also be marked as persisted in the current Context.
- Parameters:
c- the Context object whose entries should be merged into the current Context
-
equals
-
hashCode
-
getMap
-
getMapClone
-
dumpMap
-
dumpEntry
-
getLogEvent
return a LogEvent used to store trace information about this transaction. If there's no LogEvent there, it creates one.- Returns:
- LogEvent
-
getProfiler
-
getResult
-
log
-
checkPoint
add a checkpoint to the profiler -
isTrace
-
setTrace
-
pause
-
resume
-
reset
-
getTimeout
- Specified by:
getTimeoutin interfacePausable
-
setTimeout
- Specified by:
setTimeoutin interfacePausable
-