KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > TopicPublisher


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s): Nicolas Tachker (ScalAgent)
23  */

24 package com.scalagent.kjoram;
25
26 import com.scalagent.kjoram.excepts.IllegalStateException;
27 import com.scalagent.kjoram.excepts.JMSException;
28
29 public class TopicPublisher extends MessageProducer
30 {
31   /**
32    * Constructs a publisher.
33    *
34    * @param sess The session the publisher belongs to.
35    * @param topic The topic the publisher publishs messages on.
36    *
37    * @exception IllegalStateException If the connection is broken.
38    * @exception JMSException If the creation fails for any other reason.
39    */

40   TopicPublisher(TopicSession sess, Topic topic) throws JMSException
41   {
42     super(sess, topic);
43   }
44
45   /** Returns a string view of this receiver. */
46   public String JavaDoc toString()
47   {
48     return "TopicPub:" + sess.ident;
49   }
50
51   /**
52    * API method.
53    *
54    * @exception IllegalStateException If the publisher is closed.
55    */

56   public Topic getTopic() throws JMSException
57   {
58     if (closed)
59       throw new IllegalStateException JavaDoc("Forbidden call on a closed publisher.");
60
61     return (Topic) super.dest;
62   }
63
64   /**
65    * API method.
66    *
67    * @exception IllegalStateException If the publisher is closed, or if the
68    * connection is broken.
69    * @exception JMSException If the request fails for any other reason.
70    */

71   public void publish(Message message, int deliveryMode,
72                       int priority, long timeToLive) throws JMSException
73   {
74     super.send(message, deliveryMode, priority, timeToLive);
75   }
76     
77   /**
78    * API method.
79    *
80    * @exception IllegalStateException If the publisher is closed, or if the
81    * connection is broken.
82    * @exception JMSException If the request fails for any other reason.
83    */

84   public void publish(Message message) throws JMSException
85   {
86     super.send(message);
87   }
88
89   /**
90    * API method.
91    *
92    * @exception IllegalStateException If the publisher is closed, or if the
93    * connection is broken.
94    * @exception JMSException If the request fails for any other reason.
95    */

96   public void publish(Topic topic, Message message)
97             throws JMSException
98   {
99     super.send(topic, message);
100   }
101
102   /**
103    * API method.
104    *
105    * @exception IllegalStateException If the publisher is closed, or if the
106    * connection is broken.
107    * @exception JMSException If the request fails for any other reason.
108    */

109   public void publish(Topic topic, Message message,
110                       int deliveryMode, int priority,
111                       long timeToLive) throws JMSException
112   {
113     super.send(topic, message, deliveryMode, priority, timeToLive);
114   }
115 }
116
Popular Tags