public interface Executor
extends org.springframework.context.ApplicationContextAware
execute(Principal, Work)
method
ensures that SecuritySystem.login(Principal)
is called before the
task, that a TransactionCallback
and a HibernateCallback
surround the call, and that subsequently SecuritySystem.logout()
is
called.Modifier and Type | Interface and Description |
---|---|
static class |
Executor.Descriptive |
static class |
Executor.Impl |
static interface |
Executor.LoggedWork<X> |
static class |
Executor.Priority |
static class |
Executor.SimpleSqlWork
Simple adapter which takes a String for
Executor.Descriptive.description |
static class |
Executor.SimpleWork<T>
Simple adapter which takes a String for
Executor.Descriptive.description |
static interface |
Executor.SqlWork
Work SPI to perform actions related to
stateless
sessions. |
static interface |
Executor.StatefulWork
In the case of a stateful work order, the bean itself needs to be
associated with the sessionHandler and thread rather than the word
instance itself.
|
static interface |
Executor.Work<X>
Work SPI to perform actions within the server as if they were fully
wrapped in our service logic.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
execute(java.util.Map<java.lang.String,java.lang.String> callContext,
ome.system.Principal p,
Executor.Work<T> work)
Executes a
Executor.Work instance wrapped in two layers of AOP. |
<T> T |
execute(ome.system.Principal p,
Executor.Work<T> work)
Call
execute(Map, Principal, Work) with
a null call context. |
java.lang.Object |
executeSql(Executor.SqlWork work)
Executes a
Executor.SqlWork wrapped with a transaction. |
<T> T |
get(java.util.concurrent.Future<T> future)
Helper method to perform
Future.get() and properly unwrap the
exceptions. |
ome.system.OmeroContext |
getContext()
Provides access to the context for Work-API consumers who need to publish
events, etc.
|
java.util.concurrent.ExecutorService |
getService()
Returns the
ExecutorService assigned to this instance. |
ome.system.Principal |
principal()
Returns a
Principal representing your current session or null,
if none is active. |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> callable)
Call
submit(Map, Callable) with a null callContext. |
<T> java.util.concurrent.Future<T> |
submit(Executor.Priority prio,
java.util.concurrent.Callable<T> callable)
Simple submission method with a
Executor.Priority . |
<T> java.util.concurrent.Future<T> |
submit(Executor.Priority prio,
java.util.Map<java.lang.String,java.lang.String> callContext,
java.util.concurrent.Callable<T> callable)
Like
submit(Map, Callable) but provide info to which priority
queue should be used. |
<T> java.util.concurrent.Future<T> |
submit(java.util.Map<java.lang.String,java.lang.String> callContext,
java.util.concurrent.Callable<T> callable)
Simple submission method which can be used in conjunction with a call to
execute(Principal, Work) to overcome the no-multiple-login rule. |
ome.system.OmeroContext getContext()
ome.system.Principal principal()
Principal
representing your current session or null,
if none is active.<T> T execute(ome.system.Principal p, Executor.Work<T> work)
execute(Map, Principal, Work)
with
a null call context.<T> T execute(java.util.Map<java.lang.String,java.lang.String> callContext, ome.system.Principal p, Executor.Work<T> work)
Executor.Work
instance wrapped in two layers of AOP. The first
is intended to acquire the proper arguments for
Executor.Work.doWork(Session, ServiceFactory)
from the
OmeroContext
, and the second performs all the standard service
actions for any normal method call.
If the Map
argument is not null, then additionally,
setContext will be called in a try/finally block. The first login
within this thread will then pick up this delayed context.
If the Principal
argument is not null, then additionally, a
login/logout sequence will be performed in a try/finally block.
Executor.Work
implementation must be annotated with Transactional
in order to properly specify isolation, read-only status, etc.callContext
- Possibly null.p
- Possibly null.work
- Not null.<T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> callable)
submit(Map, Callable)
with a null callContext.callable
- <T> java.util.concurrent.Future<T> submit(java.util.Map<java.lang.String,java.lang.String> callContext, java.util.concurrent.Callable<T> callable)
execute(Principal, Work)
to overcome the no-multiple-login rule.T
- callContext
- Possibly null. See CurrentDetails.setContext(Map)
callable
- Not null. Action to be taken.<T> java.util.concurrent.Future<T> submit(Executor.Priority prio, java.util.concurrent.Callable<T> callable)
Executor.Priority
.prio
- Possibly null. See submit(Priority, Map, Callable)
callable
- Not null. Action to be taken.<T> java.util.concurrent.Future<T> submit(Executor.Priority prio, java.util.Map<java.lang.String,java.lang.String> callContext, java.util.concurrent.Callable<T> callable)
submit(Map, Callable)
but provide info to which priority
queue should be used.prio
- Possibly null. Priority for execution. Default: Executor.Priority.USER
callContext
- Possibly null. See CurrentDetails.setContext(Map)
callable
- Not null. Action to be taken.<T> T get(java.util.concurrent.Future<T> future)
Future.get()
and properly unwrap the
exceptions. Any RuntimeException
which was thrown during
execution will be rethrown. All other exceptions will be wrapped in an
InternalException
.java.util.concurrent.ExecutorService getService()
java.lang.Object executeSql(Executor.SqlWork work)
Executor.SqlWork
wrapped with a transaction. Since
StatelessSession
does not return proxies, there is less concern
about returned values, but this method completely overrides
OMERO security, and should be used very carefully.
As with execute(Principal, Work)
the Executor.SqlWork
instance must be properly marked with an Transactional
annotation.work
- Non-null.