< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/pipe/FiberContextSwitchInterceptor.java

Print this page




  27 
  28 import java.security.AccessController;
  29 import java.security.PrivilegedAction;
  30 
  31 /**
  32  * Interception for {@link Fiber} context switch.
  33  *
  34  * <p>
  35  * Even though pipeline runs asynchronously, sometimes it's desirable
  36  * to bind some state to the current thread running a fiber. Such state
  37  * may include security subject (in terms of {@link AccessController#doPrivileged}),
  38  * or a transaction.
  39  *
  40  * <p>
  41  * This mechanism makes it possible to do such things, by allowing
  42  * some code to be executed before and after a thread executes a fiber.
  43  *
  44  * <p>
  45  * The design also encapsulates the entire fiber execution in a single
  46  * opaque method invocation {@link Work#execute}, allowing the use of
  47  * <tt>finally</tt> block.
  48  *
  49  *
  50  * @author Kohsuke Kawaguchi
  51  */
  52 public interface FiberContextSwitchInterceptor {
  53     /**
  54      * Allows the interception of the fiber execution.
  55      *
  56      * <p>
  57      * This method needs to be implemented like this:
  58      *
  59      * <pre>
  60      * &lt;R,P> R execute( Fiber f, P p, Work&lt;R,P> work ) {
  61      *   // do some preparation work
  62      *   ...
  63      *   try {
  64      *     // invoke
  65      *     return work.execute(p);
  66      *   } finally {
  67      *     // do some clean up work




  27 
  28 import java.security.AccessController;
  29 import java.security.PrivilegedAction;
  30 
  31 /**
  32  * Interception for {@link Fiber} context switch.
  33  *
  34  * <p>
  35  * Even though pipeline runs asynchronously, sometimes it's desirable
  36  * to bind some state to the current thread running a fiber. Such state
  37  * may include security subject (in terms of {@link AccessController#doPrivileged}),
  38  * or a transaction.
  39  *
  40  * <p>
  41  * This mechanism makes it possible to do such things, by allowing
  42  * some code to be executed before and after a thread executes a fiber.
  43  *
  44  * <p>
  45  * The design also encapsulates the entire fiber execution in a single
  46  * opaque method invocation {@link Work#execute}, allowing the use of
  47  * {@code finally} block.
  48  *
  49  *
  50  * @author Kohsuke Kawaguchi
  51  */
  52 public interface FiberContextSwitchInterceptor {
  53     /**
  54      * Allows the interception of the fiber execution.
  55      *
  56      * <p>
  57      * This method needs to be implemented like this:
  58      *
  59      * <pre>
  60      * &lt;R,P> R execute( Fiber f, P p, Work&lt;R,P> work ) {
  61      *   // do some preparation work
  62      *   ...
  63      *   try {
  64      *     // invoke
  65      *     return work.execute(p);
  66      *   } finally {
  67      *     // do some clean up work


< prev index next >