This class takes care of the logic that allows code to obtain {@link UnmarshallingContext} and {@link XMLSerializer} instancesduring the unmarshalling/marshalling.
This is done by using a {@link ThreadLocal}. Therefore one unmarshalling/marshalling episode has to be done from the beginning till end by the same thread. (Note that the same {@link Coordinator} can be then used by a different threadfor an entirely different episode.) This class also maintains the user-configured instances of {@link XmlAdapter}s.
This class implements {@link ErrorHandler} and propages erros to this objectas the {@link ValidationEventHandler}, which will be implemented in a derived class. @author Kohsuke Kawaguchi
This class takes care of the logic that allows code to obtain {@link UnmarshallingContext} and {@link XMLSerializer} instancesduring the unmarshalling/marshalling.
This is done by using a {@link ThreadLocal}. Therefore one unmarshalling/marshalling episode has to be done from the beginning till end by the same thread. (Note that the same {@link Coordinator} can be then used by a different threadfor an entirely different episode.) This class also maintains the user-configured instances of {@link XmlAdapter}s.
This class implements {@link ErrorHandler} and propages erros to this objectas the {@link ValidationEventHandler}, which will be implemented in a derived class. @author Kohsuke Kawaguchi
A bundle can use the Coordinator service to create {@link Coordination}objects. Once a Coordination object is created, it can be {@link Coordination#push() pushed} on the thread local Coordination stack tobe an implicit parameter as the current Coordination for calls to other parties, or it can be passed directly to other parties as an argument. The current Coordination, which is on the top of the current thread's thread local Coordination stack, can be obtained with {@link #peek()}.
Any active Coordinations created by a bundle must be terminated when the bundle releases the Coordinator service. The Coordinator service must {@link Coordination#fail(Throwable) fail} these Coordinations with the{@link Coordination#RELEASED RELEASED} exception.
A {@link Participant} can {@link Coordination#addParticipant(Participant) register} to participate in a Coordination and receive notification of thetermination of the Coordination.
The following example code shows a example usage of the Coordinator service.
void foo() { Coordination c = coordinator.begin("work", 0); try { doWork(); } catch (Exception e) { c.fail(e); } finally { c.end(); } }In the {@code doWork} method, code can be called that requires notificationof the termination of the Coordination. The {@code doWork} method can thenregister a Participant with the Coordination.
void doWork() { if (coordinator.addParticipant(this)) { beginWork(); } else { beginWork(); finishWork(); } } void ended(Coordination c) { finishWork(); } void failed(Coordination c) { undoWork(); }@ThreadSafe @noimplement @author $Id: e2e1850c645234dd7a546a2f6a77ba6fc8d3c73b $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|