Package ome.services.util
Class Executor.Impl
- java.lang.Object
-
- ome.services.util.Executor.Impl
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ome.services.util.Executor
Executor.Descriptive, Executor.Impl, Executor.LoggedWork<X>, Executor.Priority, Executor.SimpleSqlWork, Executor.SimpleWork<T>, Executor.SqlWork, Executor.StatefulWork, Executor.Work<X>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<org.aopalliance.aop.Advice>advicesprotected ome.system.OmeroContextcontextprotected SessionFactoryfactoryprotected InternalServiceFactoryisfprotected CurrentDetailsprincipalHolderprotected java.lang.String[]proxyNamesprotected ThreadPoolserviceprotected ome.util.SqlActionsqlActionprotected java.util.concurrent.ExecutorServicesystemService
-
Constructor Summary
Constructors Constructor Description Impl(CurrentDetails principalHolder, SessionFactory factory, ome.util.SqlAction sqlAction, java.lang.String[] proxyNames)Impl(CurrentDetails principalHolder, SessionFactory factory, ome.util.SqlAction sqlAction, java.lang.String[] proxyNames, ThreadPool service)
-
Method Summary
All Methods Instance Methods Concrete 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.SqlWorkin 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.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)<T> java.util.concurrent.Future<T>submit(java.util.concurrent.Callable<T> callable)CallExecutor.submit(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 toExecutor.execute(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)LikeExecutor.submit(Map, Callable)but provide info to which priority queue should be used.
-
-
-
Field Detail
-
context
protected ome.system.OmeroContext context
-
isf
protected InternalServiceFactory isf
-
advices
protected final java.util.List<org.aopalliance.aop.Advice> advices
-
principalHolder
protected final CurrentDetails principalHolder
-
proxyNames
protected final java.lang.String[] proxyNames
-
factory
protected final SessionFactory factory
-
sqlAction
protected final ome.util.SqlAction sqlAction
-
service
protected final ThreadPool service
-
systemService
protected final java.util.concurrent.ExecutorService systemService
-
-
Constructor Detail
-
Impl
public Impl(CurrentDetails principalHolder, SessionFactory factory, ome.util.SqlAction sqlAction, java.lang.String[] proxyNames)
-
Impl
public Impl(CurrentDetails principalHolder, SessionFactory factory, ome.util.SqlAction sqlAction, java.lang.String[] proxyNames, ThreadPool service)
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getContext
public ome.system.OmeroContext getContext()
Description copied from interface:ExecutorProvides access to the context for Work-API consumers who need to publish events, etc.- Specified by:
getContextin interfaceExecutor
-
principal
public ome.system.Principal principal()
Description copied from interface:ExecutorReturns aPrincipalrepresenting your current session or null, if none is active.
-
execute
public <T> T execute(ome.system.Principal p, Executor.Work<T> work)Callexecute(Map, Principal, Work)with a null call context.
-
execute
public <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)for theOmeroContext, and the second performs all the standard service actions for any normal method call. If thePrincipalargument is not null, then additionally, a login/logout sequence will be performed in a try/finally block.
-
submit
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> callable)
Description copied from interface:ExecutorCallExecutor.submit(Map, Callable)with a null callContext.
-
submit
public <T> java.util.concurrent.Future<T> submit(java.util.Map<java.lang.String,java.lang.String> callContext, java.util.concurrent.Callable<T> callable)Description copied from interface:ExecutorSimple submission method which can be used in conjunction with a call toExecutor.execute(Principal, Work)to overcome the no-multiple-login rule.- Specified by:
submitin interfaceExecutor- Parameters:
callContext- Possibly null. SeeCurrentDetails.setContext(Map)callable- Not null. Action to be taken.- Returns:
- See above.
-
submit
public <T> java.util.concurrent.Future<T> submit(Executor.Priority prio, java.util.concurrent.Callable<T> callable)
Description copied from interface:ExecutorSimple submission method with aExecutor.Priority.- Specified by:
submitin interfaceExecutor- Parameters:
prio- Possibly null. SeeExecutor.submit(Priority, Map, Callable)callable- Not null. Action to be taken.- Returns:
- See above.
-
submit
public <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)
Description copied from interface:ExecutorLikeExecutor.submit(Map, Callable)but provide info to which priority queue should be used.- Specified by:
submitin interfaceExecutor- 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
public <T> T get(java.util.concurrent.Future<T> future)
Description copied from interface:ExecutorHelper 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
public java.util.concurrent.ExecutorService getService()
Description copied from interface:ExecutorReturns theExecutorServiceassigned to this instance. Used byExecutor.submit(Callable)andExecutor.get(Future).- Specified by:
getServicein interfaceExecutor
-
executeSql
public java.lang.Object executeSql(Executor.SqlWork work)
Executes aExecutor.SqlWorkin transaction.- Specified by:
executeSqlin interfaceExecutor- Parameters:
work- Non-null.- Returns:
- See above.
-
-