KickJava   Java API By Example, From Geeks To Geeks.

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


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.MessageConsumer JavaDoc;
27 import javax.jms.Queue JavaDoc;
28 import javax.jms.JMSSecurityException JavaDoc;
29
30 import org.objectweb.joram.client.jms.TemporaryQueue;
31 import javax.jms.Connection JavaDoc;
32
33 import org.objectweb.util.monolog.api.BasicLevel;
34
35 /**
36  * An <code>OutboundReceiver</code> instance wraps a JMS PTP consumer
37  * for a component involved in outbound messaging.
38  */

39 public class OutboundReceiver extends OutboundConsumer
40                               implements javax.jms.QueueReceiver JavaDoc
41 {
42   /** Queue instance to consume messages from. */
43   private Queue JavaDoc queue;
44
45
46   /**
47    * Constructs an <code>OutboundReceiver</code> instance.
48    */

49   OutboundReceiver(Queue JavaDoc queue,
50                    MessageConsumer JavaDoc consumer,
51                    OutboundSession session)
52     throws JMSException JavaDoc {
53     super(consumer, session);
54     this.queue = queue;
55     
56     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
57       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
58                                     "OutboundReceiver(" + queue +
59                                     ", " + consumer +
60                                     ", " + session + ")");
61     
62     if (queue instanceof TemporaryQueue) {
63       Connection JavaDoc tempQCnx = ((TemporaryQueue) queue).getCnx();
64
65       if (tempQCnx == null || !session.cnx.cnxEquals(tempQCnx))
66         throw new JMSSecurityException JavaDoc("Forbidden consumer on this "
67                                        + "temporary destination.");
68     }
69   }
70
71
72   /** Returns the consumer's queue. */
73   public Queue JavaDoc getQueue() throws JMSException JavaDoc {
74     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
75       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " getQueue() = " + queue);
76
77     checkValidity();
78     return queue;
79   }
80 }
81
Popular Tags