01: package org.objectweb.celtix.bus.transports;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.objectweb.celtix.bindings.ResponseCallback;
07: import org.objectweb.celtix.context.InputStreamMessageContext;
08:
09: public class TestResponseCallback implements ResponseCallback {
10:
11: private List<InputStreamMessageContext> responseContexts = new ArrayList<InputStreamMessageContext>();
12:
13: public synchronized void dispatch(InputStreamMessageContext respCtx) {
14: responseContexts.add(respCtx);
15: notify();
16: }
17:
18: public synchronized InputStreamMessageContext waitForNextResponse() {
19: while (responseContexts.size() == 0) {
20: try {
21: wait();
22: } catch (InterruptedException ie) {
23: // ignore
24: }
25: }
26: return responseContexts.remove(0);
27: }
28:
29: }
|