KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > connector > OutboundPublisher


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

23 package org.objectweb.joram.client.connector;
24
25 import javax.jms.JMSException JavaDoc;
26 import javax.jms.Message JavaDoc;
27 import javax.jms.MessageProducer JavaDoc;
28 import javax.jms.Topic JavaDoc;
29
30 import org.objectweb.util.monolog.api.BasicLevel;
31
32 /**
33  * An <code>OutboundPublisher</code> instance wraps a JMS producer
34  * for a component involved in PubSub outbound messaging.
35  */

36 public class OutboundPublisher extends OutboundProducer
37                                implements javax.jms.TopicPublisher JavaDoc
38 {
39   /**
40    * Constructs an <code>OutboundPublisher</code> instance.
41    *
42    * @param producer The JMS producer to wrap.
43    * @param session The OutboundSession the publisher belongs to.
44    */

45   OutboundPublisher(MessageProducer JavaDoc producer, OutboundSession session) {
46     super(producer, session);
47
48     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
49       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
50                                     "OutboundPublisher(" + producer +
51                                     ", " + session + ")");
52   }
53
54  
55   /** Delegates the call to the wrapped producer. */
56   public Topic JavaDoc getTopic() throws JMSException JavaDoc
57   {
58     checkValidity();
59     return (Topic JavaDoc) producer.getDestination();
60   }
61
62   /** Delegates the call to the wrapped producer. */
63   public void publish(Message JavaDoc message,
64                       int deliveryMode,
65                       int priority,
66                       long timeToLive)
67     throws JMSException JavaDoc {
68     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
69       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
70                                     this + " publish(" + message +
71                                     ", " + deliveryMode +
72                                     ", " + priority +
73                                     ", " + timeToLive + ")");
74
75     checkValidity();
76     producer.send(message, deliveryMode, priority, timeToLive);
77   }
78
79   /** Delegates the call to the wrapped producer. */
80   public void publish(Message JavaDoc message) throws JMSException JavaDoc {
81     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
82       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
83                                     this + " publish(" + message + ")");
84
85     checkValidity();
86     producer.send(message);
87   }
88
89   /** Delegates the call to the wrapped producer. */
90   public void publish(Topic JavaDoc topic,
91                       Message JavaDoc message,
92                       int deliveryMode,
93                       int priority,
94                       long timeToLive)
95     throws JMSException JavaDoc {
96     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
97       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
98                                     this + " publish(" + topic +
99                                     ", " + message +
100                                     ", " + deliveryMode +
101                                     ", " + priority +
102                                     ", " + timeToLive + ")");
103
104     checkValidity();
105     producer.send(topic, message, deliveryMode, priority, timeToLive);
106   }
107
108   /** Delegates the call to the wrapped producer. */
109   public void publish(Topic JavaDoc topic, Message JavaDoc message) throws JMSException JavaDoc {
110     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
111       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
112                                     this + " publish(" + topic +
113                                     ", " + message + ")");
114
115     checkValidity();
116     producer.send(topic, message);
117   }
118 }
119
Popular Tags