public class OperationContext extends AbstractMap<String,Object> implements AutoCloseable
Context objects are:
setCoreSession(CoreSession)
method. When running the operation chain
in asynchronous mode another session will be created by preserving the current session credentials.
Each entry in the operation list contains the ID of the operation to be run and a map of operation parameters to use when initializing the operation.
The context parameters map can be filled with contextual information by the caller. Each operation will be able to access the contextual data at runtime and to update it if needed.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
protected OperationCallback |
callback |
protected List<CleanupHandler> |
cleanupHandlers |
protected boolean |
commit
Whether to save the session at the end of the chain execution.
|
protected Object |
input
The execution input that will be updated after an operation run with the operation output
|
protected LoginStack |
loginStack
A logins stack manage multiple logins and sessions in a single chain execution
|
protected Map<String,Deque<Object>> |
stacks
Each stack use a key the type of the objects in the stack: document, documents, blob or blobs
|
protected List<String> |
trace
A list of trace.
|
protected Map<String,Object> |
vars
The context variables.
|
Modifier | Constructor and Description |
---|---|
|
OperationContext() |
|
OperationContext(CoreSession session) |
protected |
OperationContext(CoreSession session,
Map<String,Object> bindings) |
Modifier and Type | Method and Description |
---|---|
void |
addCleanupHandler(CleanupHandler handler) |
protected <T,U> T |
call(Callable<T> callable,
Callable<U> initialize,
Consumer<U> restore)
Calls the given
callable after having backed up the initial state as a result of initialize and
restores the initial state afterwards by calling restore . |
<T> T |
callWithChainParameters(Callable<T> callable,
Map<String,Object> parameters)
Calls the given
callable after having merged the given parameters with the chain parameters
stored in the Constants.VAR_RUNTIME_CHAIN context variable and restores the initial chain parameters
afterwards. |
<T> T |
callWithContextVar(Callable<T> callable,
String key,
Object value)
Calls the given
callable after having put a variable with key=value in the current context and
restores the initial context afterwards. |
void |
close() |
Set<Map.Entry<String,Object>> |
entrySet() |
Object |
get(Object key)
the map API
|
<T> T |
getAdapter(Class<T> type) |
OperationCallback |
getCallback() |
Object |
getChainParameter(String key)
Gets the parameter associated with the given key from the chain parameters falling back on the global context.
|
Map<String,Object> |
getChainParameters() |
CoreSession |
getCoreSession() |
Object |
getInput() |
LoginStack |
getLoginStack() |
Principal |
getPrincipal() |
OperationContext |
getSubContext(boolean isolate) |
OperationContext |
getSubContext(boolean isolate,
Object input) |
Map<String,Object> |
getVars() |
boolean |
isCommit() |
Object |
peek(String type) |
Object |
pop(String type) |
Object |
pull(String type) |
void |
push(String type,
Object obj) |
Object |
put(String key,
Object value) |
Map<String,Object> |
putChainParameters(Map<String,?> parameters) |
Object |
remove(Object key) |
Map<String,Object> |
removeChainParameters() |
void |
removeCleanupHandler(CleanupHandler handler) |
Object |
resolve(Object obj)
Evaluate the expression against this context if needed
|
void |
setCallback(OperationCallback chainCallback) |
void |
setCommit(boolean commit) |
void |
setCoreSession(CoreSession session) |
void |
setInput(Object input) |
void |
setRollback()
Set the rollback mark on the current tx.
|
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected boolean commit
protected final List<CleanupHandler> cleanupHandlers
protected final Map<String,Deque<Object>> stacks
protected LoginStack loginStack
protected Object input
protected List<String> trace
protected OperationCallback callback
public OperationContext()
public OperationContext(CoreSession session)
protected OperationContext(CoreSession session, Map<String,Object> bindings)
public void setCoreSession(CoreSession session)
public void setCommit(boolean commit)
public boolean isCommit()
public CoreSession getCoreSession()
public LoginStack getLoginStack()
public Principal getPrincipal()
public <T> T getAdapter(Class<T> type)
public void addCleanupHandler(CleanupHandler handler)
public void removeCleanupHandler(CleanupHandler handler)
public void close()
close
in interface AutoCloseable
public void setRollback()
public Map<String,Object> getChainParameters()
public Map<String,Object> removeChainParameters()
public Object getChainParameter(String key)
public <T> T callWithChainParameters(Callable<T> callable, Map<String,Object> parameters) throws OperationException
callable
after having merged the given parameters
with the chain parameters
stored in the Constants.VAR_RUNTIME_CHAIN
context variable and restores the initial chain parameters
afterwards.OperationException
public <T> T callWithContextVar(Callable<T> callable, String key, Object value) throws OperationException
callable
after having put a variable with key=value
in the current context and
restores the initial context afterwards.OperationException
protected <T,U> T call(Callable<T> callable, Callable<U> initialize, Consumer<U> restore) throws OperationException
callable
after having backed up the initial state as a result of initialize
and
restores the initial state afterwards by calling restore
.OperationException
public OperationCallback getCallback()
public void setCallback(OperationCallback chainCallback)
public OperationContext getSubContext(boolean isolate, Object input)
isolate
- define if keeps context variables for the subcontextinput
- an input objectpublic OperationContext getSubContext(boolean isolate)
isolate
- define if keeps context variables for the subcontextCopyright © 2018 Nuxeo. All rights reserved.