001: package org.mockejb.jms;
002:
003: import javax.jms.*;
004: import org.mockejb.MethodNotImplementedException;
005:
006: /**
007: * <code>TopicSession</code> implementation.
008: * Only topics of type <code>MockTopic</code> are supported.
009: * @author Dimitar Gospodinov
010: */
011: class TopicSessionImpl extends MockSession implements TopicSession {
012:
013: /**
014: * Creates new topic session with the specified attributes.
015: * @param transacted
016: * @param acknowledgeMode
017: */
018: TopicSessionImpl(boolean transacted, int acknowledgeMode,
019: MockConnection connection) {
020: super (transacted, acknowledgeMode, connection);
021: }
022:
023: /**
024: * Not implemented.
025: * @see javax.jms.TopicSession#createTopic(java.lang.String)
026: */
027: public Topic createTopic(String topicName) throws JMSException {
028: throw new MethodNotImplementedException("createTopic",
029: "TopicSessionImpl");
030: }
031:
032: /**
033: * Creates subscriber for <code>topic</code>
034: * @see javax.jms.TopicSession#createSubscriber(javax.jms.Topic)
035: */
036: public TopicSubscriber createSubscriber(Topic topic)
037: throws JMSException {
038: return (TopicSubscriber) createConsumer(topic);
039: }
040:
041: /**
042: * Not implemented.
043: * @see javax.jms.TopicSession#createSubscriber(
044: * javax.jms.Topic, java.lang.String, boolean)
045: */
046: public TopicSubscriber createSubscriber(Topic topic,
047: String messageSelector, boolean noLocal)
048: throws JMSException {
049:
050: throw new MethodNotImplementedException("createSubscriber",
051: "TopicSessionImpl");
052: }
053:
054: /**
055: * Not implemented.
056: * @see javax.jms.TopicSession#createDurableSubscriber(
057: * javax.jms.Topic, java.lang.String)
058: */
059: public TopicSubscriber createDurableSubscriber(Topic topic,
060: String name) throws JMSException {
061:
062: throw new MethodNotImplementedException(
063: "createDurableSubscriber", "TopicSessionImpl");
064: }
065:
066: /**
067: * Not implemented.
068: * @see javax.jms.TopicSession#createDurableSubscriber(
069: * javax.jms.Topic, java.lang.String,
070: * java.lang.String, boolean)
071: */
072: public TopicSubscriber createDurableSubscriber(Topic topic,
073: String name, String messageSelector, boolean noLocal)
074: throws JMSException {
075:
076: throw new MethodNotImplementedException(
077: "createDurableSubscriber", "TopicSessionImpl");
078: }
079:
080: /**
081: * Creates topic publisher for <code>topic</code>.
082: * <code>topic</code> must be <code>MockTopic</code>.
083: * @return <code>TopicPublisher</code> for <code>topic</code>
084: * @throws InvalidDestinationException if <code>topic</code>
085: * is not instance of <code>MockTopic</code>
086: * @see javax.jms.TopicSession#createPublisher(javax.jms.Topic)
087: */
088: public TopicPublisher createPublisher(Topic topic)
089: throws JMSException {
090: checkClosed();
091: return (TopicPublisher) createProducer(topic);
092: }
093:
094: public TemporaryTopic createTemporaryTopic() throws JMSException {
095: throw new MethodNotImplementedException("createTemporaryTopic",
096: "TopicSessionImpl");
097: }
098:
099: public void unsubscribe(String name) throws JMSException {
100: throw new MethodNotImplementedException("unsubscribe",
101: "TopicSessionImpl");
102: }
103:
104: /**
105: * Throws <code>IllegalStateException</code>
106: */
107: public Queue createQueue(String queueName) throws JMSException {
108:
109: throw new javax.jms.IllegalStateException(
110: "Topic session can not create queue!");
111: }
112:
113: /**
114: * Throws <code>IllegalStateException</code>
115: */
116: public QueueBrowser createBrowser(Queue queue) throws JMSException {
117:
118: throw new javax.jms.IllegalStateException(
119: "Topic session can not create queue browser!");
120: }
121:
122: /**
123: * Throws <code>IllegalStateException</code>
124: */
125: public QueueBrowser createBrowser(Queue queue,
126: String messageSelector) throws JMSException {
127:
128: throw new javax.jms.IllegalStateException(
129: "Topic session can not create queue browser!");
130: }
131:
132: /**
133: * Throws <code>IllegalStateException</code>
134: */
135: public TemporaryQueue createTemporaryQueue() throws JMSException {
136: throw new javax.jms.IllegalStateException(
137: "Topic session can not create temporary queue!");
138: }
139:
140: // Non-standard methods
141:
142: MockConsumer createMockConsumer(MockDestination destination)
143: throws JMSException {
144: if (destination instanceof MockTopic) {
145: return new TopicSubscriberImpl(this ,
146: (MockTopic) destination);
147: }
148: throw new InvalidDestinationException(
149: "Invalid topic specified!");
150: }
151:
152: MockProducer createMockProducer(MockDestination destination)
153: throws JMSException {
154: if (destination instanceof MockTopic) {
155: return new TopicPublisherImpl((MockTopic) destination);
156: }
157: throw new InvalidDestinationException(
158: "Invalid topic specified!");
159: }
160:
161: }
|