Package ome.services.util
Interface Executor
-
- All Superinterfaces:
org.springframework.context.ApplicationContextAware
,org.springframework.beans.factory.Aware
- All Known Implementing Classes:
Executor.Impl
public interface Executor extends org.springframework.context.ApplicationContextAware
Simple execution/work interface which can be used for internal tasks which need to have a full working implementation. Theexecute(Principal, Work)
method ensures thatSecuritySystem.login(Principal)
is called before the task, that aTransactionCallback
and aHibernateCallback
surround the call, and that subsequentlySecuritySystem.logout()
is called.- Since:
- 3.0-Beta3
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface 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 forExecutor.Descriptive.description
static class
Executor.SimpleWork<T>
Simple adapter which takes a String forExecutor.Descriptive.description
static interface
Executor.SqlWork
Work SPI to perform actions related tostateless
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.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
execute(java.util.Map<java.lang.String,java.lang.String> callContext, ome.system.Principal p, Executor.Work<T> work)
Executes aExecutor.Work
instance wrapped in two layers of AOP.<T> T
execute(ome.system.Principal p, Executor.Work<T> work)
Callexecute(Map, Principal, Work)
with a null call context.java.lang.Object
executeSql(Executor.SqlWork work)
Executes aExecutor.SqlWork
wrapped with a transaction.<T> T
get(java.util.concurrent.Future<T> future)
Helper method to performFuture.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 theExecutorService
assigned to this instance.ome.system.Principal
principal()
Returns aPrincipal
representing your current session or null, if none is active.<T> java.util.concurrent.Future<T>
submit(java.util.concurrent.Callable<T> callable)
Callsubmit(Map, Callable)
with a null callContext.<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 toexecute(Principal, Work)
to overcome the no-multiple-login rule.<T> java.util.concurrent.Future<T>
submit(Executor.Priority prio, java.util.concurrent.Callable<T> callable)
Simple submission method with aExecutor.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)
Likesubmit(Map, Callable)
but provide info to which priority queue should be used.
-
-
-
Method Detail
-
getContext
ome.system.OmeroContext getContext()
Provides access to the context for Work-API consumers who need to publish events, etc.
-
principal
ome.system.Principal principal()
Returns aPrincipal
representing your current session or null, if none is active.
-
execute
<T> T execute(ome.system.Principal p, Executor.Work<T> work)
Callexecute(Map, Principal, Work)
with a null call context.
-
execute
<T> T execute(java.util.Map<java.lang.String,java.lang.String> callContext, ome.system.Principal p, Executor.Work<T> work)
Executes aExecutor.Work
instance wrapped in two layers of AOP. The first is intended to acquire the proper arguments forExecutor.Work.doWork(Session, ServiceFactory)
from theOmeroContext
, and the second performs all the standard service actions for any normal method call. If theMap
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 thePrincipal
argument is not null, then additionally, a login/logout sequence will be performed in a try/finally block.Executor.Work
implementation must be annotated withTransactional
in order to properly specify isolation, read-only status, etc.- Parameters:
callContext
- Possibly null.p
- Possibly null.work
- Not null.- Returns:
- See above.
-
submit
<T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> callable)
Callsubmit(Map, Callable)
with a null callContext.- Parameters:
callable
-- Returns:
- See above.
-
submit
<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 toexecute(Principal, Work)
to overcome the no-multiple-login rule.- Type Parameters:
T
-- Parameters:
callContext
- Possibly null. SeeCurrentDetails.setContext(Map)
callable
- Not null. Action to be taken.- Returns:
- See above.
-
submit
<T> java.util.concurrent.Future<T> submit(Executor.Priority prio, java.util.concurrent.Callable<T> callable)
Simple submission method with aExecutor.Priority
.- Parameters:
prio
- Possibly null. Seesubmit(Priority, Map, Callable)
callable
- Not null. Action to be taken.- Returns:
- See above.
-
submit
<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)
Likesubmit(Map, Callable)
but provide info to which priority queue should be used.- Parameters:
prio
- Possibly null. Priority for execution. Default:Executor.Priority.USER
callContext
- Possibly null. SeeCurrentDetails.setContext(Map)
callable
- Not null. Action to be taken.- Returns:
- See above.
-
get
<T> T get(java.util.concurrent.Future<T> future)
Helper method to performFuture.get()
and properly unwrap the exceptions. AnyRuntimeException
which was thrown during execution will be rethrown. All other exceptions will be wrapped in anInternalException
.
-
getService
java.util.concurrent.ExecutorService getService()
-
executeSql
java.lang.Object executeSql(Executor.SqlWork work)
Executes aExecutor.SqlWork
wrapped with a transaction. SinceStatelessSession
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 withexecute(Principal, Work)
theExecutor.SqlWork
instance must be properly marked with anTransactional
annotation.- Parameters:
work
- Non-null.- Returns:
- See above.
-
-