01: package com.mockrunner.mock.jms;
02:
03: import javax.jms.ConnectionConsumer;
04: import javax.jms.JMSException;
05: import javax.jms.ServerSessionPool;
06:
07: /**
08: * Mock implementation of JMS <code>ConnectionConsumer</code>.
09: */
10: public class MockConnectionConsumer implements ConnectionConsumer {
11: private MockConnection connection;
12: private ServerSessionPool sessionPool;
13: private boolean closed;
14:
15: public MockConnectionConsumer(MockConnection connection,
16: ServerSessionPool serverSessionPool) {
17: this .connection = connection;
18: closed = false;
19: sessionPool = serverSessionPool;
20: if (null == sessionPool) {
21: sessionPool = new MockServerSessionPool(connection);
22: }
23: }
24:
25: /**
26: * Returns if this connection consumer was closed.
27: * @return <code>true</code> if this connection consumer is closed
28: */
29: public boolean isClosed() {
30: return closed;
31: }
32:
33: public void setServerSessionPool(ServerSessionPool serverSessionPool) {
34: sessionPool = serverSessionPool;
35: }
36:
37: public ServerSessionPool getServerSessionPool() throws JMSException {
38: connection.throwJMSException();
39: return sessionPool;
40: }
41:
42: public void close() throws JMSException {
43: connection.throwJMSException();
44: closed = true;
45: }
46: }
|