You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2011/03/03 15:47:26 UTC
svn commit: r1076642 -
/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
Author: astitcher
Date: Thu Mar 3 14:47:26 2011
New Revision: 1076642
URL: http://svn.apache.org/viewvc?rev=1076642&view=rev
Log:
QPID-3108: Allow QueueSender queue to be unidentified and still use getters
- Change error checks so that don't throw an incorrect exception in getters
when the queue is null. This should only happen when sending.
Modified:
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java?rev=1076642&r1=1076641&r2=1076642&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java Thu Mar 3 14:47:26 2011
@@ -50,25 +50,25 @@ public class QueueSenderAdapter implemen
public void send(Message msg) throws JMSException
{
- checkPreConditions();
+ checkQueuePreConditions(_queue);
_delegate.send(msg);
}
public void send(Queue queue, Message msg) throws JMSException
{
- checkPreConditions(queue);
+ checkQueuePreConditions(queue);
_delegate.send(queue, msg);
}
public void publish(Message msg, int deliveryMode, int priority, long timeToLive) throws JMSException
{
- checkPreConditions();
+ checkQueuePreConditions(_queue);
_delegate.send(msg, deliveryMode, priority, timeToLive);
}
public void send(Queue queue, Message msg, int deliveryMode, int priority, long timeToLive) throws JMSException
{
- checkPreConditions(queue);
+ checkQueuePreConditions(queue);
_delegate.send(queue, msg, deliveryMode, priority, timeToLive);
}
@@ -122,19 +122,19 @@ public class QueueSenderAdapter implemen
public void send(Destination dest, Message msg) throws JMSException
{
- checkPreConditions((Queue) dest);
+ checkQueuePreConditions((Queue) dest);
_delegate.send(dest, msg);
}
public void send(Message msg, int deliveryMode, int priority, long timeToLive) throws JMSException
{
- checkPreConditions();
+ checkQueuePreConditions(_queue);
_delegate.send(msg, deliveryMode, priority, timeToLive);
}
public void send(Destination dest, Message msg, int deliveryMode, int priority, long timeToLive) throws JMSException
{
- checkPreConditions((Queue) dest);
+ checkQueuePreConditions((Queue) dest);
_delegate.send(dest, msg, deliveryMode, priority, timeToLive);
}
@@ -170,11 +170,6 @@ public class QueueSenderAdapter implemen
private void checkPreConditions() throws JMSException
{
- checkPreConditions(_queue);
- }
-
- private void checkPreConditions(Queue queue) throws JMSException
- {
if (closed)
{
throw new javax.jms.IllegalStateException("Publisher is closed");
@@ -186,39 +181,43 @@ public class QueueSenderAdapter implemen
{
throw new javax.jms.IllegalStateException("Invalid Session");
}
+ }
- if (queue == null)
- {
- throw new UnsupportedOperationException("Queue is null.");
- }
-
- if (!(queue instanceof AMQDestination))
- {
- throw new InvalidDestinationException("Queue: " + queue + " is not a valid Qpid queue");
- }
-
- AMQDestination destination = (AMQDestination) queue;
- if (!destination.isCheckedForQueueBinding() && checkQueueBeforePublish())
- {
-
- if (_delegate.getSession().isStrictAMQP())
- {
- _delegate._logger.warn("AMQP does not support destination validation before publish, ");
- destination.setCheckedForQueueBinding(true);
- }
- else
- {
- if (_delegate.isBound(destination))
- {
- destination.setCheckedForQueueBinding(true);
- }
- else
- {
- throw new InvalidDestinationException("Queue: " + queue
- + " is not a valid destination (no bindings on server");
- }
- }
- }
+ private void checkQueuePreConditions(Queue queue) throws JMSException
+ {
+ checkPreConditions() ;
+
+ if (queue == null)
+ {
+ throw new UnsupportedOperationException("Queue is null.");
+ }
+
+ if (!(queue instanceof AMQDestination))
+ {
+ throw new InvalidDestinationException("Queue: " + queue + " is not a valid Qpid queue");
+ }
+
+ AMQDestination destination = (AMQDestination) queue;
+ if (!destination.isCheckedForQueueBinding() && checkQueueBeforePublish())
+ {
+ if (_delegate.getSession().isStrictAMQP())
+ {
+ _delegate._logger.warn("AMQP does not support destination validation before publish, ");
+ destination.setCheckedForQueueBinding(true);
+ }
+ else
+ {
+ if (_delegate.isBound(destination))
+ {
+ destination.setCheckedForQueueBinding(true);
+ }
+ else
+ {
+ throw new InvalidDestinationException("Queue: " + queue
+ + " is not a valid destination (no bindings on server");
+ }
+ }
+ }
}
private boolean checkQueueBeforePublish()
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org