ome.services.util
Interface Executor

All Superinterfaces:
org.springframework.context.ApplicationContextAware
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. The 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.

Since:
3.0-Beta3
Author:
Josh Moore, josh at glencoesoftware.com

Nested Class Summary
static class Executor.Descriptive
           
static class Executor.Impl
           
static class Executor.SimpleStatelessWork
          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.StatelessWork
          Work SPI to perform actions related to stateless sessions.
static interface Executor.Work
          Work SPI to perform actions within the server as if they were fully wrapped in our service logic.
 
Method Summary
 Object execute(Principal p, Executor.Work work)
          Executes a Executor.Work instance wrapped in two layers of AOP.
 Object executeStateless(Executor.StatelessWork work)
          Executes a Executor.StatelessWork 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.
 Principal principal()
          Returns a Principal representing your current session or null, if none is active.
 void resetCallGroup()
          Delegates to CurrentDetails.resetCallGroup().
 void setCallGroup(long gid)
          Delegates to CurrentDetails.setCallGroup(Long) to permit thread-specific setting of the group.
<T> Future<T>
submit(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.
 
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
 

Method Detail

getContext

OmeroContext getContext()
Provides access to the context for Work-API consumers who need to publish events, etc.


principal

Principal principal()
Returns a Principal representing your current session or null, if none is active.


setCallGroup

void setCallGroup(long gid)
Delegates to CurrentDetails.setCallGroup(Long) to permit thread-specific setting of the group.

Parameters:
gid -
See Also:
ticket:1434

resetCallGroup

void resetCallGroup()
Delegates to CurrentDetails.resetCallGroup().

See Also:
setCallGroup(long), ticket:1434

execute

Object execute(Principal p,
               Executor.Work work)
Executes a 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 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.

Parameters:
p - Possibly null.
work - Not null.

submit

<T> Future<T> submit(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.


get

<T> T get(Future<T> future)
Helper method to perform 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.


executeStateless

Object executeStateless(Executor.StatelessWork work)
Executes a Executor.StatelessWork 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.StatelessWork instance must be properly marked with an Transactional annotation.

Parameters:
work - Non-null.
Returns:


OmeroJava Api

Version: Beta-4.2.0-r7571-b29

Copyright © 2009 The University of Dundee. All Rights Reserved.