Interface ExecutionContext

All Known Implementing Classes:
SimpleExecutionContext

public interface ExecutionContext
The ExecutionContext is used as the place to put common things (objects, variables) into. The idea is that the objects are kept for the lifetime of the session. The ExecutionContext is usually bound to the current thread (DevCon may be an exception). Examples are the SecurityContext and the (persist) Context. You may create your own classes.

To put your own thing into the exec ctx do something along these lines:


 MyContext myCtx = exec().getContext(MyContext.class, new ContextFactory<MyContext>() {
     public MyContext create( ExecutionContext executionContext ) {
         return new MyContextImpl( some, constructor, params );
     }
 });
 
If you want your context automatically restored on every request (out of the Client) then do it like the BusinessUnit, look in the code.

As of now there is no key/value map for storing things (anymore). There was no need, and using string keys may cause uniqueness and typo problems. Class identifiers on the other hand may cause problems with multiple class loaders, and only one instance can be put into the ExecutionContext. Anyway, that's how it is now.

  • Method Details

    • getContext

      @Nullable <T> T getContext(Class<T> ctxClass)
      Returns the execution context for the given class, or null.
    • getContext

      <T> T getContext(Class<T> ctxClass, ContextFactory<T> factory)
      Returns the execution context for the given class, creates a new one using the factory if it's not in the execution context yet and puts it in.
    • requireContext

      <T> T requireContext(Class<T> ctxClass)
    • setContext

      <T> T setContext(Class<T> ctxClass, T ctx)
    • setContext

      <T> T setContext(ContextWrapper<T> wrapper)
    • removeContext

      <T> T removeContext(Class<T> ctxClass)
    • isEmpty

      boolean isEmpty()