public interface Executor
extends org.springframework.context.ApplicationContextAware
execute(Principal, ome.services.util.Executor.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 class |
Executor.Priority |
static class |
Executor.SimpleSqlWork
Simple adapter which takes a String for
Executor.Descriptive.description |
static class |
Executor.SimpleWork
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 |
---|---|
Object |
execute(Map<String,String> callContext,
Principal p,
Executor.Work work)
Executes a
Executor.Work instance wrapped in two layers of AOP. |
Object |
execute(Principal p,
Executor.Work work)
Call
execute(Map, Principal, Work) with
a null call context. |
Object |
executeSql(Executor.SqlWork work)
Executes a
Executor.SqlWork wrapped with a transaction. |
<T> T |
get(Future<T> future)
Helper method to perform
Future.get() and properly unwrap the
exceptions. |
OmeroContext |
getContext()
Provides access to the context for Work-API consumers who need to publish
events, etc.
|
ExecutorService |
getService()
Returns the
ExecutorService assigned to this instance. |
Principal |
principal()
Returns a
Principal representing your current session or null,
if none is active. |
<T> Future<T> |
submit(Callable<T> callable)
Call
submit(Map, Callable) with a null callContext. |
<T> Future<T> |
submit(Executor.Priority prio,
Callable<T> callable)
Simple submission method with a
Executor.Priority . |
<T> Future<T> |
submit(Executor.Priority prio,
Map<String,String> callContext,
Callable<T> callable)
Like
submit(Map, Callable) but provide info to which priority
queue should be used. |
<T> Future<T> |
submit(Map<String,String> callContext,
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. |
OmeroContext getContext()
Principal principal()
Principal
representing your current session or null,
if none is active.Object execute(Principal p, Executor.Work work)
execute(Map, Principal, Work)
with
a null call context.Object execute(Map<String,String> callContext, Principal p, Executor.Work 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> Future<T> submit(Callable<T> callable)
submit(Map, Callable)
with a null callContext.callable
- <T> Future<T> submit(Map<String,String> callContext, 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> Future<T> submit(Executor.Priority prio, Callable<T> callable)
Executor.Priority
.prio
- Possibly null. See submit(Priority, Map, Callable)
callable
- Not null. Action to be taken.<T> Future<T> submit(Executor.Priority prio, Map<String,String> callContext, 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(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
.ExecutorService getService()
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.
Version: 5.2.4-ice35-b23
Copyright © 2016 The University of Dundee & Open Microscopy Environment. All Rights Reserved.