KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > client > impl > TopicSession


1 package com.ubermq.jms.client.impl;
2
3 import javax.jms.*;
4
5 import com.ubermq.jms.common.datagram.*;
6 import com.ubermq.kernel.*;
7
8 /**
9  * The topic session is a core JMS abstraction representing a set of publishers
10  * and subscribers, running in their own thread, sharing a connection with
11  * zero or more other sessions. A session is a conceptual grouping of JMS
12  * participants.
13  * <P>
14  * The UberMQ implementation of the JMS TopicSession is fairly straightforward
15  * and delegates most JMS operations to the Client Processor or delivery manager.
16  */

17 final class TopicSession
18     extends Session
19     implements javax.jms.TopicSession JavaDoc
20 {
21     /**
22      * Creates a topic session as a child of the given
23      * topic connection, using a client processor, delivery manager,
24      * message datagram factory as indicated.
25      *
26      * @param conn the parent connection
27      * @param factory the message datagram creator
28      * @param ackMode the acknowledgement mode as specified by JMS
29      */

30     TopicSession(Connection conn,
31                  IMessageDatagramFactory factory,
32                  int ackMode)
33     {
34         super(conn, factory, ackMode);
35     }
36
37     public TopicSubscriber createSubscriber(Topic topic)
38         throws JMSException
39     {
40         return createSubscriber(topic, null, Session.DEFAULT_NO_LOCAL);
41     }
42
43     public TopicSubscriber createSubscriber(Topic topic,
44                                             java.lang.String JavaDoc messageSelector,
45                                             boolean noLocal)
46         throws JMSException
47     {
48         return (TopicSubscriber)createConsumer(topic, messageSelector, noLocal);
49     }
50
51     public TopicPublisher createPublisher(Topic topic)
52         throws JMSException
53     {
54         return new LocalTopicPublisher(topic);
55     }
56
57     /**
58      * My very own publisher implementation!
59      */

60     final private class LocalTopicPublisher
61         extends AbstractProducer
62         implements javax.jms.TopicPublisher JavaDoc, IDatagramEndpoint
63     {
64         /**
65          * Allocates a sender ID for this publisher and registers
66          * it with the connection.
67          */

68         private LocalTopicPublisher(Topic t)
69         {
70             super(t, TopicSession.this);
71         }
72
73         public Topic getTopic()
74             throws JMSException
75         {
76             return (Topic)getDestination();
77         }
78
79         public void publish(Message message)
80             throws JMSException
81         {
82             super.send(message);
83         }
84
85         public void publish(Message message,
86                             int deliveryMode,
87                             int priority,
88                             long timeToLive)
89             throws JMSException
90         {
91             super.send(message, deliveryMode, priority, timeToLive);
92         }
93
94         public void publish(Topic topic,
95                             Message message)
96             throws JMSException
97         {
98             super.send(topic, message);
99         }
100
101         public void publish(Topic topic,
102                             Message message,
103                             int deliveryMode,
104                             int priority,
105                             long timeToLive)
106             throws JMSException
107         {
108             super.send(topic,
109                        message,
110                        deliveryMode,
111                        priority,
112                        timeToLive);
113         }
114     }
115 }
116
Popular Tags