com.sun.xml.ws.api.pipe
public interface TG_FiberContextSwitchInterceptor
Fiber context switch.
Even though pipeline runs asynchronously, sometimes it's desirable
to bind some state to the current thread running a fiber. Such state
may include security subject (in terms of AccessController.doPrivileged(java.security.PrivilegedAction),
or a transaction.
This mechanism makes it possible to do such things, by allowing some code to be executed before and after a thread executes a fiber.
The design also encapsulates the entire fiber execution in a single
opaque method invocation TG_FiberContextSwitchInterceptor.Work.execute(P), allowing the use of
finally block.
| Modifier and Type | 接口 and 描述 |
|---|---|
static interface |
TG_FiberContextSwitchInterceptor.Work<R,P>
Abstraction of the execution that happens inside the interceptor.
|
| Modifier and Type | Method and 描述 |
|---|---|
<R,P> R |
execute(TG_Fiber f,
P p,
TG_FiberContextSwitchInterceptor.Work<R,P> work)
Allows the interception of the fiber execution.
|
<R,P> R execute(TG_Fiber f, P p, TG_FiberContextSwitchInterceptor.Work<R,P> work)
This method needs to be implemented like this:
<R,P> R execute( Fiber f, P p, Work<R,P> work ) {
// do some preparation work
...
try {
// invoke
return work.execute(p);
} finally {
// do some clean up work
...
}
}
While somewhat unintuitive,
this interception mechanism enables the interceptor to wrap
the whole fiber execution into a AccessController.doPrivileged(PrivilegedAction),
for example.
f - Fiber to be executed.p - The opaque parameter value for TG_FiberContextSwitchInterceptor.Work. Simply pass this value to
TG_FiberContextSwitchInterceptor.Work.execute(Object).TG_FiberContextSwitchInterceptor.Work. Simply return
the value from TG_FiberContextSwitchInterceptor.Work.execute(Object).Copyright © 2006–2015 TinyGroup. All rights reserved.