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.ApplicationContextAwareSimple 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 aTransactionCallbackand aHibernateCallbacksurround the call, and that subsequentlySecuritySystem.logout()is called.- Since:
- 3.0-Beta3
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classExecutor.Descriptivestatic classExecutor.Implstatic interfaceExecutor.LoggedWork<X>static classExecutor.Prioritystatic classExecutor.SimpleSqlWorkSimple adapter which takes a String forExecutor.Descriptive.descriptionstatic classExecutor.SimpleWork<T>Simple adapter which takes a String forExecutor.Descriptive.descriptionstatic interfaceExecutor.SqlWorkWork SPI to perform actions related tostatelesssessions.static interfaceExecutor.StatefulWorkIn 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 interfaceExecutor.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> Texecute(java.util.Map<java.lang.String,java.lang.String> callContext, ome.system.Principal p, Executor.Work<T> work)Executes aExecutor.Workinstance wrapped in two layers of AOP.<T> Texecute(ome.system.Principal p, Executor.Work<T> work)Callexecute(Map, Principal, Work)with a null call context.java.lang.ObjectexecuteSql(Executor.SqlWork work)Executes aExecutor.SqlWorkwrapped with a transaction.<T> Tget(java.util.concurrent.Future<T> future)Helper method to performFuture.get()and properly unwrap the exceptions.ome.system.OmeroContextgetContext()Provides access to the context for Work-API consumers who need to publish events, etc.java.util.concurrent.ExecutorServicegetService()Returns theExecutorServiceassigned to this instance.ome.system.Principalprincipal()Returns aPrincipalrepresenting 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 aPrincipalrepresenting 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.Workinstance 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 theMapargument 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 thePrincipalargument is not null, then additionally, a login/logout sequence will be performed in a try/finally block.Executor.Workimplementation must be annotated withTransactionalin 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.USERcallContext- 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. AnyRuntimeExceptionwhich 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.SqlWorkwrapped with a transaction. SinceStatelessSessiondoes 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.SqlWorkinstance must be properly marked with anTransactionalannotation.- Parameters:
work- Non-null.- Returns:
- See above.
-
-