KickJava   Java API By Example, From Geeks To Geeks.

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


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.Queue JavaDoc;
29
30 import org.objectweb.util.monolog.api.BasicLevel;
31
32 /**
33  * An <code>OutboundSender</code> instance wraps a JMS producer
34  * for a component involved in PTP outbound messaging.
35  */

36 public class OutboundSender extends OutboundProducer
37                             implements javax.jms.QueueSender JavaDoc
38 {
39   /**
40    * Constructs an <code>OutboundSender</code> instance.
41    */

42   OutboundSender(MessageProducer JavaDoc producer, OutboundSession session) {
43     super(producer, session);
44
45     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
46       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
47                                     "OutboundSender(" + producer +
48                                     ", " + session + ")");
49   }
50
51  
52   /** Delegates the call to the wrapped producer. */
53   public Queue JavaDoc getQueue() throws JMSException JavaDoc {
54     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
55       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
56                                     this + " getQueue() = " + producer.getDestination());
57
58     checkValidity();
59     return (Queue JavaDoc) producer.getDestination();
60   }
61
62   /** Delegates the call to the wrapped producer. */
63   public void send(Queue JavaDoc queue,
64                    Message JavaDoc message,
65                    int deliveryMode,
66                    int priority,
67                    long timeToLive)
68     throws JMSException JavaDoc {
69     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
70       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
71                                     this + " send(" + queue +
72                                     ", " + message +
73                                     ", " + deliveryMode +
74                                     ", " + priority +
75                                     ", " + timeToLive + ")");
76
77     checkValidity();
78     producer.send(queue, message, deliveryMode, priority, timeToLive);
79   }
80
81   /** Delegates the call to the wrapped producer. */
82   public void send(Queue JavaDoc queue, Message JavaDoc message)
83     throws JMSException JavaDoc {
84     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
85       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
86                                     this + " send(" + queue +
87                                     ", " + message + ")");
88
89     checkValidity();
90     producer.send(queue, message);
91   }
92 }
93
Popular Tags