01: package com.mockrunner.mock.connector.cci;
02:
03: import javax.resource.ResourceException;
04: import javax.resource.cci.Connection;
05: import javax.resource.cci.Interaction;
06: import javax.resource.cci.InteractionSpec;
07: import javax.resource.cci.Record;
08: import javax.resource.cci.ResourceWarning;
09:
10: /**
11: * Mock implementation of <code>Interaction</code>.
12: * The <code>execute</code> calls are delegated to
13: * {@link com.mockrunner.connector.InteractionHandler}.
14: */
15: public class MockInteraction implements Interaction {
16: private MockConnection mockConnection;
17: private boolean closed;
18:
19: public MockInteraction(MockConnection mockConnection) {
20: this .mockConnection = mockConnection;
21: closed = false;
22: }
23:
24: public void clearWarnings() throws ResourceException {
25:
26: }
27:
28: public void close() throws ResourceException {
29: closed = true;
30: }
31:
32: /**
33: * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record)}.
34: */
35: public Record execute(InteractionSpec is, Record record)
36: throws ResourceException {
37: return mockConnection.getInteractionHandler().execute(is,
38: record);
39: }
40:
41: /**
42: * Calls {@link com.mockrunner.connector.InteractionHandler#execute(InteractionSpec, Record, Record)}.
43: */
44: public boolean execute(InteractionSpec is, Record request,
45: Record response) throws ResourceException {
46: return mockConnection.getInteractionHandler().execute(is,
47: request, response);
48: }
49:
50: public Connection getConnection() {
51: return mockConnection;
52: }
53:
54: /**
55: * Returns if this <code>Interaction</code> is closed.
56: * @return <code>true</code> if this <code>Interaction</code> is closed,
57: * <code>false</code> otherwise
58: */
59: public boolean isClosed() {
60: return closed;
61: }
62:
63: /**
64: * Returns <code>null</code>, warnings not supported yet.
65: */
66: public ResourceWarning getWarnings() throws ResourceException {
67: return null;
68: }
69: }
|