Class Mode<E extends Exception>
java.lang.Object
ch.tocco.nice2.persist.core.api.exec.Mode<E>
Describes the execution of a task; such as
 
- whether the task is executed in a transaction
 - can control exception handling of 
PersistException. It will catch the checked exceptions *and*PersistExceptions thrown by tasks and wrap it using the exception supplied with themode. Other `RuntimeException`s are propagated, and a log message is printed. - whether the task is executed in privileged mode
 - which business-unit to use
 - ...
 
The first two are provided by this class. The security module is adding the third option, the privileged mode.
 Other options can be easily added by creating a new Mode.Key constant and adding values to the
 mode object. This may be useful to hand parameters to the task itself, or by contributing a
 persist.spi.ModeWrapper to control the execution environment of a task.
 
- 
Nested Class Summary
Nested Classes - 
Method Summary
Modifier and TypeMethodDescriptioncontext()Returns the context, if specified withuse(Context)static Mode<PersistException> create()static Mode<PersistException> Specifies explicitely to use the current context (the default).boolean<V> Optional<V> getPriority(Mode.Key<?> key) inthashCode()booleanReturnstrueif the given key exists and does not map to a boolean value offalse.booleanbooleanstatic <T> Mode.Key<T> static <T> Mode.Key<T> Creates a new key of the specified name and type.noTx()Specifies to not use a transaction when executing the task.This flag is used internally to mark execution of a task in a different thread.toString()unwrap()Specifies to use the given context when executing the task.Short forwith(Key, true)Creates a new mode object of the current list of options together with the given one.withinTx()Specifies to execute a task within a transaction.Removes the given key from the list of options.Wrap persist exceptions into the specified one. 
- 
Method Details
- 
key
Creates a new key of the specified name and type. - 
key
 - 
create
 - 
createTransactional
 - 
exception
 - 
wrapIn
Wrap persist exceptions into the specified one. - 
unwrap
 - 
isTransactional
public boolean isTransactional() - 
getTxPriority
 - 
get
 - 
getPriority
 - 
getExceptionMapper
 - 
is
Returnstrueif the given key exists and does not map to a boolean value offalse. - 
with
Creates a new mode object of the current list of options together with the given one.If
valueisnullthe option key is removed (same as callingwithout(Key). - 
with
 - 
with
Short forwith(Key, true) - 
with
 - 
without
Removes the given key from the list of options. - 
withinTx
Specifies to execute a task within a transaction. The default priority isPriority.LOWER. - 
withinTx
 - 
withinNewContext
 - 
noTx
Specifies to not use a transaction when executing the task. - 
use
Specifies to use the given context when executing the task. In some (rare) cases it can be desired to hand in a concrete context. Most usually, it is better to use the current context, which is the default behaviour.Can be reverted by
defaultContext(). - 
use
 - 
getContextPriority
 - 
defaultContext
Specifies explicitely to use the current context (the default). - 
isSubmitted
public boolean isSubmitted()- See Also:
 
 - 
setSubmittedFlag
This flag is used internally to mark execution of a task in a different thread. It is set byCommandExecutorif a task has beensubmitted - 
context
Returns the context, if specified withuse(Context) - 
equals
 - 
hashCode
public int hashCode() - 
toString
 
 -