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>
advices
protected ome.system.OmeroContext
context
protected SessionFactory
factory
protected InternalServiceFactory
isf
protected CurrentDetails
principalHolder
protected java.lang.String[]
proxyNames
protected ThreadPool
service
protected ome.util.SqlAction
sqlAction
protected java.util.concurrent.ExecutorService
systemService
-
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> 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
in 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.void
setApplicationContext(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:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getContext
public ome.system.OmeroContext getContext()
Description copied from interface:Executor
Provides access to the context for Work-API consumers who need to publish events, etc.- Specified by:
getContext
in interfaceExecutor
-
principal
public ome.system.Principal principal()
Description copied from interface:Executor
Returns aPrincipal
representing 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.Work
instance 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 thePrincipal
argument 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:Executor
CallExecutor.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:Executor
Simple submission method which can be used in conjunction with a call toExecutor.execute(Principal, Work)
to overcome the no-multiple-login rule.- Specified by:
submit
in 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:Executor
Simple submission method with aExecutor.Priority
.- Specified by:
submit
in 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:Executor
LikeExecutor.submit(Map, Callable)
but provide info to which priority queue should be used.- Specified by:
submit
in interfaceExecutor
- 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
public <T> T get(java.util.concurrent.Future<T> future)
Description copied from interface:Executor
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
public java.util.concurrent.ExecutorService getService()
Description copied from interface:Executor
Returns theExecutorService
assigned to this instance. Used byExecutor.submit(Callable)
andExecutor.get(Future)
.- Specified by:
getService
in interfaceExecutor
-
executeSql
public java.lang.Object executeSql(Executor.SqlWork work)
Executes aExecutor.SqlWork
in transaction.- Specified by:
executeSql
in interfaceExecutor
- Parameters:
work
- Non-null.- Returns:
- See above.
-
-