summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-08 17:02:26 +0000
committerRobert Greig <rgreig@apache.org>2007-01-08 17:02:26 +0000
commitd6b4e65f3fd1ff4a2763f8068cd6b3f7fe0b84e0 (patch)
treef0c608bcb9e4e5af6cd7ca5245401d2d1716b4f3
parent61350c8523e2edca63d8a9ab2c970ad8607d4c0a (diff)
downloadqpid-python-d6b4e65f3fd1ff4a2763f8068cd6b3f7fe0b84e0.tar.gz
QPID-255 : Patch Supplied by Rob Godfrey - Change to use bespoke AMQShortString rather than converting to String
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@494121 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--gentools/src/org/apache/qpid/gentools/JavaGenerator.java4
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java13
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java23
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java11
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java12
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java9
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java29
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java27
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java15
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java9
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java12
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/exchange/Index.java15
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java29
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java11
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java9
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java7
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java23
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java10
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/message/jms/JMSMessage.java42
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java17
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java8
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java33
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentDeliveryManager.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentSelectorDeliveryManager.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java7
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/DeliveryManager.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java9
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionFactory.java5
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java23
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/SynchronizedDeliveryManager.java3
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/WeakReferenceMessageHandle.java4
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationManager.java2
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/security/auth/NullAuthenticationManager.java1
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/security/auth/SASLAuthenticationManager.java1
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/security/auth/amqplain/AmqPlainSaslServer.java4
-rw-r--r--java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java120
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQConnection.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQDestination.java242
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQHeadersExchange.java10
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQQueue.java44
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java151
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java4
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQTopic.java16
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java37
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java96
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java (renamed from java/client/src/main/java/org/apache/qpid/client/CustomJMXProperty.java)21
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java7
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java5
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java11
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java17
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java9
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java4
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java98
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java16
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java11
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java8
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java12
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java8
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java23
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java16
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java77
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java12
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java4
-rw-r--r--java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java17
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java16
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java16
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java17
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java9
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java2
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java9
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java13
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/message/JMSDestinationTest.java3
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java4
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java12
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/ClusterCapability.java16
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/DefaultGroupManager.java10
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/MemberHandle.java4
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/MinaBrokerProxy.java2
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleMemberHandle.java13
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChannelQueueManager.java14
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ClusterMethodHandlerFactory.java31
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/LocalQueueDeclareHandler.java7
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ConsumerCounts.java11
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ReplayStore.java42
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/queue/ClusteredQueue.java7
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java5
-rw-r--r--java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteQueueProxy.java5
-rw-r--r--java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java5
-rw-r--r--java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java3
-rw-r--r--java/common/src/main/java/org/apache/qpid/AMQChannelException.java3
-rw-r--r--java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java8
-rw-r--r--java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java14
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java334
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java614
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/ContentBody.java9
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java237
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/FieldTable.java516
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java453
-rw-r--r--java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java8
-rw-r--r--java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java59
-rw-r--r--java/common/src/main/java/org/apache/qpid/url/BindingURL.java22
-rw-r--r--java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java1016
-rw-r--r--java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java54
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java25
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java10
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java24
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java5
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java23
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java5
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java3
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java14
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java5
-rw-r--r--java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java3
129 files changed, 2736 insertions, 2589 deletions
diff --git a/gentools/src/org/apache/qpid/gentools/JavaGenerator.java b/gentools/src/org/apache/qpid/gentools/JavaGenerator.java
index e4d7ae0e78..a18338f3fe 100644
--- a/gentools/src/org/apache/qpid/gentools/JavaGenerator.java
+++ b/gentools/src/org/apache/qpid/gentools/JavaGenerator.java
@@ -320,10 +320,10 @@ public class JavaGenerator extends Generator
"EncodingUtils.writeUnsignedShort(buffer, #)", // encode expression
"# = buffer.getUnsignedShort()")); // decode expression
typeMap.put("shortstr", new DomainInfo(
- "String", // Java code type
+ "AMQShortString", // Java code type
"EncodingUtils.encodedShortStringLength(#)", // size
"EncodingUtils.writeShortStringBytes(buffer, #)", // encode expression
- "# = EncodingUtils.readShortString(buffer)")); // decode expression
+ "# = EncodingUtils.readAMQShortString(buffer)")); // decode expression
typeMap.put("table", new DomainInfo(
"FieldTable", // Java code type
"EncodingUtils.encodedFieldTableLength(#)", // size
diff --git a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
index 509f57be7f..d7326b4c64 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
@@ -31,6 +31,7 @@ import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import javax.management.JMException;
import javax.management.MBeanException;
@@ -81,10 +82,10 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr
{
synchronized (_exchangeRegistry)
{
- Exchange exchange = _exchangeRegistry.getExchange(exchangeName);
+ Exchange exchange = _exchangeRegistry.getExchange(new AMQShortString(exchangeName));
if (exchange == null)
{
- exchange = _exchangeFactory.createExchange(exchangeName, type, durable, autoDelete, 0);
+ exchange = _exchangeFactory.createExchange(new AMQShortString(exchangeName), new AMQShortString(type), durable, autoDelete, 0);
_exchangeRegistry.registerExchange(exchange);
}
else
@@ -114,7 +115,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr
// when there are no bindings.
try
{
- _exchangeRegistry.unregisterExchange(exchangeName, false);
+ _exchangeRegistry.unregisterExchange(new AMQShortString(exchangeName), false);
}
catch (AMQException ex)
{
@@ -135,7 +136,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr
public void createNewQueue(String queueName, boolean durable, String owner, boolean autoDelete)
throws JMException
{
- AMQQueue queue = _queueRegistry.getQueue(queueName);
+ AMQQueue queue = _queueRegistry.getQueue(new AMQShortString(queueName));
if (queue != null)
{
throw new JMException("The queue \"" + queueName + "\" already exists.");
@@ -143,7 +144,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr
try
{
- queue = new AMQQueue(queueName, durable, owner, autoDelete, _queueRegistry);
+ queue = new AMQQueue(new AMQShortString(queueName), durable, new AMQShortString(owner), autoDelete, _queueRegistry);
if (queue.isDurable() && !queue.isAutoDelete())
{
_messageStore.createQueue(queue);
@@ -164,7 +165,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr
*/
public void deleteQueue(String queueName) throws JMException
{
- AMQQueue queue = _queueRegistry.getQueue(queueName);
+ AMQQueue queue = _queueRegistry.getQueue(new AMQShortString(queueName));
if (queue == null)
{
throw new JMException("The Queue " + queueName + " is not a registerd queue.");
diff --git a/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java b/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
index 999eb9f651..799b085fb2 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/AMQChannel.java
@@ -22,10 +22,7 @@ package org.apache.qpid.server;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.BasicPublishBody;
-import org.apache.qpid.framing.ContentBody;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.*;
import org.apache.qpid.server.ack.UnacknowledgedMessage;
import org.apache.qpid.server.ack.UnacknowledgedMessageMap;
import org.apache.qpid.server.ack.UnacknowledgedMessageMapImpl;
@@ -88,7 +85,7 @@ public class AMQChannel
/**
* Maps from consumer tag to queue instance. Allows us to unsubscribe from a queue.
*/
- private final Map<String, AMQQueue> _consumerTag2QueueMap = new TreeMap<String, AMQQueue>();
+ private final Map<AMQShortString, AMQQueue> _consumerTag2QueueMap = new HashMap<AMQShortString, AMQQueue>();
private final MessageStore _messageStore;
@@ -270,12 +267,12 @@ public class AMQChannel
* @throws ConsumerTagNotUniqueException if the tag is not unique
* @throws AMQException if something goes wrong
*/
- public String subscribeToQueue(String tag, AMQQueue queue, AMQProtocolSession session, boolean acks,
+ public AMQShortString subscribeToQueue(AMQShortString tag, AMQQueue queue, AMQProtocolSession session, boolean acks,
FieldTable filters, boolean noLocal) throws AMQException, ConsumerTagNotUniqueException
{
if (tag == null)
{
- tag = "sgen_" + getNextConsumerTag();
+ tag = new AMQShortString("sgen_" + getNextConsumerTag());
}
if (_consumerTag2QueueMap.containsKey(tag))
{
@@ -288,7 +285,7 @@ public class AMQChannel
}
- public void unsubscribeConsumer(AMQProtocolSession session, String consumerTag) throws AMQException
+ public void unsubscribeConsumer(AMQProtocolSession session, AMQShortString consumerTag) throws AMQException
{
AMQQueue q = _consumerTag2QueueMap.remove(consumerTag);
if (q != null)
@@ -312,7 +309,7 @@ public class AMQChannel
private void unsubscribeAllConsumers(AMQProtocolSession session) throws AMQException
{
_log.info("Unsubscribing all consumers on channel " + toString());
- for (Map.Entry<String, AMQQueue> me : _consumerTag2QueueMap.entrySet())
+ for (Map.Entry<AMQShortString, AMQQueue> me : _consumerTag2QueueMap.entrySet())
{
me.getValue().unregisterProtocolSession(session, _channelId, me.getKey());
}
@@ -327,7 +324,7 @@ public class AMQChannel
* the delivery tag)
* @param queue the queue from which the message was delivered
*/
- public void addUnacknowledgedMessage(AMQMessage message, long deliveryTag, String consumerTag, AMQQueue queue)
+ public void addUnacknowledgedMessage(AMQMessage message, long deliveryTag, AMQShortString consumerTag, AMQQueue queue)
{
_unacknowledgedMessageMap.add(deliveryTag, new UnacknowledgedMessage(queue, message, consumerTag, deliveryTag));
checkSuspension();
@@ -362,7 +359,7 @@ public class AMQChannel
public boolean callback(UnacknowledgedMessage message) throws AMQException
{
long deliveryTag = message.deliveryTag;
- String consumerTag = message.consumerTag;
+ AMQShortString consumerTag = message.consumerTag;
AMQMessage msg = message.message;
msg.setRedelivered(true);
msg.writeDeliver(session, _channelId, deliveryTag, consumerTag);
@@ -437,7 +434,7 @@ public class AMQChannel
return _unacknowledgedMessageMap;
}
- public void addUnacknowledgedBrowsedMessage(AMQMessage msg, long deliveryTag, String consumerTag, AMQQueue queue)
+ public void addUnacknowledgedBrowsedMessage(AMQMessage msg, long deliveryTag, AMQShortString consumerTag, AMQQueue queue)
{
_browsedAcks.add(deliveryTag);
addUnacknowledgedMessage(msg, deliveryTag, consumerTag, queue);
@@ -524,7 +521,7 @@ public class AMQChannel
for (RequiredDeliveryException bouncedMessage : _returnMessages)
{
AMQMessage message = bouncedMessage.getAMQMessage();
- message.writeReturn(session, _channelId, bouncedMessage.getReplyCode(), bouncedMessage.getMessage());
+ message.writeReturn(session, _channelId, bouncedMessage.getReplyCode(), new AMQShortString(bouncedMessage.getMessage()));
}
_returnMessages.clear();
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java b/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java
index 26f41e19af..ac390718c6 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessage.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.ack;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.store.StoreContext;
@@ -28,11 +29,11 @@ import org.apache.qpid.server.store.StoreContext;
public class UnacknowledgedMessage
{
public final AMQMessage message;
- public final String consumerTag;
+ public final AMQShortString consumerTag;
public final long deliveryTag;
public AMQQueue queue;
- public UnacknowledgedMessage(AMQQueue queue, AMQMessage message, String consumerTag, long deliveryTag)
+ public UnacknowledgedMessage(AMQQueue queue, AMQMessage message, AMQShortString consumerTag, long deliveryTag)
{
this.queue = queue;
this.message = message;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java b/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
index 1f4333549a..0677494134 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/ack/UnacknowledgedMessageMapImpl.java
@@ -24,6 +24,7 @@ import org.apache.qpid.server.queue.AMQMessage;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.txn.TransactionalContext;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import java.util.*;
@@ -180,7 +181,7 @@ public class UnacknowledgedMessageMapImpl implements UnacknowledgedMessageMap
for (Map.Entry<Long, UnacknowledgedMessage> entry : _map.entrySet())
{
long deliveryTag = entry.getKey();
- String consumerTag = entry.getValue().consumerTag;
+ AMQShortString consumerTag = entry.getValue().consumerTag;
AMQMessage msg = entry.getValue().message;
msg.writeDeliver(protocolSession, channelId, deliveryTag, consumerTag);
diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
index 9ecbf3d31a..7e807304c8 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
@@ -29,6 +29,7 @@ import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.log4j.Logger;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
@@ -157,7 +158,7 @@ public class VirtualHostConfiguration
private void bind(AMQBindingURL binding) throws AMQException, ConfigurationException
{
- String queueName = binding.getQueueName();
+ AMQShortString queueName = binding.getQueueName();
// This will occur if the URL is a Topic
if (queueName == null)
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
index d5ca567308..94c792c358 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.management.AMQManagedObject;
import org.apache.qpid.server.management.Managable;
import org.apache.qpid.server.management.ManagedObject;
@@ -31,7 +32,7 @@ import javax.management.ObjectName;
public abstract class AbstractExchange implements Exchange, Managable
{
- private String _name;
+ private AMQShortString _name;
protected boolean _durable;
protected String _exchangeType;
@@ -58,12 +59,12 @@ public abstract class AbstractExchange implements Exchange, Managable
public String getObjectInstanceName()
{
- return _name;
+ return _name.toString();
}
public String getName()
{
- return _name;
+ return _name.toString();
}
public String getExchangeType()
@@ -95,7 +96,7 @@ public abstract class AbstractExchange implements Exchange, Managable
} // End of MBean class
- public String getName()
+ public AMQShortString getName()
{
return _name;
}
@@ -107,7 +108,7 @@ public abstract class AbstractExchange implements Exchange, Managable
*/
protected abstract ExchangeMBean createMBean() throws AMQException;
- public void initialise(String name, boolean durable, int ticket, boolean autoDelete) throws AMQException
+ public void initialise(AMQShortString name, boolean durable, int ticket, boolean autoDelete) throws AMQException
{
_name = name;
_durable = durable;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
index 0c73e0f9f0..222cd2aef2 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
@@ -22,6 +22,8 @@ package org.apache.qpid.server.exchange;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import java.util.HashMap;
import java.util.Map;
@@ -30,16 +32,16 @@ public class DefaultExchangeFactory implements ExchangeFactory
{
private static final Logger _logger = Logger.getLogger(DefaultExchangeFactory.class);
- private Map<String, Class<? extends Exchange>> _exchangeClassMap = new HashMap<String, Class<? extends Exchange>>();
+ private Map<AMQShortString, Class<? extends Exchange>> _exchangeClassMap = new HashMap<AMQShortString, Class<? extends Exchange>>();
public DefaultExchangeFactory()
{
- _exchangeClassMap.put("direct", org.apache.qpid.server.exchange.DestNameExchange.class);
- _exchangeClassMap.put("topic", org.apache.qpid.server.exchange.DestWildExchange.class);
- _exchangeClassMap.put("headers", org.apache.qpid.server.exchange.HeadersExchange.class);
+ _exchangeClassMap.put(ExchangeDefaults.DIRECT_EXCHANGE_CLASS, org.apache.qpid.server.exchange.DestNameExchange.class);
+ _exchangeClassMap.put(ExchangeDefaults.TOPIC_EXCHANGE_CLASS, org.apache.qpid.server.exchange.DestWildExchange.class);
+ _exchangeClassMap.put(ExchangeDefaults.HEADERS_EXCHANGE_CLASS, org.apache.qpid.server.exchange.HeadersExchange.class);
}
- public Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete,
+ public Exchange createExchange(AMQShortString exchange, AMQShortString type, boolean durable, boolean autoDelete,
int ticket)
throws AMQException
{
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
index 99c08ad200..cadcd22001 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.exchange;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.protocol.ExchangeInitialiser;
import org.apache.qpid.server.queue.AMQMessage;
@@ -35,7 +36,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
/**
* Maps from exchange name to exchange instance
*/
- private ConcurrentMap<String, Exchange> _exchangeMap = new ConcurrentHashMap<String, Exchange>();
+ private ConcurrentMap<AMQShortString, Exchange> _exchangeMap = new ConcurrentHashMap<AMQShortString, Exchange>();
public DefaultExchangeRegistry(ExchangeFactory exchangeFactory)
{
@@ -55,7 +56,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
_exchangeMap.put(exchange.getName(), exchange);
}
- public void unregisterExchange(String name, boolean inUse) throws AMQException
+ public void unregisterExchange(AMQShortString name, boolean inUse) throws AMQException
{
// TODO: check inUse argument
Exchange e = _exchangeMap.remove(name);
@@ -69,7 +70,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
}
}
- public Exchange getExchange(String name)
+ public Exchange getExchange(AMQShortString name)
{
return _exchangeMap.get(name);
}
@@ -81,7 +82,7 @@ public class DefaultExchangeRegistry implements ExchangeRegistry
*/
public void routeContent(AMQMessage payload) throws AMQException
{
- final String exchange = payload.getPublishBody().exchange;
+ final AMQShortString exchange = payload.getPublishBody().exchange;
final Exchange exch = _exchangeMap.get(exchange);
// there is a small window of opportunity for the exchange to be deleted in between
// the BasicPublish being received (where the exchange is validated) and the final
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
index 7b28161263..dc65297615 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestNameExchange.java
@@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicPublishBody;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.management.MBeanConstructor;
import org.apache.qpid.server.management.MBeanDescription;
import org.apache.qpid.server.queue.AMQMessage;
@@ -83,21 +84,21 @@ public class DestNameExchange extends AbstractExchange
public TabularData bindings() throws OpenDataException
{
- Map<String, List<AMQQueue>> bindings = _index.getBindingsMap();
+ Map<AMQShortString, List<AMQQueue>> bindings = _index.getBindingsMap();
_bindingList = new TabularDataSupport(_bindinglistDataType);
- for (Map.Entry<String, List<AMQQueue>> entry : bindings.entrySet())
+ for (Map.Entry<AMQShortString, List<AMQQueue>> entry : bindings.entrySet())
{
- String key = entry.getKey();
+ AMQShortString key = entry.getKey();
List<String> queueList = new ArrayList<String>();
List<AMQQueue> queues = entry.getValue();
for (AMQQueue q : queues)
{
- queueList.add(q.getName());
+ queueList.add(q.getName().toString());
}
- Object[] bindingItemValues = {key, queueList.toArray(new String[0])};
+ Object[] bindingItemValues = {key.toString(), queueList.toArray(new String[0])};
CompositeData bindingData = new CompositeDataSupport(_bindingDataType, _bindingItemNames, bindingItemValues);
_bindingList.put(bindingData);
}
@@ -107,7 +108,7 @@ public class DestNameExchange extends AbstractExchange
public void createNewBinding(String queueName, String binding) throws JMException
{
- AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(queueName);
+ AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(new AMQShortString(queueName));
if (queue == null)
{
throw new JMException("Queue \"" + queueName + "\" is not registered with the exchange.");
@@ -115,8 +116,8 @@ public class DestNameExchange extends AbstractExchange
try
{
- registerQueue(binding, queue, null);
- queue.bind(binding, DestNameExchange.this);
+ registerQueue(new AMQShortString(binding), queue, null);
+ queue.bind(new AMQShortString(binding), DestNameExchange.this);
}
catch (AMQException ex)
{
@@ -140,7 +141,7 @@ public class DestNameExchange extends AbstractExchange
}
}
- public void registerQueue(String routingKey, AMQQueue queue, FieldTable args) throws AMQException
+ public void registerQueue(AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQException
{
assert queue != null;
assert routingKey != null;
@@ -154,7 +155,7 @@ public class DestNameExchange extends AbstractExchange
}
}
- public void deregisterQueue(String routingKey, AMQQueue queue) throws AMQException
+ public void deregisterQueue(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
assert queue != null;
assert routingKey != null;
@@ -169,7 +170,7 @@ public class DestNameExchange extends AbstractExchange
public void route(AMQMessage payload) throws AMQException
{
final BasicPublishBody publishBody = payload.getPublishBody();
- final String routingKey = publishBody.routingKey;
+ final AMQShortString routingKey = publishBody.routingKey;
final List<AMQQueue> queues = (routingKey == null) ? null : _index.get(routingKey);
if (queues == null || queues.isEmpty())
{
@@ -197,13 +198,13 @@ public class DestNameExchange extends AbstractExchange
}
}
- public boolean isBound(String routingKey, AMQQueue queue) throws AMQException
+ public boolean isBound(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
final List<AMQQueue> queues = _index.get(routingKey);
return queues != null && queues.contains(queue);
}
- public boolean isBound(String routingKey) throws AMQException
+ public boolean isBound(AMQShortString routingKey) throws AMQException
{
final List<AMQQueue> queues = _index.get(routingKey);
return queues != null && !queues.isEmpty();
@@ -211,7 +212,7 @@ public class DestNameExchange extends AbstractExchange
public boolean isBound(AMQQueue queue) throws AMQException
{
- Map<String, List<AMQQueue>> bindings = _index.getBindingsMap();
+ Map<AMQShortString, List<AMQQueue>> bindings = _index.getBindingsMap();
for (List<AMQQueue> queues : bindings.values())
{
if (queues.contains(queue))
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
index c341f30ab6..179dc0e9ef 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/DestWildExchange.java
@@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicPublishBody;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.management.MBeanConstructor;
import org.apache.qpid.server.management.MBeanDescription;
import org.apache.qpid.server.queue.AMQMessage;
@@ -43,7 +44,7 @@ public class DestWildExchange extends AbstractExchange
{
private static final Logger _logger = Logger.getLogger(DestWildExchange.class);
- private ConcurrentHashMap<String, List<AMQQueue>> _routingKey2queues = new ConcurrentHashMap<String, List<AMQQueue>>();
+ private ConcurrentHashMap<AMQShortString, List<AMQQueue>> _routingKey2queues = new ConcurrentHashMap<AMQShortString, List<AMQQueue>>();
/**
* DestWildExchangeMBean class implements the management interface for the
@@ -87,18 +88,18 @@ public class DestWildExchange extends AbstractExchange
public TabularData bindings() throws OpenDataException
{
_bindingList = new TabularDataSupport(_bindinglistDataType);
- for (Map.Entry<String, List<AMQQueue>> entry : _routingKey2queues.entrySet())
+ for (Map.Entry<AMQShortString, List<AMQQueue>> entry : _routingKey2queues.entrySet())
{
- String key = entry.getKey();
+ AMQShortString key = entry.getKey();
List<String> queueList = new ArrayList<String>();
List<AMQQueue> queues = entry.getValue();
for (AMQQueue q : queues)
{
- queueList.add(q.getName());
+ queueList.add(q.getName().toString());
}
- Object[] bindingItemValues = {key, queueList.toArray(new String[0])};
+ Object[] bindingItemValues = {key.toString(), queueList.toArray(new String[0])};
CompositeData bindingData = new CompositeDataSupport(_bindingDataType, _bindingItemNames, bindingItemValues);
_bindingList.put(bindingData);
}
@@ -108,14 +109,14 @@ public class DestWildExchange extends AbstractExchange
public void createNewBinding(String queueName, String binding) throws JMException
{
- AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(queueName);
+ AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(new AMQShortString(queueName));
if (queue == null)
throw new JMException("Queue \"" + queueName + "\" is not registered with the exchange.");
try
{
- registerQueue(binding, queue, null);
- queue.bind(binding, DestWildExchange.this);
+ registerQueue(new AMQShortString(binding), queue, null);
+ queue.bind(new AMQShortString(binding), DestWildExchange.this);
}
catch (AMQException ex)
{
@@ -126,7 +127,7 @@ public class DestWildExchange extends AbstractExchange
} // End of MBean class
- public synchronized void registerQueue(String routingKey, AMQQueue queue, FieldTable args) throws AMQException
+ public synchronized void registerQueue(AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQException
{
assert queue != null;
assert routingKey != null;
@@ -154,7 +155,7 @@ public class DestWildExchange extends AbstractExchange
{
BasicPublishBody publishBody = payload.getPublishBody();
- final String routingKey = publishBody.routingKey;
+ final AMQShortString routingKey = publishBody.routingKey;
List<AMQQueue> queues = _routingKey2queues.get(routingKey);
// if we have no registered queues we have nothing to do
// TODO: add support for the immediate flag
@@ -175,14 +176,14 @@ public class DestWildExchange extends AbstractExchange
}
}
- public boolean isBound(String routingKey, AMQQueue queue) throws AMQException
+ public boolean isBound(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
List<AMQQueue> queues = _routingKey2queues.get(routingKey);
return queues != null && queues.contains(queue);
}
- public boolean isBound(String routingKey) throws AMQException
+ public boolean isBound(AMQShortString routingKey) throws AMQException
{
List<AMQQueue> queues = _routingKey2queues.get(routingKey);
return queues != null && !queues.isEmpty();
@@ -205,7 +206,7 @@ public class DestWildExchange extends AbstractExchange
return !_routingKey2queues.isEmpty();
}
- public synchronized void deregisterQueue(String routingKey, AMQQueue queue) throws AMQException
+ public synchronized void deregisterQueue(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
assert queue != null;
assert routingKey != null;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
index 8ef5f0ab29..7ba9ddd5a8 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
@@ -22,14 +22,15 @@ package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.server.queue.AMQMessage;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQMessage;
public interface Exchange
{
- String getName();
+ AMQShortString getName();
- void initialise(String name, boolean durable, int ticket, boolean autoDelete) throws AMQException;
+ void initialise(AMQShortString name, boolean durable, int ticket, boolean autoDelete) throws AMQException;
boolean isDurable();
@@ -42,9 +43,9 @@ public interface Exchange
void close() throws AMQException;
- void registerQueue(String routingKey, AMQQueue queue, FieldTable args) throws AMQException;
+ void registerQueue(AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQException;
- void deregisterQueue(String routingKey, AMQQueue queue) throws AMQException;
+ void deregisterQueue(AMQShortString routingKey, AMQQueue queue) throws AMQException;
void route(AMQMessage message) throws AMQException;
@@ -55,7 +56,7 @@ public interface Exchange
* @return
* @throws AMQException
*/
- boolean isBound(String routingKey, AMQQueue queue) throws AMQException;
+ boolean isBound(AMQShortString routingKey, AMQQueue queue) throws AMQException;
/**
* Determines whether a message is routing to any queue using a specific routing key
@@ -63,7 +64,7 @@ public interface Exchange
* @return
* @throws AMQException
*/
- boolean isBound(String routingKey) throws AMQException;
+ boolean isBound(AMQShortString routingKey) throws AMQException;
boolean isBound(AMQQueue queue) throws AMQException;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
index 37ba883bc3..e07fd0b8fc 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
@@ -21,11 +21,12 @@
package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
public interface ExchangeFactory
{
- Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete,
+ Exchange createExchange(AMQShortString exchange, AMQShortString type, boolean durable, boolean autoDelete,
int ticket)
throws AMQException;
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
index 4a0a6a0ee1..efcb963f8b 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.exchange;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
public interface ExchangeRegistry extends MessageRouter
@@ -34,7 +35,7 @@ public interface ExchangeRegistry extends MessageRouter
* @throws ExchangeInUseException when the exchange cannot be deleted because it is in use
* @throws AMQException
*/
- void unregisterExchange(String name, boolean inUse) throws ExchangeInUseException, AMQException;
+ void unregisterExchange(AMQShortString name, boolean inUse) throws ExchangeInUseException, AMQException;
- Exchange getExchange(String name);
+ Exchange getExchange(AMQShortString name);
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
index 1c63a5571e..cf10f219aa 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
@@ -34,7 +34,7 @@ class HeadersBinding
{
private static final Logger _logger = Logger.getLogger(HeadersBinding.class);
- private final FieldTable _mappings = new FieldTable();
+ private final FieldTable _mappings;
private final Set<String> required = new HashSet<String>();
private final Map<String,Object> matches = new HashMap<String,Object>();
private boolean matchAny;
@@ -91,12 +91,7 @@ class HeadersBinding
HeadersBinding(FieldTable mappings)
{
- Enumeration propertyNames = mappings.getPropertyNames();
- while(propertyNames.hasMoreElements())
- {
- String propName = (String) propertyNames.nextElement();
- _mappings.put(propName, mappings.getObject(propName));
- }
+ _mappings = mappings;
initMappings();
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
index dcb64e2d30..e681cb4c47 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
@@ -110,7 +110,7 @@ public class HeadersExchange extends AbstractExchange
for (Iterator<Registration> itr = _bindings.iterator(); itr.hasNext();)
{
Registration registration = itr.next();
- String queueName = registration.queue.getName();
+ String queueName = registration.queue.getName().toString();
HeadersBinding headers = registration.binding;
FieldTable headerMappings = headers.getMappings();
@@ -149,7 +149,7 @@ public class HeadersExchange extends AbstractExchange
*/
public void createNewBinding(String queueName, String binding) throws JMException
{
- AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(queueName);
+ AMQQueue queue = ApplicationRegistry.getInstance().getQueueRegistry().getQueue(new AMQShortString(queueName));
if (queue == null)
{
@@ -173,13 +173,13 @@ public class HeadersExchange extends AbstractExchange
} // End of MBean class
- public void registerQueue(String routingKey, AMQQueue queue, FieldTable args) throws AMQException
+ public void registerQueue(AMQShortString routingKey, AMQQueue queue, FieldTable args) throws AMQException
{
_logger.debug("Exchange " + getName() + ": Binding " + queue.getName() + " with " + args);
_bindings.add(new Registration(new HeadersBinding(args), queue));
}
- public void deregisterQueue(String routingKey, AMQQueue queue) throws AMQException
+ public void deregisterQueue(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
_logger.debug("Exchange " + getName() + ": Unbinding " + queue.getName());
_bindings.remove(new Registration(null, queue));
@@ -223,12 +223,12 @@ public class HeadersExchange extends AbstractExchange
}
}
- public boolean isBound(String routingKey, AMQQueue queue) throws AMQException
+ public boolean isBound(AMQShortString routingKey, AMQQueue queue) throws AMQException
{
return isBound(queue);
}
- public boolean isBound(String routingKey) throws AMQException
+ public boolean isBound(AMQShortString routingKey) throws AMQException
{
return hasBindings();
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/exchange/Index.java b/java/broker/src/main/java/org/apache/qpid/server/exchange/Index.java
index 485c4739bd..8527a68862 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/exchange/Index.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/exchange/Index.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.exchange;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.framing.AMQShortString;
import java.util.List;
import java.util.Map;
@@ -35,10 +36,10 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
class Index
{
- private ConcurrentMap<String, List<AMQQueue>> _index
- = new ConcurrentHashMap<String, List<AMQQueue>>();
+ private ConcurrentMap<AMQShortString, List<AMQQueue>> _index
+ = new ConcurrentHashMap<AMQShortString, List<AMQQueue>>();
- synchronized boolean add(String key, AMQQueue queue)
+ synchronized boolean add(AMQShortString key, AMQQueue queue)
{
List<AMQQueue> queues = _index.get(key);
if(queues == null)
@@ -62,7 +63,7 @@ class Index
}
}
- synchronized boolean remove(String key, AMQQueue queue)
+ synchronized boolean remove(AMQShortString key, AMQQueue queue)
{
List<AMQQueue> queues = _index.get(key);
if (queues != null)
@@ -77,13 +78,13 @@ class Index
return false;
}
- List<AMQQueue> get(String key)
+ List<AMQQueue> get(AMQShortString key)
{
return _index.get(key);
}
- Map<String, List<AMQQueue>> getBindingsMap()
+ Map<AMQShortString, List<AMQQueue>> getBindingsMap()
{
- return new HashMap<String, List<AMQQueue>>(_index);
+ return new HashMap<AMQShortString, List<AMQQueue>>(_index);
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java b/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
index 49f99132ef..5c784983cb 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/filter/FilterManagerFactory.java
@@ -45,29 +45,24 @@ public class FilterManagerFactory
manager = new SimpleFilterManager();
- Iterator it = filters.keySet().iterator();
- _logger.info("Processing filters:");
- while (it.hasNext())
+ if(filters.containsKey(AMQPFilterTypes.JMS_SELECTOR.getValue()))
{
- String key = (String) it.next();
- _logger.info("filter:" + key);
- if (key.equals(AMQPFilterTypes.JMS_SELECTOR.getValue()))
- {
- String selector = (String) filters.get(key);
-
- if (selector != null && !selector.equals(""))
- {
- manager.add(new JMSSelectorFilter(selector));
- }
- }
+ String selector = filters.getString(AMQPFilterTypes.JMS_SELECTOR.getValue());
- if (key.equals(AMQPFilterTypes.NO_CONSUME.getValue()))
+ if (selector != null && !selector.equals(""))
{
- manager.add(new NoConsumerFilter());
+ manager.add(new JMSSelectorFilter(selector));
}
}
+ if (filters.containsKey(AMQPFilterTypes.NO_CONSUME.getValue()))
+ {
+ manager.add(new NoConsumerFilter());
+ }
+
+
+
//If we added no filters don't bear the overhead of having an filter manager
if (!manager.hasFilters())
{
@@ -76,7 +71,7 @@ public class FilterManagerFactory
}
else
{
- _logger.info("No Filters found.");
+ _logger.debug("No Filters found.");
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java b/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java
index 7d6a98df84..934bca991d 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/filter/PropertyExpression.java
@@ -248,7 +248,7 @@ public class PropertyExpression implements Expression
_logger.info("Looking up property:" + name);
_logger.info("Properties are:" + _properties.getHeaders().keySet());
- return _properties.getHeaders().get(name);
+ return _properties.getHeaders().getObject(name);
}
// catch (IOException ioe)
// {
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
index d3aece9818..0cb1d8bee8 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicConsumeMethodHandler.java
@@ -23,10 +23,7 @@ package org.apache.qpid.server.handler;
import org.apache.qpid.AMQException;
import org.apache.qpid.AMQInvalidSelectorException;
import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.framing.BasicConsumeBody;
-import org.apache.qpid.framing.BasicConsumeOkBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ChannelCloseBody;
+import org.apache.qpid.framing.*;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.ConsumerTagNotUniqueException;
import org.apache.qpid.server.exchange.ExchangeRegistry;
@@ -77,7 +74,7 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic
}
try
{
- String consumerTag = channel.subscribeToQueue(body.consumerTag, queue, session, !body.noAck,
+ AMQShortString consumerTag = channel.subscribeToQueue(body.consumerTag, queue, session, !body.noAck,
body.arguments, body.noLocal);
if (!body.nowait)
{
@@ -103,11 +100,11 @@ public class BasicConsumeMethodHandler implements StateAwareMethodListener<Basic
BasicConsumeBody.getClazz((byte)8, (byte)0), // classId
BasicConsumeBody.getMethod((byte)8, (byte)0), // methodId
AMQConstant.INVALID_SELECTOR.getCode(), // replyCode
- ise.getMessage())); // replyText
+ new AMQShortString(ise.getMessage()))); // replyText
}
catch (ConsumerTagNotUniqueException e)
{
- String msg = "Non-unique consumer tag, '" + body.consumerTag + "'";
+ AMQShortString msg = new AMQShortString("Non-unique consumer tag, '" + body.consumerTag + "'");
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
index 423ea5f276..181409c255 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/BasicPublishMethodHandler.java
@@ -21,9 +21,11 @@
package org.apache.qpid.server.handler;
import org.apache.qpid.AMQException;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.BasicPublishBody;
import org.apache.qpid.framing.ChannelCloseBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeRegistry;
@@ -36,6 +38,8 @@ import org.apache.qpid.server.state.StateAwareMethodListener;
public class BasicPublishMethodHandler implements StateAwareMethodListener<BasicPublishBody>
{
private static final BasicPublishMethodHandler _instance = new BasicPublishMethodHandler();
+
+ private static final AMQShortString UNKNOWN_EXCHANGE_NAME = new AMQShortString("Unknown exchange name");
public static BasicPublishMethodHandler getInstance()
{
@@ -55,7 +59,8 @@ public class BasicPublishMethodHandler implements StateAwareMethodListener<Basi
// TODO: check the delivery tag field details - is it unique across the broker or per subscriber?
if (body.exchange == null)
{
- body.exchange = "amq.direct";
+ body.exchange = ExchangeDefaults.DIRECT_EXCHANGE_NAME;
+
}
Exchange e = exchangeRegistry.getExchange(body.exchange);
// if the exchange does not exist we raise a channel exception
@@ -72,7 +77,7 @@ public class BasicPublishMethodHandler implements StateAwareMethodListener<Basi
ChannelCloseBody.getClazz((byte)8, (byte)0), // classId
ChannelCloseBody.getMethod((byte)8, (byte)0), // methodId
500, // replyCode
- "Unknown exchange name"); // replyText
+ UNKNOWN_EXCHANGE_NAME); // replyText
protocolSession.writeFrame(cf);
}
else
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
index 9f9b029ada..c00fe858fa 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionOpenMethodHandler.java
@@ -24,6 +24,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.ConnectionOpenBody;
import org.apache.qpid.framing.ConnectionOpenOkBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.protocol.AMQMethodEvent;
import org.apache.qpid.server.protocol.AMQProtocolSession;
@@ -45,9 +46,9 @@ public class ConnectionOpenMethodHandler implements StateAwareMethodListener<Con
{
}
- private static String generateClientID()
+ private static AMQShortString generateClientID()
{
- return Long.toString(System.currentTimeMillis());
+ return new AMQShortString(Long.toString(System.currentTimeMillis()));
}
public void methodReceived(AMQStateManager stateManager, QueueRegistry queueRegistry,
@@ -55,7 +56,7 @@ public class ConnectionOpenMethodHandler implements StateAwareMethodListener<Con
AMQMethodEvent<ConnectionOpenBody> evt) throws AMQException
{
ConnectionOpenBody body = evt.getMethod();
- String contextKey = body.virtualHost;
+ AMQShortString contextKey = body.virtualHost;
//todo //FIXME The virtual host must be validated by the server for the connection to open-ok
// See Spec (0.8.2). Section 3.1.2 Virtual Hosts
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
index 9f24100df1..7cf1236d2f 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
@@ -73,7 +73,7 @@ public class ConnectionStartOkMethodHandler implements StateAwareMethodListener<
SaslServer ss = null;
try
{
- ss = authMgr.createSaslServer(body.mechanism, protocolSession.getLocalFQDN());
+ ss = authMgr.createSaslServer(String.valueOf(body.mechanism), protocolSession.getLocalFQDN());
protocolSession.setSaslServer(ss);
AuthenticationResult authResult = authMgr.authenticate(ss, body.response);
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
index 30e8990b54..0b216c4da1 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/ExchangeBoundHandler.java
@@ -21,6 +21,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.ExchangeBoundBody;
import org.apache.qpid.framing.ExchangeBoundOkBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.protocol.AMQMethodEvent;
@@ -71,9 +72,9 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
ExchangeBoundBody body = evt.getMethod();
- String exchangeName = body.exchange;
- String queueName = body.queue;
- String routingKey = body.routingKey;
+ AMQShortString exchangeName = body.exchange;
+ AMQShortString queueName = body.queue;
+ AMQShortString routingKey = body.routingKey;
if (exchangeName == null)
{
throw new AMQException("Exchange exchange must not be null");
@@ -86,7 +87,7 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
EXCHANGE_NOT_FOUND, // replyCode
- "Exchange " + exchangeName + " not found"); // replyText
+ new AMQShortString("Exchange " + exchangeName + " not found")); // replyText
}
else if (routingKey == null)
{
@@ -118,7 +119,7 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
QUEUE_NOT_FOUND, // replyCode
- "Queue " + queueName + " not found"); // replyText
+ new AMQShortString("Queue " + queueName + " not found")); // replyText
}
else
{
@@ -136,7 +137,7 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
QUEUE_NOT_BOUND, // replyCode
- "Queue " + queueName + " not bound to exchange " + exchangeName); // replyText
+ new AMQShortString("Queue " + queueName + " not bound to exchange " + exchangeName)); // replyText
}
}
}
@@ -150,7 +151,7 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
QUEUE_NOT_FOUND, // replyCode
- "Queue " + queueName + " not found"); // replyText
+ new AMQShortString("Queue " + queueName + " not found")); // replyText
}
else
{
@@ -168,8 +169,8 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
SPECIFIC_QUEUE_NOT_BOUND_WITH_RK, // replyCode
- "Queue " + queueName + " not bound with routing key " +
- body.routingKey + " to exchange " + exchangeName); // replyText
+ new AMQShortString("Queue " + queueName + " not bound with routing key " +
+ body.routingKey + " to exchange " + exchangeName)); // replyText
}
}
}
@@ -189,8 +190,8 @@ public class ExchangeBoundHandler implements StateAwareMethodListener<ExchangeBo
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
NO_QUEUE_BOUND_WITH_RK, // replyCode
- "No queue bound with routing key " + body.routingKey +
- " to exchange " + exchangeName); // replyText
+ new AMQShortString("No queue bound with routing key " + body.routingKey +
+ " to exchange " + exchangeName)); // replyText
}
}
protocolSession.writeFrame(response);
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
index 83f98de2d9..6ff7700a13 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
@@ -22,10 +22,12 @@ package org.apache.qpid.server.handler;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
+import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.configuration.Configured;
import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.QueueDeclareBody;
import org.apache.qpid.framing.QueueDeclareOkBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.exchange.ExchangeRegistry;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.protocol.AMQMethodEvent;
@@ -91,7 +93,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
queueRegistry.registerQueue(queue);
if (autoRegister)
{
- Exchange defaultExchange = exchangeRegistry.getExchange("amq.direct");
+ Exchange defaultExchange = exchangeRegistry.getExchange(ExchangeDefaults.DIRECT_EXCHANGE_NAME);
defaultExchange.registerQueue(body.queue, queue, null);
queue.bind(body.queue, defaultExchange);
_log.info("Queue " + body.queue + " bound to default exchange");
@@ -115,9 +117,9 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
}
}
- protected String createName()
+ protected AMQShortString createName()
{
- return "tmp_" + pad(_counter.incrementAndGet());
+ return new AMQShortString("tmp_" + pad(_counter.incrementAndGet()));
}
protected static String pad(int value)
@@ -128,7 +130,7 @@ public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclar
protected AMQQueue createQueue(QueueDeclareBody body, QueueRegistry registry, AMQProtocolSession session)
throws AMQException
{
- String owner = body.exclusive ? session.getContextKey() : null;
+ AMQShortString owner = body.exclusive ? session.getContextKey() : null;
return new AMQQueue(body.queue, body.durable, owner, body.autoDelete, registry);
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
index 688968b8a0..5437561095 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeleteHandler.java
@@ -80,7 +80,7 @@ public class QueueDeleteHandler implements StateAwareMethodListener<QueueDelete
else
{
int purged = queue.delete(body.ifUnused, body.ifEmpty);
- _store.removeQueue(queue.getName());
+ _store.removeQueue(queue.getName().toString());
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.
diff --git a/java/broker/src/main/java/org/apache/qpid/server/message/jms/JMSMessage.java b/java/broker/src/main/java/org/apache/qpid/server/message/jms/JMSMessage.java
index 376f88cbf1..ab201c476e 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/message/jms/JMSMessage.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/message/jms/JMSMessage.java
@@ -178,116 +178,116 @@ public class JMSMessage implements MessageDecorator
public void clearProperties() throws MessageNotWriteableException
{
checkWriteable();
- _properties.getJMSHeaders().clear();
+ _properties.clear();
}
public boolean propertyExists(String string)
{
- return _properties.getJMSHeaders().propertyExists(string);
+ return _properties.propertyExists(string);
}
public boolean getBooleanProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getBoolean(string);
+ return _properties.getBoolean(string);
}
public byte getByteProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getByte(string);
+ return _properties.getByte(string);
}
public short getShortProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getShort(string);
+ return _properties.getShort(string);
}
public int getIntProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getInteger(string);
+ return _properties.getInteger(string);
}
public long getLongProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getLong(string);
+ return _properties.getLong(string);
}
public float getFloatProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getFloat(string);
+ return _properties.getFloat(string);
}
public double getDoubleProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getDouble(string);
+ return _properties.getDouble(string);
}
public String getStringProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getString(string);
+ return _properties.getString(string);
}
public Object getObjectProperty(String string) throws JMSException
{
- return _properties.getJMSHeaders().getObject(string);
+ return _properties.getObject(string);
}
public Enumeration getPropertyNames()
{
- return _properties.getJMSHeaders().getPropertyNames();
+ return _properties.getPropertyNames();
}
public void setBooleanProperty(String string, boolean b) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setBoolean(string, b);
+ _properties.setBoolean(string, b);
}
public void setByteProperty(String string, byte b) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setByte(string, b);
+ _properties.setByte(string, b);
}
public void setShortProperty(String string, short i) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setShort(string, i);
+ _properties.setShort(string, i);
}
public void setIntProperty(String string, int i) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setInteger(string, i);
+ _properties.setInteger(string, i);
}
public void setLongProperty(String string, long l) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setLong(string, l);
+ _properties.setLong(string, l);
}
public void setFloatProperty(String string, float v) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setFloat(string, v);
+ _properties.setFloat(string, v);
}
public void setDoubleProperty(String string, double v) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setDouble(string, v);
+ _properties.setDouble(string, v);
}
public void setStringProperty(String string, String string1) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setString(string, string1);
+ _properties.setString(string, string1);
}
public void setObjectProperty(String string, Object object) throws JMSException
{
checkWriteable();
- _properties.getJMSHeaders().setObject(string, object);
+ _properties.setObject(string, object);
}
public void acknowledge() throws MessageNotWriteableException
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
index 08668f0f6a..f86d8afe02 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
@@ -26,16 +26,7 @@ import org.apache.mina.common.IoSession;
import org.apache.mina.transport.vmpipe.VmPipeAddress;
import org.apache.qpid.AMQChannelException;
import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQDataBlock;
-import org.apache.qpid.framing.ProtocolInitiation;
-import org.apache.qpid.framing.ConnectionStartBody;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.ProtocolVersionList;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.ContentBody;
-import org.apache.qpid.framing.HeartbeatBody;
-import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.*;
import org.apache.qpid.codec.AMQCodecFactory;
import org.apache.qpid.codec.AMQDecoder;
@@ -65,7 +56,7 @@ public class AMQMinaProtocolSession implements AMQProtocolSession,
private final IoSession _minaProtocolSession;
- private String _contextKey;
+ private AMQShortString _contextKey;
private final Map<Integer, AMQChannel> _channelMap = new HashMap<Integer, AMQChannel>();
@@ -291,12 +282,12 @@ public class AMQMinaProtocolSession implements AMQProtocolSession,
_minaProtocolSession.write(frame);
}
- public String getContextKey()
+ public AMQShortString getContextKey()
{
return _contextKey;
}
- public void setContextKey(String contextKey)
+ public void setContextKey(AMQShortString contextKey)
{
_contextKey = contextKey;
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java
index 2e9590277b..f4f443b162 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java
@@ -180,7 +180,7 @@ public class AMQPFastProtocolHandler extends IoHandlerAdapter implements Protoco
0, // classId
0, // methodId
200, // replyCode
- throwable.getMessage() // replyText
+ new AMQShortString(throwable.getMessage()) // replyText
));
_logger.error("Exception caught in" + session + ", closing session explictly: " + throwable, throwable);
protocolSession.close();
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
index a75627d240..ee01dd9f5b 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.protocol;
import org.apache.qpid.framing.AMQDataBlock;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.AMQException;
@@ -48,14 +49,14 @@ public interface AMQProtocolSession
* in the AMQ protocol specification (RFC 6).
* @return the context key
*/
- String getContextKey();
+ AMQShortString getContextKey();
/**
* Set the context key associated with this session. Context key is described
* in the AMQ protocol specification (RFC 6).
* @param contextKey the context key
*/
- void setContextKey(String contextKey);
+ void setContextKey(AMQShortString contextKey);
/**
* Get the channel for this session associated with the specified id. A channel
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
index 0ceadcb30b..08045e1c41 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java
@@ -21,6 +21,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.framing.ConnectionCloseBody;
import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.management.AMQManagedObject;
import org.apache.qpid.server.management.MBeanConstructor;
@@ -58,6 +59,8 @@ public class AMQProtocolSessionMBean extends AMQManagedObject implements Managed
private OpenType[] _channelAttributeTypes = {SimpleType.INTEGER, SimpleType.BOOLEAN, SimpleType.STRING, SimpleType.INTEGER};
private CompositeType _channelType = null; // represents the data type for channel data
private TabularType _channelsType = null; // Data type for list of channels type
+ private static final AMQShortString BROKER_MANAGEMENT_CONSOLE_HAS_CLOSING_THE_CONNECTION =
+ new AMQShortString("Broker Management Console has closing the connection.");
@MBeanConstructor("Creates an MBean exposing an AMQ Broker Connection")
public AMQProtocolSessionMBean(AMQMinaProtocolSession session) throws JMException
@@ -201,7 +204,7 @@ public class AMQProtocolSessionMBean extends AMQManagedObject implements Managed
0, // classId
0, // methodId
AMQConstant.REPLY_SUCCESS.getCode(), // replyCode
- "Broker Management Console has closing the connection." // replyText
+ BROKER_MANAGEMENT_CONSOLE_HAS_CLOSING_THE_CONNECTION // replyText
);
_session.writeFrame(response);
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java
index d3ec70456f..d4881aefaf 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.protocol;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.server.exchange.ExchangeFactory;
import org.apache.qpid.server.exchange.ExchangeRegistry;
@@ -34,7 +35,7 @@ public class ExchangeInitialiser
}
private void define(ExchangeRegistry r, ExchangeFactory f,
- String name, String type) throws AMQException
+ AMQShortString name, AMQShortString type) throws AMQException
{
r.registerExchange(f.createExchange(name, type, true, false, 0));
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java
index f30667690f..05b4f5ec2b 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQMessage.java
@@ -562,7 +562,7 @@ public class AMQMessage
}
}
- public void writeDeliver(AMQProtocolSession protocolSession, int channelId, long deliveryTag, String consumerTag)
+ public void writeDeliver(AMQProtocolSession protocolSession, int channelId, long deliveryTag, AMQShortString consumerTag)
throws AMQException
{
ByteBuffer deliver = createEncodedDeliverFrame(channelId, deliveryTag, consumerTag);
@@ -598,7 +598,7 @@ public class AMQMessage
}
- private ByteBuffer createEncodedDeliverFrame(int channelId, long deliveryTag, String consumerTag)
+ private ByteBuffer createEncodedDeliverFrame(int channelId, long deliveryTag, AMQShortString consumerTag)
throws AMQException
{
BasicPublishBody pb = getPublishBody();
@@ -611,7 +611,7 @@ public class AMQMessage
return buf;
}
- private ByteBuffer createEncodedReturnFrame(int channelId, int replyCode, String replyText) throws AMQException
+ private ByteBuffer createEncodedReturnFrame(int channelId, int replyCode, AMQShortString replyText) throws AMQException
{
AMQFrame returnFrame = BasicReturnBody.createAMQFrame(channelId, (byte) 8, (byte) 0, getPublishBody().exchange,
replyCode, replyText,
@@ -622,7 +622,7 @@ public class AMQMessage
return buf;
}
- public void writeReturn(AMQProtocolSession protocolSession, int channelId, int replyCode, String replyText)
+ public void writeReturn(AMQProtocolSession protocolSession, int channelId, int replyCode, AMQShortString replyText)
throws AMQException
{
ByteBuffer returnFrame = createEncodedReturnFrame(channelId, replyCode, replyText);
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
index 6f1018e753..ea09654988 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.server.management.Managable;
import org.apache.qpid.server.management.ManagedObject;
@@ -42,12 +43,12 @@ public class AMQQueue implements Managable, Comparable
{
private static final Logger _logger = Logger.getLogger(AMQQueue.class);
- private final String _name;
+ private final AMQShortString _name;
/**
* null means shared
*/
- private final String _owner;
+ private final AMQShortString _owner;
private final boolean _durable;
@@ -111,7 +112,7 @@ public class AMQQueue implements Managable, Comparable
return _name.compareTo(((AMQQueue) o).getName());
}
- public AMQQueue(String name, boolean durable, String owner,
+ public AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry)
throws AMQException
{
@@ -119,7 +120,7 @@ public class AMQQueue implements Managable, Comparable
AsyncDeliveryConfig.getAsyncDeliveryExecutor(), new SubscriptionImpl.Factory());
}
- public AMQQueue(String name, boolean durable, String owner,
+ public AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry, SubscriptionFactory subscriptionFactory)
throws AMQException
{
@@ -127,7 +128,7 @@ public class AMQQueue implements Managable, Comparable
AsyncDeliveryConfig.getAsyncDeliveryExecutor(), subscriptionFactory);
}
- public AMQQueue(String name, boolean durable, String owner,
+ public AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery,
SubscriptionFactory subscriptionFactory)
throws AMQException
@@ -136,7 +137,7 @@ public class AMQQueue implements Managable, Comparable
this(name, durable, owner, autoDelete, queueRegistry, asyncDelivery, new SubscriptionSet(), subscriptionFactory);
}
- public AMQQueue(String name, boolean durable, String owner,
+ public AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
throws AMQException
{
@@ -145,7 +146,7 @@ public class AMQQueue implements Managable, Comparable
new SubscriptionImpl.Factory());
}
- protected AMQQueue(String name, boolean durable, String owner,
+ protected AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry,
SubscriptionSet subscribers, SubscriptionFactory subscriptionFactory)
throws AMQException
@@ -154,7 +155,7 @@ public class AMQQueue implements Managable, Comparable
AsyncDeliveryConfig.getAsyncDeliveryExecutor(), subscribers, subscriptionFactory);
}
- protected AMQQueue(String name, boolean durable, String owner,
+ protected AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry,
SubscriptionSet subscribers)
throws AMQException
@@ -163,7 +164,7 @@ public class AMQQueue implements Managable, Comparable
AsyncDeliveryConfig.getAsyncDeliveryExecutor(), subscribers, new SubscriptionImpl.Factory());
}
- protected AMQQueue(String name, boolean durable, String owner,
+ protected AMQQueue(AMQShortString name, boolean durable, AMQShortString owner,
boolean autoDelete, QueueRegistry queueRegistry,
Executor asyncDelivery, SubscriptionSet subscribers, SubscriptionFactory subscriptionFactory)
throws AMQException
@@ -225,7 +226,7 @@ public class AMQQueue implements Managable, Comparable
}
}
- public String getName()
+ public AMQShortString getName()
{
return _name;
}
@@ -240,7 +241,7 @@ public class AMQQueue implements Managable, Comparable
return _durable;
}
- public String getOwner()
+ public AMQShortString getOwner()
{
return _owner;
}
@@ -356,17 +357,17 @@ public class AMQQueue implements Managable, Comparable
_deliveryMgr.clearAllMessages(storeContext);
}
- public void bind(String routingKey, Exchange exchange)
+ public void bind(AMQShortString routingKey, Exchange exchange)
{
_bindings.addBinding(routingKey, exchange);
}
- public void registerProtocolSession(AMQProtocolSession ps, int channel, String consumerTag, boolean acks, FieldTable filters) throws AMQException
+ public void registerProtocolSession(AMQProtocolSession ps, int channel, AMQShortString consumerTag, boolean acks, FieldTable filters) throws AMQException
{
registerProtocolSession(ps, channel, consumerTag, acks, filters, false);
}
- public void registerProtocolSession(AMQProtocolSession ps, int channel, String consumerTag, boolean acks, FieldTable filters, boolean noLocal)
+ public void registerProtocolSession(AMQProtocolSession ps, int channel, AMQShortString consumerTag, boolean acks, FieldTable filters, boolean noLocal)
throws AMQException
{
debug("Registering protocol session {0} with channel {1} and consumer tag {2} with {3}", ps, channel, consumerTag, this);
@@ -384,7 +385,7 @@ public class AMQQueue implements Managable, Comparable
_subscribers.addSubscriber(subscription);
}
- public void unregisterProtocolSession(AMQProtocolSession ps, int channel, String consumerTag) throws AMQException
+ public void unregisterProtocolSession(AMQProtocolSession ps, int channel, AMQShortString consumerTag) throws AMQException
{
debug("Unregistering protocol session {0} with channel {1} and consumer tag {2} from {3}", ps, channel, consumerTag,
this);
@@ -475,7 +476,7 @@ public class AMQQueue implements Managable, Comparable
}
catch (AMQException e)
{
- throw new FailedDequeueException(_name, e);
+ throw new FailedDequeueException(_name.toString(), e);
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
index 77bbdf7b4b..fb4a8e06bf 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
@@ -112,7 +112,7 @@ public class AMQQueueMBean extends AMQManagedObject implements ManagedQueue
public String getOwner()
{
- return _queue.getOwner();
+ return String.valueOf(_queue.getOwner());
}
public boolean isAutoDelete()
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentDeliveryManager.java b/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentDeliveryManager.java
index a2898ccdce..1a44e86f1a 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentDeliveryManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentDeliveryManager.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.configuration.Configured;
import org.apache.qpid.server.configuration.Configurator;
import org.apache.qpid.server.store.StoreContext;
@@ -294,7 +295,7 @@ public class ConcurrentDeliveryManager implements DeliveryManager
}
}
- public void deliver(StoreContext storeContext, String name, AMQMessage msg) throws FailedDequeueException, AMQException
+ public void deliver(StoreContext storeContext, AMQShortString name, AMQMessage msg) throws FailedDequeueException, AMQException
{
// first check whether we are queueing, and enqueue if we are
if (!enqueue(msg))
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentSelectorDeliveryManager.java b/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentSelectorDeliveryManager.java
index 8f0c3a5ec7..91c49a4cf9 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentSelectorDeliveryManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/ConcurrentSelectorDeliveryManager.java
@@ -25,6 +25,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.util.ConcurrentLinkedQueueAtomicSize;
import org.apache.qpid.configuration.Configured;
import org.apache.qpid.framing.ContentBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.configuration.Configurator;
import org.apache.qpid.server.store.StoreContext;
@@ -280,7 +281,7 @@ public class ConcurrentSelectorDeliveryManager implements DeliveryManager
return _messages.poll();
}
- public void deliver(StoreContext context, String name, AMQMessage msg) throws AMQException
+ public void deliver(StoreContext context, AMQShortString name, AMQMessage msg) throws AMQException
{
if (_log.isDebugEnabled())
{
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java
index 3b73072e30..8ab26def74 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java
@@ -21,13 +21,14 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
public class DefaultQueueRegistry implements QueueRegistry
{
- private ConcurrentMap<String, AMQQueue> _queueMap = new ConcurrentHashMap<String, AMQQueue>();
+ private ConcurrentMap<AMQShortString, AMQQueue> _queueMap = new ConcurrentHashMap<AMQShortString, AMQQueue>();
public DefaultQueueRegistry()
{
@@ -38,12 +39,12 @@ public class DefaultQueueRegistry implements QueueRegistry
_queueMap.put(queue.getName(), queue);
}
- public void unregisterQueue(String name) throws AMQException
+ public void unregisterQueue(AMQShortString name) throws AMQException
{
_queueMap.remove(name);
}
- public AMQQueue getQueue(String name)
+ public AMQQueue getQueue(AMQShortString name)
{
return _queueMap.get(name);
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/DeliveryManager.java b/java/broker/src/main/java/org/apache/qpid/server/queue/DeliveryManager.java
index 82d8f9538f..d3d235f07f 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/DeliveryManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/DeliveryManager.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.store.StoreContext;
import java.util.concurrent.Executor;
@@ -67,7 +68,7 @@ interface DeliveryManager
* @param msg the message to deliver
* @throws org.apache.qpid.server.queue.FailedDequeueException if the message could not be dequeued
*/
- void deliver(StoreContext storeContext, String name, AMQMessage msg) throws FailedDequeueException, AMQException;
+ void deliver(StoreContext storeContext, AMQShortString name, AMQMessage msg) throws FailedDequeueException, AMQException;
void removeAMessageFromTop(StoreContext storeContext) throws AMQException;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
index 684e312fa3..2f742952c9 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/ExchangeBindings.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.queue;
import org.apache.qpid.server.exchange.Exchange;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import java.util.List;
import java.util.HashSet;
@@ -37,9 +38,9 @@ class ExchangeBindings
static class ExchangeBinding
{
private final Exchange exchange;
- private final String routingKey;
+ private final AMQShortString routingKey;
- ExchangeBinding(String routingKey, Exchange exchange)
+ ExchangeBinding(AMQShortString routingKey, Exchange exchange)
{
this.routingKey = routingKey;
this.exchange = exchange;
@@ -55,7 +56,7 @@ class ExchangeBindings
return exchange;
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
return routingKey;
}
@@ -87,7 +88,7 @@ class ExchangeBindings
* are being tracked by the instance has been bound to the exchange
* @param exchange the exchange bound to
*/
- void addBinding(String routingKey, Exchange exchange)
+ void addBinding(AMQShortString routingKey, Exchange exchange)
{
_bindings.add(new ExchangeBinding(routingKey, exchange));
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
index c83f17b98c..bfbaf27c84 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
@@ -21,13 +21,14 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
public interface QueueRegistry
{
void registerQueue(AMQQueue queue) throws AMQException;
- void unregisterQueue(String name) throws AMQException;
+ void unregisterQueue(AMQShortString name) throws AMQException;
- AMQQueue getQueue(String name);
+ AMQQueue getQueue(AMQShortString name);
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionFactory.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionFactory.java
index 2bb77dc649..6cc55f2818 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionFactory.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionFactory.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.queue;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
/**
* Allows the customisation of the creation of a subscription. This is typically done within an AMQQueue. This
@@ -33,10 +34,10 @@ import org.apache.qpid.framing.FieldTable;
*/
public interface SubscriptionFactory
{
- Subscription createSubscription(int channel, AMQProtocolSession protocolSession, String consumerTag, boolean acks,
+ Subscription createSubscription(int channel, AMQProtocolSession protocolSession, AMQShortString consumerTag, boolean acks,
FieldTable filters, boolean noLocal) throws AMQException;
- Subscription createSubscription(int channel, AMQProtocolSession protocolSession, String consumerTag)
+ Subscription createSubscription(int channel, AMQProtocolSession protocolSession, AMQShortString consumerTag)
throws AMQException;
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java
index 0dc1f3b0c1..0afe17c6ca 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java
@@ -25,10 +25,7 @@ import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.AMQException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.common.ClientProperties;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.BasicCancelOkBody;
-import org.apache.qpid.framing.BasicDeliverBody;
-import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.*;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.filter.FilterManager;
import org.apache.qpid.server.filter.FilterManagerFactory;
@@ -53,7 +50,7 @@ public class SubscriptionImpl implements Subscription
public final AMQProtocolSession protocolSession;
- public final String consumerTag;
+ public final AMQShortString consumerTag;
private final Object sessionKey;
@@ -72,12 +69,12 @@ public class SubscriptionImpl implements Subscription
public static class Factory implements SubscriptionFactory
{
- public Subscription createSubscription(int channel, AMQProtocolSession protocolSession, String consumerTag, boolean acks, FieldTable filters, boolean noLocal) throws AMQException
+ public Subscription createSubscription(int channel, AMQProtocolSession protocolSession, AMQShortString consumerTag, boolean acks, FieldTable filters, boolean noLocal) throws AMQException
{
return new SubscriptionImpl(channel, protocolSession, consumerTag, acks, filters, noLocal);
}
- public SubscriptionImpl createSubscription(int channel, AMQProtocolSession protocolSession, String consumerTag)
+ public SubscriptionImpl createSubscription(int channel, AMQProtocolSession protocolSession, AMQShortString consumerTag)
throws AMQException
{
return new SubscriptionImpl(channel, protocolSession, consumerTag, false, null, false);
@@ -85,14 +82,14 @@ public class SubscriptionImpl implements Subscription
}
public SubscriptionImpl(int channelId, AMQProtocolSession protocolSession,
- String consumerTag, boolean acks)
+ AMQShortString consumerTag, boolean acks)
throws AMQException
{
this(channelId, protocolSession, consumerTag, acks, null, false);
}
public SubscriptionImpl(int channelId, AMQProtocolSession protocolSession,
- String consumerTag, boolean acks, FieldTable filters, boolean noLocal)
+ AMQShortString consumerTag, boolean acks, FieldTable filters, boolean noLocal)
throws AMQException
{
AMQChannel channel = protocolSession.getChannel(channelId);
@@ -162,7 +159,7 @@ public class SubscriptionImpl implements Subscription
public SubscriptionImpl(int channel, AMQProtocolSession protocolSession,
- String consumerTag)
+ AMQShortString consumerTag)
throws AMQException
{
this(channel, protocolSession, consumerTag, false);
@@ -304,8 +301,8 @@ public class SubscriptionImpl implements Subscription
if (_noLocal)
{
// We don't want local messages so check to see if message is one we sent
- if (protocolSession.getClientProperties().get(ClientProperties.instance.toString()).equals(
- msg.getPublisher().getClientProperties().get(ClientProperties.instance.toString())))
+ if (protocolSession.getClientProperties().getObject(ClientProperties.instance.toString()).equals(
+ msg.getPublisher().getClientProperties().getObject(ClientProperties.instance.toString())))
{
if (_logger.isTraceEnabled())
{
@@ -395,7 +392,7 @@ public class SubscriptionImpl implements Subscription
}
- private ByteBuffer createEncodedDeliverFrame(long deliveryTag, String routingKey, String exchange)
+ private ByteBuffer createEncodedDeliverFrame(long deliveryTag, AMQShortString routingKey, AMQShortString exchange)
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SynchronizedDeliveryManager.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SynchronizedDeliveryManager.java
index f290452058..02fe86a083 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/SynchronizedDeliveryManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SynchronizedDeliveryManager.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.store.StoreContext;
import org.apache.log4j.Logger;
@@ -234,7 +235,7 @@ class SynchronizedDeliveryManager implements DeliveryManager
* @throws NoConsumersException if there are no active subscribers to deliver
* the message to
*/
- public void deliver(StoreContext storeContext, String name, AMQMessage msg) throws FailedDequeueException, AMQException
+ public void deliver(StoreContext storeContext, AMQShortString name, AMQMessage msg) throws FailedDequeueException, AMQException
{
// first check whether we are queueing, and enqueue if we are
if (!enqueue(msg))
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/WeakReferenceMessageHandle.java b/java/broker/src/main/java/org/apache/qpid/server/queue/WeakReferenceMessageHandle.java
index 2fb2bdd2e3..446cf5ec2c 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/WeakReferenceMessageHandle.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/WeakReferenceMessageHandle.java
@@ -180,11 +180,11 @@ public class WeakReferenceMessageHandle implements AMQMessageHandle
public void enqueue(StoreContext storeContext, long messageId, AMQQueue queue) throws AMQException
{
- _messageStore.enqueueMessage(storeContext, queue.getName(), messageId);
+ _messageStore.enqueueMessage(storeContext, queue.getName().toString(), messageId);
}
public void dequeue(StoreContext storeContext, long messageId, AMQQueue queue) throws AMQException
{
- _messageStore.dequeueMessage(storeContext, queue.getName(), messageId);
+ _messageStore.dequeueMessage(storeContext, queue.getName().toString(), messageId);
}
}
diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationManager.java b/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationManager.java
index 9f4addd7ee..6cee2ee452 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/security/auth/AuthenticationManager.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.security.auth;
+import org.apache.qpid.framing.AMQShortString;
+
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/auth/NullAuthenticationManager.java b/java/broker/src/main/java/org/apache/qpid/server/security/auth/NullAuthenticationManager.java
index 14cce86715..5c21dd4de4 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/security/auth/NullAuthenticationManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/security/auth/NullAuthenticationManager.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.security.auth;
import org.apache.qpid.server.security.auth.AuthenticationManager;
import org.apache.qpid.server.security.auth.AuthenticationResult;
+import org.apache.qpid.framing.AMQShortString;
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/auth/SASLAuthenticationManager.java b/java/broker/src/main/java/org/apache/qpid/server/security/auth/SASLAuthenticationManager.java
index 21eb80c69d..e96bd68cad 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/security/auth/SASLAuthenticationManager.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/security/auth/SASLAuthenticationManager.java
@@ -24,6 +24,7 @@ import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Logger;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.configuration.PropertyUtils;
+import org.apache.qpid.framing.AMQShortString;
import javax.security.auth.callback.CallbackHandler;
import javax.security.sasl.Sasl;
diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/auth/amqplain/AmqPlainSaslServer.java b/java/broker/src/main/java/org/apache/qpid/server/security/auth/amqplain/AmqPlainSaslServer.java
index c364ca1d8d..a943003bd3 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/security/auth/amqplain/AmqPlainSaslServer.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/security/auth/amqplain/AmqPlainSaslServer.java
@@ -56,13 +56,13 @@ public class AmqPlainSaslServer implements SaslServer
try
{
final FieldTable ft = FieldTableFactory.newFieldTable(ByteBuffer.wrap(response), response.length);
- String username = (String) ft.get("LOGIN");
+ String username = (String) ft.getString("LOGIN");
// we do not care about the prompt but it throws if null
NameCallback nameCb = new NameCallback("prompt", username);
// we do not care about the prompt but it throws if null
PasswordCallback passwordCb = new PasswordCallback("prompt", false);
// TODO: should not get pwd as a String but as a char array...
- String pwd = (String) ft.get("PASSWORD");
+ String pwd = (String) ft.getString("PASSWORD");
passwordCb.setPassword(pwd.toCharArray());
AuthorizeCallback authzCb = new AuthorizeCallback(username, username);
Callback[] callbacks = new Callback[]{nameCb, passwordCb, authzCb};
diff --git a/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java b/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
index 10aa621f89..86ba96bf5d 100644
--- a/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
+++ b/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersBindingTest.java
@@ -37,157 +37,157 @@ public class HeadersBindingTest extends TestCase
{
bindHeaders.setString("A", "Value of A");
- matchHeaders.put("A", "Value of A");
+ matchHeaders.setString("A", "Value of A");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testDefault_2()
{
- bindHeaders.put("A", "Value of A");
+ bindHeaders.setString("A", "Value of A");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Value of B");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Value of B");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testDefault_3()
{
- bindHeaders.put("A", "Value of A");
+ bindHeaders.setString("A", "Value of A");
- matchHeaders.put("A", "Altered value of A");
+ matchHeaders.setString("A", "Altered value of A");
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAll_1()
{
- bindHeaders.put("X-match", "all");
- bindHeaders.put("A", "Value of A");
+ bindHeaders.setString("X-match", "all");
+ bindHeaders.setString("A", "Value of A");
- matchHeaders.put("A", "Value of A");
+ matchHeaders.setString("A", "Value of A");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAll_2()
{
- bindHeaders.put("X-match", "all");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "all");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
+ matchHeaders.setString("A", "Value of A");
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAll_3()
{
- bindHeaders.put("X-match", "all");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "all");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Value of B");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Value of B");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAll_4()
{
- bindHeaders.put("X-match", "all");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "all");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Value of B");
- matchHeaders.put("C", "Value of C");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Value of B");
+ matchHeaders.setString("C", "Value of C");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAll_5()
{
- bindHeaders.put("X-match", "all");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "all");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Altered value of B");
- matchHeaders.put("C", "Value of C");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Altered value of B");
+ matchHeaders.setString("C", "Value of C");
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_1()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
- matchHeaders.put("A", "Value of A");
+ matchHeaders.setString("A", "Value of A");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_2()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
+ matchHeaders.setString("A", "Value of A");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_3()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Value of B");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Value of B");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_4()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Value of B");
- matchHeaders.put("C", "Value of C");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Value of B");
+ matchHeaders.setString("C", "Value of C");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_5()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Value of A");
- matchHeaders.put("B", "Altered value of B");
- matchHeaders.put("C", "Value of C");
+ matchHeaders.setString("A", "Value of A");
+ matchHeaders.setString("B", "Altered value of B");
+ matchHeaders.setString("C", "Value of C");
assertTrue(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
public void testAny_6()
{
- bindHeaders.put("X-match", "any");
- bindHeaders.put("A", "Value of A");
- bindHeaders.put("B", "Value of B");
+ bindHeaders.setString("X-match", "any");
+ bindHeaders.setString("A", "Value of A");
+ bindHeaders.setString("B", "Value of B");
- matchHeaders.put("A", "Altered value of A");
- matchHeaders.put("B", "Altered value of B");
- matchHeaders.put("C", "Value of C");
+ matchHeaders.setString("A", "Altered value of A");
+ matchHeaders.setString("B", "Altered value of B");
+ matchHeaders.setString("C", "Value of C");
assertFalse(new HeadersBinding(bindHeaders).matches(matchHeaders));
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java b/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
index 6da0da9f6f..e59b6fbe19 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQBrokerDetails.java
@@ -308,7 +308,7 @@ public class AMQBrokerDetails implements BrokerDetails
}
}
- //remove the extra DEFAULT_OPTION_SEPERATOR or the '?' if there are no options
+ //removeKey the extra DEFAULT_OPTION_SEPERATOR or the '?' if there are no options
optionsURL.deleteCharAt(optionsURL.length() - 1);
return optionsURL.toString();
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
index 58ac49dd4e..a4d0065699 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
@@ -965,7 +965,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect
public void resubscribeSessions() throws JMSException, AMQException
{
ArrayList sessions = new ArrayList(_sessions.values());
- _logger.info(MessageFormat.format("Resubscribing sessions = {0} sessions.size={1}", sessions, sessions.size())); // FIXME: remove?
+ _logger.info(MessageFormat.format("Resubscribing sessions = {0} sessions.size={1}", sessions, sessions.size())); // FIXME: removeKey?
for (Iterator it = sessions.iterator(); it.hasNext();)
{
AMQSession s = (AMQSession) it.next();
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index c6f3f9c492..b634f48c1e 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -25,6 +25,7 @@ import org.apache.qpid.url.AMQBindingURL;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.url.URLHelper;
import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import javax.naming.Reference;
import javax.naming.NamingException;
@@ -35,19 +36,27 @@ import javax.jms.Destination;
public abstract class AMQDestination implements Destination, Referenceable
{
- protected final String _exchangeName;
+ protected final AMQShortString _exchangeName;
- protected final String _exchangeClass;
+ protected final AMQShortString _exchangeClass;
- protected final String _destinationName;
+ protected final AMQShortString _destinationName;
- protected boolean _isDurable;
+ protected final boolean _isDurable;
protected final boolean _isExclusive;
protected final boolean _isAutoDelete;
- protected String _queueName;
+ private AMQShortString _queueName;
+
+ private String _url;
+ private AMQShortString _urlAsShortString;
+
+ private byte[] _byteEncoding;
+ private static final int IS_DURABLE_MASK = 0x1;
+ private static final int IS_EXCLUSIVE_MASK = 0x2;
+ private static final int IS_AUTODELETE_MASK = 0x4;
protected AMQDestination(String url) throws URLSyntaxException
{
@@ -63,27 +72,27 @@ public abstract class AMQDestination implements Destination, Referenceable
_isExclusive = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_EXCLUSIVE));
_isAutoDelete = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_AUTODELETE));
_isDurable = Boolean.parseBoolean(binding.getOption(BindingURL.OPTION_DURABLE));
- _queueName = binding.getQueueName();
+ _queueName = new AMQShortString(binding.getQueueName());
}
- protected AMQDestination(String exchangeName, String exchangeClass, String destinationName, String queueName)
+ protected AMQDestination(AMQShortString exchangeName, AMQShortString exchangeClass, AMQShortString destinationName, AMQShortString queueName)
{
this(exchangeName, exchangeClass, destinationName, false, false, queueName);
}
- protected AMQDestination(String exchangeName, String exchangeClass, String destinationName)
+ protected AMQDestination(AMQShortString exchangeName, AMQShortString exchangeClass, AMQShortString destinationName)
{
this(exchangeName, exchangeClass, destinationName, false, false, null);
}
- protected AMQDestination(String exchangeName, String exchangeClass, String destinationName, boolean isExclusive,
- boolean isAutoDelete, String queueName)
+ protected AMQDestination(AMQShortString exchangeName, AMQShortString exchangeClass, AMQShortString destinationName, boolean isExclusive,
+ boolean isAutoDelete, AMQShortString queueName)
{
this(exchangeName, exchangeClass, destinationName, isExclusive, isAutoDelete, queueName, false);
}
- protected AMQDestination(String exchangeName, String exchangeClass, String destinationName, boolean isExclusive,
- boolean isAutoDelete, String queueName, boolean isDurable)
+ protected AMQDestination(AMQShortString exchangeName, AMQShortString exchangeClass, AMQShortString destinationName, boolean isExclusive,
+ boolean isAutoDelete, AMQShortString queueName, boolean isDurable)
{
if (destinationName == null)
{
@@ -106,9 +115,13 @@ public abstract class AMQDestination implements Destination, Referenceable
_isDurable = isDurable;
}
- public String getEncodedName()
+ public AMQShortString getEncodedName()
{
- return toURL();
+ if(_urlAsShortString == null)
+ {
+ toURL();
+ }
+ return _urlAsShortString;
}
public boolean isDurable()
@@ -116,12 +129,12 @@ public abstract class AMQDestination implements Destination, Referenceable
return _isDurable;
}
- public String getExchangeName()
+ public AMQShortString getExchangeName()
{
return _exchangeName;
}
- public String getExchangeClass()
+ public AMQShortString getExchangeClass()
{
return _exchangeClass;
}
@@ -136,22 +149,34 @@ public abstract class AMQDestination implements Destination, Referenceable
return ExchangeDefaults.DIRECT_EXCHANGE_NAME.equals(_exchangeName);
}
- public String getDestinationName()
+ public AMQShortString getDestinationName()
{
return _destinationName;
}
public String getQueueName()
{
+ return _queueName == null ? null : _queueName.toString();
+ }
+
+ public AMQShortString getAMQQueueName()
+ {
return _queueName;
}
- public void setQueueName(String queueName)
+
+
+ public void setQueueName(AMQShortString queueName)
{
+
_queueName = queueName;
+ // calculated URL now out of date
+ _url = null;
+ _urlAsShortString = null;
+ _byteEncoding = null;
}
- public abstract String getRoutingKey();
+ public abstract AMQShortString getRoutingKey();
public boolean isExclusive()
{
@@ -179,53 +204,114 @@ public abstract class AMQDestination implements Destination, Referenceable
public String toURL()
{
- StringBuffer sb = new StringBuffer();
+ String url = _url;
+ if(url == null)
+ {
- sb.append(_exchangeClass);
- sb.append("://");
- sb.append(_exchangeName);
- sb.append("/");
+ StringBuffer sb = new StringBuffer();
- if (_destinationName != null)
- {
- sb.append(_destinationName);
- }
+ sb.append(_exchangeClass);
+ sb.append("://");
+ sb.append(_exchangeName);
- sb.append("/");
+ sb.append('/');
- if (_queueName != null)
- {
- sb.append(_queueName);
- }
+ if (_destinationName != null)
+ {
+ sb.append(_destinationName);
+ }
- sb.append("?");
+ sb.append('/');
- if (_isDurable)
- {
- sb.append(BindingURL.OPTION_DURABLE);
- sb.append("='true'");
- sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
- }
+ if (_queueName != null)
+ {
+ sb.append(_queueName);
+ }
- if (_isExclusive)
- {
- sb.append(BindingURL.OPTION_EXCLUSIVE);
- sb.append("='true'");
- sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
- }
+ sb.append('?');
- if (_isAutoDelete)
- {
- sb.append(BindingURL.OPTION_AUTODELETE);
- sb.append("='true'");
- sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
+ if (_isDurable)
+ {
+ sb.append(BindingURL.OPTION_DURABLE);
+ sb.append("='true'");
+ sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
+ }
+
+ if (_isExclusive)
+ {
+ sb.append(BindingURL.OPTION_EXCLUSIVE);
+ sb.append("='true'");
+ sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
+ }
+
+ if (_isAutoDelete)
+ {
+ sb.append(BindingURL.OPTION_AUTODELETE);
+ sb.append("='true'");
+ sb.append(URLHelper.DEFAULT_OPTION_SEPERATOR);
+ }
+
+ //removeKey the last char '?' if there is no options , ',' if there are.
+ sb.deleteCharAt(sb.length() - 1);
+ url = sb.toString();
+ _url = url;
+ _urlAsShortString = new AMQShortString(url);
}
+ return url;
+ }
- //remove the last char '?' if there is no options , ',' if there are.
- sb.deleteCharAt(sb.length() - 1);
+ public byte[] toByteEncoding()
+ {
+ byte[] encoding = _byteEncoding;
+ if(encoding == null)
+ {
+ int size = _exchangeClass.length() + 1 +
+ _exchangeName.length() + 1 +
+ (_destinationName == null ? 0 : _destinationName.length()) + 1 +
+ (_queueName == null ? 0 : _queueName.length()) + 1 +
+ 1;
+ encoding = new byte[size];
+ int pos = 0;
+
+ pos = _exchangeClass.writeToByteArray(encoding, pos);
+ pos = _exchangeName.writeToByteArray(encoding, pos);
+ if(_destinationName == null)
+ {
+ encoding[pos++] = (byte)0;
+ }
+ else
+ {
+ pos = _destinationName.writeToByteArray(encoding,pos);
+ }
+ if(_queueName == null)
+ {
+ encoding[pos++] = (byte)0;
+ }
+ else
+ {
+ pos = _queueName.writeToByteArray(encoding,pos);
+ }
+ byte options = 0;
+ if(_isDurable)
+ {
+ options |= IS_DURABLE_MASK;
+ }
+ if(_isExclusive)
+ {
+ options |= IS_EXCLUSIVE_MASK;
+ }
+ if(_isAutoDelete)
+ {
+ options |= IS_AUTODELETE_MASK;
+ }
+ encoding[pos] = options;
+
+
+ _byteEncoding = encoding;
- return sb.toString();
+ }
+ return encoding;
}
public boolean equals(Object o)
@@ -293,9 +379,55 @@ public abstract class AMQDestination implements Destination, Referenceable
null); // factory location
}
+
+ public static Destination createDestination(byte[] byteEncodedDestination)
+ {
+ AMQShortString exchangeClass;
+ AMQShortString exchangeName;
+ AMQShortString destinationName;
+ AMQShortString queueName;
+ boolean isDurable;
+ boolean isExclusive;
+ boolean isAutoDelete;
+
+ int pos = 0;
+ exchangeClass = AMQShortString.readFromByteArray(byteEncodedDestination, pos);
+ pos+= exchangeClass.length() + 1;
+ exchangeName = AMQShortString.readFromByteArray(byteEncodedDestination, pos);
+ pos+= exchangeName.length() + 1;
+ destinationName = AMQShortString.readFromByteArray(byteEncodedDestination, pos);
+ pos+= (destinationName == null ? 0 : destinationName.length()) + 1;
+ queueName = AMQShortString.readFromByteArray(byteEncodedDestination, pos);
+ pos+= (queueName == null ? 0 : queueName.length()) + 1;
+ int options = byteEncodedDestination[pos];
+ isDurable = (options & IS_DURABLE_MASK) != 0;
+ isExclusive = (options & IS_EXCLUSIVE_MASK) != 0;
+ isAutoDelete = (options & IS_AUTODELETE_MASK) != 0;
+
+ if (exchangeClass.equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
+ {
+ return new AMQQueue(destinationName,queueName,isExclusive,isAutoDelete,isDurable);
+ }
+ else if (exchangeClass.equals(ExchangeDefaults.TOPIC_EXCHANGE_CLASS))
+ {
+ return new AMQTopic(destinationName,isAutoDelete,queueName,isDurable);
+ }
+ else if (exchangeClass.equals(ExchangeDefaults.HEADERS_EXCHANGE_CLASS))
+ {
+ return new AMQHeadersExchange(destinationName);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Exchange Class:" + exchangeClass);
+ }
+
+
+
+ }
+
public static Destination createDestination(BindingURL binding)
{
- String type = binding.getExchangeClass();
+ AMQShortString type = binding.getExchangeClass();
if (type.equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
{
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQHeadersExchange.java b/java/client/src/main/java/org/apache/qpid/client/AMQHeadersExchange.java
index c6d21c0ea7..b3dea770fa 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQHeadersExchange.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQHeadersExchange.java
@@ -22,6 +22,7 @@ package org.apache.qpid.client;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.url.BindingURL;
+import org.apache.qpid.framing.AMQShortString;
/**
* A destination backed by a headers exchange
@@ -33,12 +34,17 @@ public class AMQHeadersExchange extends AMQDestination
this(binding.getExchangeName());
}
- public AMQHeadersExchange(String queueName)
+ public AMQHeadersExchange(String name)
+ {
+ this(new AMQShortString(name));
+ }
+
+ public AMQHeadersExchange(AMQShortString queueName)
{
super(queueName, ExchangeDefaults.HEADERS_EXCHANGE_CLASS, queueName, true, true, null);
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
return getDestinationName();
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java b/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
index 6c0da6112a..39a5ffc0b8 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQQueue.java
@@ -22,6 +22,7 @@ package org.apache.qpid.client;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.Queue;
@@ -42,12 +43,22 @@ public class AMQQueue extends AMQDestination implements Queue
* Create a reference to a non temporary queue. Note this does not actually imply the queue exists.
* @param name the name of the queue
*/
- public AMQQueue(String name)
+ public AMQQueue(AMQShortString name)
{
this(name, false);
}
/**
+ * Create a reference to a non temporary queue. Note this does not actually imply the queue exists.
+ * @param name the name of the queue
+ */
+ public AMQQueue(String name)
+ {
+ this(new AMQShortString(name), false);
+ }
+
+
+ /**
* Create a queue with a specified name.
*
* @param name the destination name (used in the routing key)
@@ -56,10 +67,23 @@ public class AMQQueue extends AMQDestination implements Queue
*/
public AMQQueue(String name, boolean temporary)
{
+ this(new AMQShortString(name),temporary);
+ }
+
+
+ /**
+ * Create a queue with a specified name.
+ *
+ * @param name the destination name (used in the routing key)
+ * @param temporary if true the broker will generate a queue name, also if true then the queue is autodeleted
+ * and exclusive
+ */
+ public AMQQueue(AMQShortString name, boolean temporary)
+ {
// queue name is set to null indicating that the broker assigns a name in the case of temporary queues
// temporary queues are typically used as response queues
- this(name, temporary?null:name, temporary, temporary);
- _isDurable = !temporary;
+ this(name, temporary?null:name, temporary, temporary, !temporary);
+
}
/**
@@ -69,16 +93,22 @@ public class AMQQueue extends AMQDestination implements Queue
* @param exclusive true if the queue should only permit a single consumer
* @param autoDelete true if the queue should be deleted automatically when the last consumers detaches
*/
- public AMQQueue(String destinationName, String queueName, boolean exclusive, boolean autoDelete)
+ public AMQQueue(AMQShortString destinationName, AMQShortString queueName, boolean exclusive, boolean autoDelete)
+ {
+ this(destinationName, queueName, exclusive, autoDelete, false);
+ }
+
+
+ public AMQQueue(AMQShortString destinationName, AMQShortString queueName, boolean exclusive, boolean autoDelete, boolean durable)
{
super(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS, destinationName, exclusive,
- autoDelete, queueName);
+ autoDelete, queueName, durable);
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
- return getQueueName();
+ return getAMQQueueName();
}
public boolean isNameRequired()
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index 0dfd469d8d..be240cc39e 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -26,10 +26,7 @@ import org.apache.qpid.AMQUndeliveredException;
import org.apache.qpid.AMQInvalidSelectorException;
import org.apache.qpid.common.AMQPFilterTypes;
import org.apache.qpid.client.failover.FailoverSupport;
-import org.apache.qpid.client.message.AbstractJMSMessage;
-import org.apache.qpid.client.message.JMSStreamMessage;
-import org.apache.qpid.client.message.MessageFactoryRegistry;
-import org.apache.qpid.client.message.UnprocessedMessage;
+import org.apache.qpid.client.message.*;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
import org.apache.qpid.client.protocol.AMQMethodEvent;
import org.apache.qpid.client.util.FlowControllingBlockingQueue;
@@ -104,7 +101,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
/**
* Maps from consumer tag (String) to JMSMessageConsumer instance
*/
- private Map<String, BasicMessageConsumer> _consumers = new ConcurrentHashMap<String, BasicMessageConsumer>();
+ private Map<AMQShortString, BasicMessageConsumer> _consumers = new ConcurrentHashMap<AMQShortString, BasicMessageConsumer>();
/**
* Maps from destination to count of JMSMessageConsumers
@@ -205,7 +202,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
message.bodies);
int errorCode = message.bounceBody.replyCode;
- String reason = message.bounceBody.replyText;
+ AMQShortString reason = message.bounceBody.replyText;
_logger.debug("Message returned with error code " + errorCode + " (" + reason + ")");
//@TODO should this be moved to an exception handler of sorts. Somewhere errors are converted to correct execeptions.
@@ -322,14 +319,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
synchronized(_connection.getFailoverMutex())
{
checkNotClosed();
- try
- {
- return (BytesMessage) _messageFactoryRegistry.createMessage("application/octet-stream");
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create message: " + e);
- }
+ return new JMSBytesMessage();
}
}
@@ -338,31 +328,13 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
synchronized(_connection.getFailoverMutex())
{
checkNotClosed();
- try
- {
- return (MapMessage) _messageFactoryRegistry.createMessage("jms/map-message");
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create message: " + e);
- }
+ return new JMSMapMessage();
}
}
public javax.jms.Message createMessage() throws JMSException
{
- synchronized(_connection.getFailoverMutex())
- {
- checkNotClosed();
- try
- {
- return (BytesMessage) _messageFactoryRegistry.createMessage("application/octet-stream");
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create message: " + e);
- }
- }
+ return createBytesMessage();
}
public ObjectMessage createObjectMessage() throws JMSException
@@ -370,33 +342,15 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
synchronized(_connection.getFailoverMutex())
{
checkNotClosed();
- try
- {
- return (ObjectMessage) _messageFactoryRegistry.createMessage("application/java-object-stream");
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create message: " + e);
- }
+ return (ObjectMessage) new JMSObjectMessage();
}
}
public ObjectMessage createObjectMessage(Serializable object) throws JMSException
{
- synchronized(_connection.getFailoverMutex())
- {
- checkNotClosed();
- try
- {
- ObjectMessage msg = (ObjectMessage) _messageFactoryRegistry.createMessage("application/java-object-stream");
- msg.setObject(object);
- return msg;
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create message: " + e);
- }
- }
+ ObjectMessage msg = createObjectMessage();
+ msg.setObject(object);
+ return msg;
}
public StreamMessage createStreamMessage() throws JMSException
@@ -405,14 +359,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
{
checkNotClosed();
- try
- {
- return (StreamMessage) _messageFactoryRegistry.createMessage(JMSStreamMessage.MIME_TYPE);
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create text message: " + e);
- }
+ return new JMSStreamMessage();
}
}
@@ -422,33 +369,16 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
{
checkNotClosed();
- try
- {
- return (TextMessage) _messageFactoryRegistry.createMessage("text/plain");
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create text message: " + e);
- }
+ return new JMSTextMessage();
}
}
public TextMessage createTextMessage(String text) throws JMSException
{
- synchronized(_connection.getFailoverMutex())
- {
- checkNotClosed();
- try
- {
- TextMessage msg = (TextMessage) _messageFactoryRegistry.createMessage("text/plain");
- msg.setText(text);
- return msg;
- }
- catch (AMQException e)
- {
- throw new JMSException("Unable to create text message: " + e);
- }
- }
+
+ TextMessage msg = createTextMessage();
+ msg.setText(text);
+ return msg;
}
public boolean getTransacted() throws JMSException
@@ -530,7 +460,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
0, // classId
0, // methodId
AMQConstant.REPLY_SUCCESS.getCode(), // replyCode
- "JMS client closing channel"); // replyText
+ new AMQShortString("JMS client closing channel")); // replyText
_connection.getProtocolHandler().syncWrite(frame, ChannelCloseOkBody.class);
// When control resumes at this point, a reply will have been received that
// indicates the broker has closed the channel successfully
@@ -1050,12 +980,12 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
}
- public void declareExchange(String name, String type)
+ public void declareExchange(AMQShortString name, AMQShortString type)
{
declareExchange(name, type, _connection.getProtocolHandler());
}
- public void declareExchangeSynch(String name, String type) throws AMQException
+ public void declareExchangeSynch(AMQShortString name, AMQShortString type) throws AMQException
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
@@ -1079,7 +1009,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
declareExchange(amqd.getExchangeName(), amqd.getExchangeClass(), protocolHandler);
}
- private void declareExchange(String name, String type, AMQProtocolHandler protocolHandler)
+ private void declareExchange(AMQShortString name, AMQShortString type, AMQProtocolHandler protocolHandler)
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
@@ -1106,7 +1036,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
* @return the queue name. This is useful where the broker is generating a queue name on behalf of the client.
* @throws AMQException
*/
- private String declareQueue(AMQDestination amqd, AMQProtocolHandler protocolHandler) throws AMQException
+ private AMQShortString declareQueue(AMQDestination amqd, AMQProtocolHandler protocolHandler) throws AMQException
{
// For queues (but not topics) we generate the name in the client rather than the
// server. This allows the name to be reused on failover if required. In general,
@@ -1127,14 +1057,14 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
amqd.isExclusive(), // exclusive
true, // nowait
false, // passive
- amqd.getQueueName(), // queue
+ amqd.getAMQQueueName(), // queue
0); // ticket
protocolHandler.writeFrame(queueDeclare);
- return amqd.getQueueName();
+ return amqd.getAMQQueueName();
}
- private void bindQueue(AMQDestination amqd, String queueName, AMQProtocolHandler protocolHandler, FieldTable ft) throws AMQException
+ private void bindQueue(AMQDestination amqd, AMQShortString queueName, AMQProtocolHandler protocolHandler, FieldTable ft) throws AMQException
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
@@ -1157,12 +1087,12 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
* @param queueName
* @return the consumer tag generated by the broker
*/
- private void consumeFromQueue(BasicMessageConsumer consumer, String queueName, AMQProtocolHandler protocolHandler,
+ private void consumeFromQueue(BasicMessageConsumer consumer, AMQShortString queueName, AMQProtocolHandler protocolHandler,
boolean nowait, String messageSelector) throws AMQException
{
//fixme prefetch values are not used here. Do we need to have them as parametsrs?
//need to generate a consumer tag on the client so we can exploit the nowait flag
- String tag = Integer.toString(_nextTag++);
+ AMQShortString tag = new AMQShortString(Integer.toString(_nextTag++));
FieldTable arguments = FieldTableFactory.newFieldTable();
if (messageSelector != null && !messageSelector.equals(""))
@@ -1282,7 +1212,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
if (topicName.indexOf('/') == -1)
{
- return new AMQTopic(topicName);
+ return new AMQTopic(new AMQShortString(topicName));
}
else
{
@@ -1352,12 +1282,21 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
}
else
{
+ AMQShortString topicName;
+ if(topic instanceof AMQTopic)
+ {
+ topicName = ((AMQTopic)topic).getDestinationName();
+ }
+ else
+ {
+ topicName = new AMQShortString(topic.getTopicName());
+ }
// if the queue is bound to the exchange but NOT for this topic, then the JMS spec
// says we must trash the subscription.
- if (isQueueBound(dest.getQueueName()) &&
- !isQueueBound(dest.getQueueName(), topic.getTopicName()))
+ if (isQueueBound(dest.getAMQQueueName()) &&
+ !isQueueBound(dest.getAMQQueueName(), topicName))
{
- deleteQueue(dest.getQueueName());
+ deleteQueue(dest.getAMQQueueName());
}
}
@@ -1369,7 +1308,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
return subscriber;
}
- void deleteQueue(String queueName) throws JMSException
+ void deleteQueue(AMQShortString queueName) throws JMSException
{
try
{
@@ -1461,12 +1400,12 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
}
}
- boolean isQueueBound(String queueName) throws JMSException
+ boolean isQueueBound(AMQShortString queueName) throws JMSException
{
return isQueueBound(queueName, null);
}
- boolean isQueueBound(String queueName, String routingKey) throws JMSException
+ boolean isQueueBound(AMQShortString queueName, AMQShortString routingKey) throws JMSException
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
@@ -1606,7 +1545,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
declareExchange(amqd, protocolHandler);
- String queueName = declareQueue(amqd, protocolHandler);
+ AMQShortString queueName = declareQueue(amqd, protocolHandler);
bindQueue(amqd, queueName, protocolHandler, consumer.getRawSelectorFieldTable());
@@ -1674,7 +1613,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
private void resubscribeProducers() throws AMQException
{
ArrayList producers = new ArrayList(_producers.values());
- _logger.info(MessageFormat.format("Resubscribing producers = {0} producers.size={1}", producers, producers.size())); // FIXME: remove
+ _logger.info(MessageFormat.format("Resubscribing producers = {0} producers.size={1}", producers, producers.size())); // FIXME: removeKey
for (Iterator it = producers.iterator(); it.hasNext();)
{
BasicMessageProducer producer = (BasicMessageProducer) it.next();
@@ -1718,7 +1657,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
_connection.getProtocolHandler().writeFrame(channelFlowFrame);
}
- public void confirmConsumerCancelled(String consumerTag)
+ public void confirmConsumerCancelled(AMQShortString consumerTag)
{
BasicMessageConsumer consumer = (BasicMessageConsumer) _consumers.get(consumerTag);
if((consumer != null) && (consumer.isAutoClose()))
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
index 81fee69f90..18c655a829 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQTemporaryQueue.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.client;
+import org.apache.qpid.framing.AMQShortString;
+
import javax.jms.JMSException;
import javax.jms.TemporaryQueue;
@@ -38,7 +40,7 @@ final class AMQTemporaryQueue extends AMQQueue implements TemporaryQueue, Tempor
*/
public AMQTemporaryQueue(AMQSession session)
{
- super("TempQueue" + Long.toString(System.currentTimeMillis()), true);
+ super(new AMQShortString("TempQueue" + Long.toString(System.currentTimeMillis())), true);
_session = session;
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java b/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
index 39304f3f4c..9b8a6686d3 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQTopic.java
@@ -22,6 +22,7 @@ package org.apache.qpid.client;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.JMSException;
import javax.jms.Topic;
@@ -40,10 +41,15 @@ public class AMQTopic extends AMQDestination implements Topic
public AMQTopic(String name)
{
+ this(new AMQShortString(name));
+ }
+
+ public AMQTopic(AMQShortString name)
+ {
this(name, true, null, false);
}
- public AMQTopic(String name, boolean isAutoDelete, String queueName, boolean isDurable)
+ public AMQTopic(AMQShortString name, boolean isAutoDelete, AMQShortString queueName, boolean isDurable)
{
super(ExchangeDefaults.TOPIC_EXCHANGE_NAME, ExchangeDefaults.TOPIC_EXCHANGE_CLASS, name, true, isAutoDelete,
queueName, isDurable);
@@ -56,17 +62,17 @@ public class AMQTopic extends AMQDestination implements Topic
true);
}
- public static String getDurableTopicQueueName(String subscriptionName, AMQConnection connection) throws JMSException
+ public static AMQShortString getDurableTopicQueueName(String subscriptionName, AMQConnection connection) throws JMSException
{
- return connection.getClientID() + ":" + subscriptionName;
+ return new AMQShortString(connection.getClientID() + ":" + subscriptionName);
}
public String getTopicName() throws JMSException
{
- return super.getDestinationName();
+ return super.getDestinationName().toString();
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
return getDestinationName();
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
index 1033e827de..c5e97a27f6 100644
--- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
+++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
@@ -22,16 +22,11 @@ package org.apache.qpid.client;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.client.message.AbstractJMSMessage;
import org.apache.qpid.client.message.MessageFactoryRegistry;
import org.apache.qpid.client.message.UnprocessedMessage;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.BasicCancelBody;
-import org.apache.qpid.framing.BasicCancelOkBody;
-import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.*;
import org.apache.qpid.jms.MessageConsumer;
import org.apache.qpid.jms.Session;
@@ -74,7 +69,7 @@ public class BasicMessageConsumer extends Closeable implements MessageConsumer
* The consumer tag allows us to close the consumer by sending a jmsCancel method to the
* broker
*/
- private String _consumerTag;
+ private AMQShortString _consumerTag;
/**
* We need to know the channel id when constructing frames
@@ -255,17 +250,10 @@ public class BasicMessageConsumer extends Closeable implements MessageConsumer
if(_session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE)
{
_unacknowledgedDeliveryTags.add(jmsMsg.getDeliveryTag());
- String url = jmsMsg.getStringProperty(CustomJMXProperty.JMSX_QPID_JMSDESTINATIONURL.toString());
- try
- {
- Destination dest = AMQDestination.createDestination(new AMQBindingURL(url));
- jmsMsg.setJMSDestination(dest);
- }
- catch (URLSyntaxException e)
- {
- _logger.warn("Unable to parse the supplied destination header: " + url);
- }
-
+ byte[] url = jmsMsg.getBytesProperty(CustomJMSXProperty.JMSX_QPID_JMSDESTINATIONURL.getShortStringName());
+ Destination dest = AMQDestination.createDestination(url);
+ jmsMsg.setJMSDestination(dest);
+
}
_session.setInRecovery(false);
}
@@ -498,7 +486,9 @@ public class BasicMessageConsumer extends Closeable implements MessageConsumer
*/
void notifyMessage(UnprocessedMessage messageFrame, int channelId)
{
- if (_logger.isDebugEnabled())
+ final boolean debug = _logger.isDebugEnabled();
+
+ if (debug)
{
_logger.debug("notifyMessage called with message number " + messageFrame.deliverBody.deliveryTag);
}
@@ -509,7 +499,10 @@ public class BasicMessageConsumer extends Closeable implements MessageConsumer
messageFrame.contentHeader,
messageFrame.bodies);
- _logger.debug("Message is of type: " + jmsMessage.getClass().getName());
+ if(debug)
+ {
+ _logger.debug("Message is of type: " + jmsMessage.getClass().getName());
+ }
jmsMessage.setConsumer(this);
preDeliver(jmsMessage);
@@ -642,12 +635,12 @@ public class BasicMessageConsumer extends Closeable implements MessageConsumer
_session.deregisterConsumer(this);
}
- public String getConsumerTag()
+ public AMQShortString getConsumerTag()
{
return _consumerTag;
}
- public void setConsumerTag(String consumerTag)
+ public void setConsumerTag(AMQShortString consumerTag)
{
_consumerTag = consumerTag;
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
index d38e461400..56b8f44e56 100644
--- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
+++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
@@ -522,7 +522,7 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j
AbstractJMSMessage message = convertToNativeMessage(origMessage);
- message.getJmsContentHeaderProperties().getJMSHeaders().setString(CustomJMXProperty.JMSX_QPID_JMSDESTINATIONURL.toString(), destination.toURL());
+ message.getJmsContentHeaderProperties().setBytes(CustomJMSXProperty.JMSX_QPID_JMSDESTINATIONURL.getShortStringName(), destination.toByteEncoding());
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.
@@ -534,26 +534,22 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j
destination.getRoutingKey(), // routingKey
0); // ticket
- long currentTime = 0;
- if (!_disableTimestamps)
- {
- currentTime = System.currentTimeMillis();
- message.setJMSTimestamp(currentTime);
- }
+
+
message.prepareForSending();
ByteBuffer payload = message.getData();
BasicContentHeaderProperties contentHeaderProperties = message.getJmsContentHeaderProperties();
- if (timeToLive > 0)
+ if (!_disableTimestamps)
{
- if (!_disableTimestamps)
+ final long currentTime = System.currentTimeMillis();
+ contentHeaderProperties.setTimestamp(currentTime);
+
+ if (timeToLive > 0)
{
contentHeaderProperties.setExpiration(currentTime + timeToLive);
}
- }
- else
- {
- if (!_disableTimestamps)
+ else
{
contentHeaderProperties.setExpiration(0);
}
@@ -561,14 +557,16 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j
contentHeaderProperties.setDeliveryMode((byte) deliveryMode);
contentHeaderProperties.setPriority((byte) priority);
- int size = (payload != null) ? payload.limit() : 0;
- ContentBody[] contentBodies = createContentBodies(payload);
- AMQFrame[] frames = new AMQFrame[2 + contentBodies.length];
- for (int i = 0; i < contentBodies.length; i++)
+ final int size = (payload != null) ? payload.limit() : 0;
+ final int contentBodyFrameCount = calculateContentBodyFrameCount(payload);
+ final AMQFrame[] frames = new AMQFrame[2 + contentBodyFrameCount];
+
+ if(payload != null)
{
- frames[2 + i] = ContentBody.createAMQFrame(_channelId, contentBodies[i]);
+ createContentBodies(payload, frames, 2, _channelId);
}
- if (contentBodies.length > 0 && _logger.isDebugEnabled())
+
+ if (contentBodyFrameCount != 0 && _logger.isDebugEnabled())
{
_logger.debug("Sending content body frames to " + destination);
}
@@ -592,10 +590,10 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j
if (message != origMessage)
{
- _logger.warn("Updating original message");
+ _logger.debug("Updating original message");
origMessage.setJMSPriority(message.getJMSPriority());
origMessage.setJMSTimestamp(message.getJMSTimestamp());
- _logger.warn("Setting JMSExpiration:" + message.getJMSExpiration());
+ _logger.debug("Setting JMSExpiration:" + message.getJMSExpiration());
origMessage.setJMSExpiration(message.getJMSExpiration());
origMessage.setJMSMessageID(message.getJMSMessageID());
}
@@ -625,42 +623,52 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j
* maximum frame size.
*
* @param payload
- * @return the array of content bodies
+ * @param frames
+ * @param offset
+ * @param channelId @return the array of content bodies
*/
- private ContentBody[] createContentBodies(ByteBuffer payload)
+ private void createContentBodies(ByteBuffer payload, AMQFrame[] frames, int offset, int channelId)
{
- if (payload == null || payload.remaining() == 0)
- {
- return NO_CONTENT_BODIES;
- }
- // we substract one from the total frame maximum size to account for the end of frame marker in a body frame
- // (0xCE byte).
- int dataLength = payload.remaining();
- final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
- int lastFrame = (dataLength % framePayloadMax) > 0 ? 1 : 0;
- int frameCount = (int) (dataLength / framePayloadMax) + lastFrame;
- final ContentBody[] bodies = new ContentBody[frameCount];
-
- if (frameCount == 1)
+ if (frames.length == offset + 1)
{
- bodies[0] = new ContentBody();
- bodies[0].payload = payload;
+ frames[offset] = ContentBody.createAMQFrame(channelId,new ContentBody(payload));
}
else
{
- long remaining = dataLength;
- for (int i = 0; i < bodies.length; i++)
+
+ final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
+ long remaining = payload.remaining();
+ for (int i = offset; i < frames.length; i++)
{
- bodies[i] = new ContentBody();
- payload.position((int) framePayloadMax * i);
+ payload.position((int) framePayloadMax * (i-offset));
int length = (remaining >= framePayloadMax) ? (int) framePayloadMax : (int) remaining;
payload.limit(payload.position() + length);
- bodies[i].payload = payload.slice();
+ frames[i] = ContentBody.createAMQFrame(channelId,new ContentBody(payload.slice()));
+
remaining -= length;
}
}
- return bodies;
+
+ }
+
+ private int calculateContentBodyFrameCount(ByteBuffer payload)
+ {
+ // we substract one from the total frame maximum size to account for the end of frame marker in a body frame
+ // (0xCE byte).
+ int frameCount;
+ if(payload == null || payload.remaining() == 0)
+ {
+ frameCount = 0;
+ }
+ else
+ {
+ int dataLength = payload.remaining();
+ final long framePayloadMax = _session.getAMQConnection().getMaximumFrameSize() - 1;
+ int lastFrame = (dataLength % framePayloadMax) > 0 ? 1 : 0;
+ frameCount = (int) (dataLength / framePayloadMax) + lastFrame;
+ }
+ return frameCount;
}
public void setMimeType(String mimeType) throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/CustomJMXProperty.java b/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
index 3a7b7a7b3d..26e26781c0 100644
--- a/java/client/src/main/java/org/apache/qpid/client/CustomJMXProperty.java
+++ b/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
@@ -20,23 +20,38 @@
*/
package org.apache.qpid.client;
+import org.apache.qpid.framing.AMQShortString;
+
import java.util.*;
-public enum CustomJMXProperty
+public enum CustomJMSXProperty
{
JMSX_QPID_JMSDESTINATIONURL,
JMSXGroupID,
JMSXGroupSeq;
+
+ private final AMQShortString _nameAsShortString;
+
+ CustomJMSXProperty()
+ {
+ _nameAsShortString = new AMQShortString(toString());
+ }
+
+ public AMQShortString getShortStringName()
+ {
+ return _nameAsShortString;
+ }
+
private static Enumeration _names;
public static synchronized Enumeration asEnumeration()
{
if(_names == null)
{
- CustomJMXProperty[] properties = values();
+ CustomJMSXProperty[] properties = values();
ArrayList<String> nameList = new ArrayList<String>(properties.length);
- for(CustomJMXProperty property : properties)
+ for(CustomJMSXProperty property : properties)
{
nameList.add(property.toString());
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java b/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
index 9ee802ff10..7749bded2c 100644
--- a/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
+++ b/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
@@ -56,7 +56,7 @@ public class QpidConnectionMetaData implements ConnectionMetaData
public Enumeration getJMSXPropertyNames() throws JMSException
{
- return CustomJMXProperty.asEnumeration();
+ return CustomJMSXProperty.asEnumeration();
}
public int getProviderMajorVersion() throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
index 278f0906ea..dbc1512b2f 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java
@@ -33,6 +33,7 @@ import org.apache.qpid.client.state.StateAwareMethodListener;
import org.apache.qpid.framing.AMQFrame;
import org.apache.qpid.framing.ChannelCloseBody;
import org.apache.qpid.framing.ChannelCloseOkBody;
+import org.apache.qpid.framing.AMQShortString;
public class ChannelCloseMethodHandler implements StateAwareMethodListener
{
@@ -51,7 +52,7 @@ public class ChannelCloseMethodHandler implements StateAwareMethodListener
ChannelCloseBody method = (ChannelCloseBody) evt.getMethod();
int errorCode = method.replyCode;
- String reason = method.replyText;
+ AMQShortString reason = method.replyText;
if (_logger.isDebugEnabled())
{
_logger.debug("Channel close reply code: " + errorCode + ", reason: " + reason);
@@ -77,7 +78,7 @@ public class ChannelCloseMethodHandler implements StateAwareMethodListener
{
_logger.info("Broker responded with Invalid Selector.");
- throw new AMQInvalidSelectorException(reason);
+ throw new AMQInvalidSelectorException(String.valueOf(reason));
}
else
{
@@ -85,6 +86,6 @@ public class ChannelCloseMethodHandler implements StateAwareMethodListener
}
}
- evt.getProtocolSession().channelClosed(evt.getChannelId(), errorCode, reason);
+ evt.getProtocolSession().channelClosed(evt.getChannelId(), errorCode, String.valueOf(reason));
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
index bbfb100b25..bd1be5d629 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java
@@ -31,6 +31,7 @@ import org.apache.qpid.client.state.StateAwareMethodListener;
import org.apache.qpid.client.AMQAuthenticationException;
import org.apache.qpid.framing.ConnectionCloseBody;
import org.apache.qpid.framing.ConnectionCloseOkBody;
+import org.apache.qpid.framing.AMQShortString;
public class ConnectionCloseMethodHandler implements StateAwareMethodListener
{
@@ -56,7 +57,7 @@ public class ConnectionCloseMethodHandler implements StateAwareMethodListener
//stateManager.changeState(AMQState.CONNECTION_CLOSING);
int errorCode = method.replyCode;
- String reason = method.replyText;
+ AMQShortString reason = method.replyText;
// TODO: check whether channel id of zero is appropriate
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
@@ -75,7 +76,7 @@ public class ConnectionCloseMethodHandler implements StateAwareMethodListener
//todo this is a bit of a fudge (could be conssidered such as each new connection needs a new state manager or at least a fresh state.
stateManager.changeState(AMQState.CONNECTION_NOT_STARTED);
- throw new AMQAuthenticationException(errorCode, reason);
+ throw new AMQAuthenticationException(errorCode, reason == null ? null : reason.toString());
}
else
{
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
index a658e3e787..5580d02895 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionRedirectMethodHandler.java
@@ -49,19 +49,20 @@ public class ConnectionRedirectMethodHandler implements StateAwareMethodListener
_logger.info("ConnectionRedirect frame received");
ConnectionRedirectBody method = (ConnectionRedirectBody) evt.getMethod();
+ String host = method.host.toString();
// the host is in the form hostname:port with the port being optional
- int portIndex = method.host.indexOf(':');
- String host;
+ int portIndex = host.indexOf(':');
+
int port;
if (portIndex == -1)
{
- host = method.host;
port = DEFAULT_REDIRECT_PORT;
}
else
{
- host = method.host.substring(0, portIndex);
- port = Integer.parseInt(method.host.substring(portIndex + 1));
+ port = Integer.parseInt(host.substring(portIndex + 1));
+ host = host.substring(0, portIndex);
+
}
evt.getProtocolSession().failover(host, port);
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
index 8640bbb999..6f206735fe 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
@@ -31,10 +31,7 @@ import org.apache.qpid.client.security.CallbackHandlerRegistry;
import org.apache.qpid.client.state.AMQState;
import org.apache.qpid.client.state.AMQStateManager;
import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.framing.ConnectionStartBody;
-import org.apache.qpid.framing.ConnectionStartOkBody;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.qpid.framing.FieldTableFactory;
+import org.apache.qpid.framing.*;
import javax.security.sasl.Sasl;
import javax.security.sasl.SaslClient;
@@ -122,18 +119,18 @@ public class ConnectionStartMethodHandler implements StateAwareMethodListener
stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
FieldTable clientProperties = FieldTableFactory.newFieldTable();
- clientProperties.put(ClientProperties.instance.toString(), ps.getClientID());
- clientProperties.put(ClientProperties.product.toString(), QpidProperties.getProductName());
- clientProperties.put(ClientProperties.version.toString(), QpidProperties.getReleaseVersion());
- clientProperties.put(ClientProperties.platform.toString(), getFullSystemInfo());
+ clientProperties.setString(ClientProperties.instance.toString(), ps.getClientID());
+ clientProperties.setString(ClientProperties.product.toString(), QpidProperties.getProductName());
+ clientProperties.setString(ClientProperties.version.toString(), QpidProperties.getReleaseVersion());
+ clientProperties.setString(ClientProperties.platform.toString(), getFullSystemInfo());
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.
ps.writeFrame(ConnectionStartOkBody.createAMQFrame(evt.getChannelId(),
(byte)8, (byte)0, // AMQP version (major, minor)
clientProperties, // clientProperties
- selectedLocale, // locale
- mechanism, // mechanism
+ new AMQShortString(selectedLocale), // locale
+ new AMQShortString(mechanism), // mechanism
saslResponse)); // response
}
catch (UnsupportedEncodingException e)
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
index 3592ee4c53..604202a742 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java
@@ -28,10 +28,7 @@ import org.apache.qpid.client.protocol.AMQProtocolSession;
import org.apache.qpid.client.state.AMQState;
import org.apache.qpid.client.state.AMQStateManager;
import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.framing.ConnectionOpenBody;
-import org.apache.qpid.framing.ConnectionTuneBody;
-import org.apache.qpid.framing.ConnectionTuneOkBody;
-import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.*;
public class ConnectionTuneMethodHandler implements StateAwareMethodListener
{
@@ -67,10 +64,10 @@ public class ConnectionTuneMethodHandler implements StateAwareMethodListener
stateManager.changeState(AMQState.CONNECTION_NOT_OPENED);
session.writeFrame(createTuneOkFrame(evt.getChannelId(), params));
- session.writeFrame(createConnectionOpenFrame(evt.getChannelId(), session.getAMQConnection().getVirtualHost(), null, true));
+ session.writeFrame(createConnectionOpenFrame(evt.getChannelId(), new AMQShortString(session.getAMQConnection().getVirtualHost()), null, true));
}
- protected AMQFrame createConnectionOpenFrame(int channel, String path, String capabilities, boolean insist)
+ protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist)
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
index 011f7c09ab..5fb8de3690 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
@@ -55,7 +55,7 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage
AbstractBytesMessage(ByteBuffer data)
{
super(data); // this instanties a content header
- getJmsContentHeaderProperties().setContentType(getMimeType());
+ getJmsContentHeaderProperties().setContentType(getMimeTypeAsShortString());
if (_data == null)
{
@@ -74,7 +74,7 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage
{
// TODO: this casting is ugly. Need to review whole ContentHeaderBody idea
super(messageNbr, (BasicContentHeaderProperties) contentHeader.properties, data);
- getJmsContentHeaderProperties().setContentType(getMimeType());
+ getJmsContentHeaderProperties().setContentType(getMimeTypeAsShortString());
}
public void clearBodyImpl() throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
index 0c29344c37..4a0d3283b0 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
@@ -30,6 +30,7 @@ import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.BasicMessageConsumer;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -168,7 +169,7 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
}
final AMQDestination amqd = (AMQDestination) destination;
- final String encodedDestination = amqd.getEncodedName();
+ final AMQShortString encodedDestination = amqd.getEncodedName();
_destinationCache.put(encodedDestination, destination);
getJmsContentHeaderProperties().setReplyTo(encodedDestination);
}
@@ -235,7 +236,7 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
public void clearProperties() throws JMSException
{
- getJmsContentHeaderProperties().getJMSHeaders().clear();
+ getJmsContentHeaderProperties().clear();
_readableProperties = false;
}
@@ -247,139 +248,168 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
}
+ public boolean propertyExists(AMQShortString propertyName) throws JMSException
+ {
+ checkPropertyName(propertyName);
+ return getJmsContentHeaderProperties().propertyExists(propertyName);
+ }
+
+
public boolean propertyExists(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().propertyExists(propertyName);
+ return getJmsContentHeaderProperties().propertyExists(propertyName);
}
+ public boolean getBooleanProperty(AMQShortString propertyName) throws JMSException
+ {
+ checkPropertyName(propertyName);
+
+ return getJmsContentHeaderProperties().getBoolean(propertyName);
+ }
+
+
public boolean getBooleanProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getBoolean(propertyName);
+ return getJmsContentHeaderProperties().getBoolean(propertyName);
}
public byte getByteProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getByte(propertyName);
+ return getJmsContentHeaderProperties().getByte(propertyName);
}
public short getShortProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getShort(propertyName);
+ return getJmsContentHeaderProperties().getShort(propertyName);
}
public int getIntProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getInteger(propertyName);
+ return getJmsContentHeaderProperties().getInteger(propertyName);
}
public long getLongProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getLong(propertyName);
+ return getJmsContentHeaderProperties().getLong(propertyName);
}
public float getFloatProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getFloat(propertyName);
+ return getJmsContentHeaderProperties().getFloat(propertyName);
}
public double getDoubleProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getDouble(propertyName);
+ return getJmsContentHeaderProperties().getDouble(propertyName);
}
public String getStringProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getString(propertyName);
+ return getJmsContentHeaderProperties().getString(propertyName);
}
public Object getObjectProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getJMSHeaders().getObject(propertyName);
+ return getJmsContentHeaderProperties().getObject(propertyName);
}
public Enumeration getPropertyNames() throws JMSException
{
- return getJmsContentHeaderProperties().getJMSHeaders().getPropertyNames();
+ return getJmsContentHeaderProperties().getPropertyNames();
+ }
+
+ public void setBooleanProperty(AMQShortString propertyName, boolean b) throws JMSException
+ {
+ checkWritableProperties();
+ checkPropertyName(propertyName);
+ getJmsContentHeaderProperties().setBoolean(propertyName, b);
}
public void setBooleanProperty(String propertyName, boolean b) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setBoolean(propertyName, b);
+ getJmsContentHeaderProperties().setBoolean(propertyName, b);
}
public void setByteProperty(String propertyName, byte b) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setByte(propertyName, new Byte(b));
+ getJmsContentHeaderProperties().setByte(propertyName, new Byte(b));
}
public void setShortProperty(String propertyName, short i) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setShort(propertyName, new Short(i));
+ getJmsContentHeaderProperties().setShort(propertyName, new Short(i));
}
public void setIntProperty(String propertyName, int i) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setInteger(propertyName, new Integer(i));
+ getJmsContentHeaderProperties().setInteger(propertyName, new Integer(i));
}
public void setLongProperty(String propertyName, long l) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setLong(propertyName, new Long(l));
+ getJmsContentHeaderProperties().setLong(propertyName, new Long(l));
}
public void setFloatProperty(String propertyName, float f) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setFloat(propertyName, new Float(f));
+ getJmsContentHeaderProperties().setFloat(propertyName, new Float(f));
}
public void setDoubleProperty(String propertyName, double v) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setDouble(propertyName, new Double(v));
+ getJmsContentHeaderProperties().setDouble(propertyName, new Double(v));
}
public void setStringProperty(String propertyName, String value) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setString(propertyName, value);
+ getJmsContentHeaderProperties().setString(propertyName, value);
}
public void setObjectProperty(String propertyName, Object object) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().setObject(propertyName, object);
+ getJmsContentHeaderProperties().setObject(propertyName, object);
}
+ protected void removeProperty(AMQShortString propertyName) throws JMSException
+ {
+ checkPropertyName(propertyName);
+ getJmsContentHeaderProperties().remove(propertyName);
+ }
+
+
protected void removeProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getJMSHeaders().remove(propertyName);
+ getJmsContentHeaderProperties().remove(propertyName);
}
public void acknowledgeThis() throws JMSException
@@ -421,7 +451,12 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
*/
public abstract String toBodyString() throws JMSException;
- public abstract String getMimeType();
+ public String getMimeType()
+ {
+ return getMimeTypeAsShortString().toString();
+ }
+
+ public abstract AMQShortString getMimeTypeAsShortString();
public String toString()
{
@@ -436,13 +471,13 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
buf.append("\nJMS reply to: ").append(String.valueOf(getJMSReplyTo()));
buf.append("\nAMQ message number: ").append(_deliveryTag);
buf.append("\nProperties:");
- if (getJmsContentHeaderProperties().getJMSHeaders().isEmpty())
+ if (getJmsContentHeaderProperties().isEmpty())
{
buf.append("<NONE>");
}
else
{
- buf.append('\n').append(getJmsContentHeaderProperties().getJMSHeaders());
+ buf.append('\n').append(getJmsContentHeaderProperties().getHeaders());
}
return buf.toString();
}
@@ -458,13 +493,13 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
getJmsContentHeaderProperties().setHeaders(messageProperties);
}
- private void checkPropertyName(String propertyName)
+ private void checkPropertyName(CharSequence propertyName)
{
if (propertyName == null)
{
throw new IllegalArgumentException("Property name must not be null");
}
- else if ("".equals(propertyName))
+ else if (propertyName.length()==0)
{
throw new IllegalArgumentException("Property name must not be the empty string");
}
@@ -537,4 +572,11 @@ public abstract class AbstractJMSMessage extends AMQMessage implements org.apach
{
_consumer = basicMessageConsumer;
}
+
+ public byte[] getBytesProperty(AMQShortString propertyName) throws JMSException
+ {
+ checkPropertyName(propertyName);
+ return getJmsContentHeaderProperties().getBytes(propertyName);
+
+ }
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
index dcff8c348b..4b28a43c64 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
@@ -43,16 +43,23 @@ public abstract class AbstractJMSMessageFactory implements MessageFactory
List bodies) throws AMQException
{
ByteBuffer data;
+ final boolean debug = _logger.isDebugEnabled();
// we optimise the non-fragmented case to avoid copying
if (bodies != null && bodies.size() == 1)
{
- _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.bodySize +")");
+ if(debug)
+ {
+ _logger.debug("Non-fragmented message body (bodySize=" + contentHeader.bodySize +")");
+ }
data = ((ContentBody)bodies.get(0)).payload;
}
else
{
- _logger.debug("Fragmented message body (" + bodies.size() + " frames, bodySize=" + contentHeader.bodySize + ")");
+ if(debug)
+ {
+ _logger.debug("Fragmented message body (" + bodies.size() + " frames, bodySize=" + contentHeader.bodySize + ")");
+ }
data = ByteBuffer.allocate((int)contentHeader.bodySize); // XXX: Is cast a problem?
final Iterator it = bodies.iterator();
while (it.hasNext())
@@ -63,7 +70,10 @@ public abstract class AbstractJMSMessageFactory implements MessageFactory
}
data.flip();
}
- _logger.debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data.remaining());
+ if(debug)
+ {
+ _logger.debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data.remaining());
+ }
return createMessage(messageNbr, data, contentHeader);
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
index d769300c69..ec7ef453eb 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java
@@ -23,6 +23,7 @@ package org.apache.qpid.client.message;
import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
@@ -35,9 +36,11 @@ import java.nio.CharBuffer;
public class JMSBytesMessage extends AbstractBytesMessage implements BytesMessage
{
- private static final String MIME_TYPE = "application/octet-stream";
+ public static final String MIME_TYPE = "application/octet-stream";
+ private static final AMQShortString MIME_TYPE_SHORT_STRING = new AMQShortString(MIME_TYPE);
- JMSBytesMessage()
+
+ public JMSBytesMessage()
{
this(null);
}
@@ -65,9 +68,9 @@ public class JMSBytesMessage extends AbstractBytesMessage implements BytesMessag
_readableMessage = true;
}
- public String getMimeType()
+ public AMQShortString getMimeTypeAsShortString()
{
- return MIME_TYPE;
+ return MIME_TYPE_SHORT_STRING;
}
public long getBodyLength() throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
index 88e78a1dad..fcbb6500d4 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
@@ -22,6 +22,7 @@ package org.apache.qpid.client.message;
import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.AMQException;
import org.apache.log4j.Logger;
@@ -37,10 +38,11 @@ public class JMSMapMessage extends AbstractBytesTypedMessage implements javax.jm
public static final String MIME_TYPE = "jms/map-message";
+ private static final AMQShortString MIME_TYPE_SHORT_STRING = new AMQShortString(MIME_TYPE);
private Map<String,Object> _map = new HashMap<String, Object>();
- JMSMapMessage() throws JMSException
+ public JMSMapMessage() throws JMSException
{
this(null);
}
@@ -74,9 +76,9 @@ public class JMSMapMessage extends AbstractBytesTypedMessage implements javax.jm
return _map.toString();
}
- public String getMimeType()
+ public AMQShortString getMimeTypeAsShortString()
{
- return MIME_TYPE;
+ return MIME_TYPE_SHORT_STRING;
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
index 35c5377f14..ae29cef901 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
@@ -24,6 +24,7 @@ import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.JMSException;
import javax.jms.MessageFormatException;
@@ -34,14 +35,15 @@ import java.nio.charset.Charset;
public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessage
{
- static final String MIME_TYPE = "application/java-object-stream";
+ public static final String MIME_TYPE = "application/java-object-stream";
+ private static final AMQShortString MIME_TYPE_SHORT_STRING = new AMQShortString(MIME_TYPE);
private static final int DEFAULT_BUFFER_SIZE = 1024;
/**
* Creates empty, writable message for use by producers
*/
- JMSObjectMessage()
+ public JMSObjectMessage()
{
this(null);
}
@@ -54,7 +56,7 @@ public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessag
_data = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
_data.setAutoExpand(true);
}
- getJmsContentHeaderProperties().setContentType(MIME_TYPE);
+ getJmsContentHeaderProperties().setContentType(MIME_TYPE_SHORT_STRING);
}
/**
@@ -80,9 +82,9 @@ public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessag
return toString(_data);
}
- public String getMimeType()
+ public AMQShortString getMimeTypeAsShortString()
{
- return MIME_TYPE;
+ return MIME_TYPE_SHORT_STRING;
}
public void setObject(Serializable serializable) throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
index 972a5fc8bf..747b97b11c 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessage.java
@@ -23,6 +23,7 @@ package org.apache.qpid.client.message;
import org.apache.mina.common.ByteBuffer;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.*;
import java.nio.charset.CharacterCodingException;
@@ -34,6 +35,7 @@ import java.nio.charset.Charset;
public class JMSStreamMessage extends AbstractBytesTypedMessage implements StreamMessage
{
public static final String MIME_TYPE="jms/stream-message";
+ private static final AMQShortString MIME_TYPE_SHORT_STRING = new AMQShortString(MIME_TYPE);
/**
@@ -42,7 +44,7 @@ public class JMSStreamMessage extends AbstractBytesTypedMessage implements Strea
*/
private int _byteArrayRemaining = -1;
- JMSStreamMessage()
+ public JMSStreamMessage()
{
this(null);
}
@@ -71,9 +73,9 @@ public class JMSStreamMessage extends AbstractBytesTypedMessage implements Strea
_readableMessage = true;
}
- public String getMimeType()
+ public AMQShortString getMimeTypeAsShortString()
{
- return MIME_TYPE;
+ return MIME_TYPE_SHORT_STRING;
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
index d8394b0489..f386346dd1 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java
@@ -21,6 +21,7 @@
package org.apache.qpid.client.message;
import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.AMQException;
import org.apache.mina.common.ByteBuffer;
@@ -32,15 +33,18 @@ import java.nio.charset.CharacterCodingException;
public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.TextMessage
{
private static final String MIME_TYPE = "text/plain";
+ private static final AMQShortString MIME_TYPE_SHORT_STRING = new AMQShortString(MIME_TYPE);
+
private String _decodedValue;
/**
* This constant represents the name of a property that is set when the message payload is null.
*/
- private static final String PAYLOAD_NULL_PROPERTY = "JMS_QPID_NULL";
+ private static final AMQShortString PAYLOAD_NULL_PROPERTY = new AMQShortString("JMS_QPID_NULL");
+ private static final Charset DEFAULT_CHARSET = Charset.defaultCharset();
- JMSTextMessage() throws JMSException
+ public JMSTextMessage() throws JMSException
{
this(null, null);
}
@@ -48,7 +52,7 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text
JMSTextMessage(ByteBuffer data, String encoding) throws JMSException
{
super(data); // this instantiates a content header
- getJmsContentHeaderProperties().setContentType(MIME_TYPE);
+ getJmsContentHeaderProperties().setContentType(MIME_TYPE_SHORT_STRING);
getJmsContentHeaderProperties().setEncoding(encoding);
}
@@ -56,7 +60,7 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text
throws AMQException
{
super(deliveryTag, contentHeader, data);
- contentHeader.setContentType(MIME_TYPE);
+ contentHeader.setContentType(MIME_TYPE_SHORT_STRING);
_data = data;
}
@@ -91,9 +95,9 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text
_data = data;
}
- public String getMimeType()
+ public AMQShortString getMimeTypeAsShortString()
{
- return MIME_TYPE;
+ return MIME_TYPE_SHORT_STRING;
}
public void setText(String text) throws JMSException
@@ -109,13 +113,14 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text
_data.limit(text.length()) ;
//_data.sweep();
_data.setAutoExpand(true);
- if (getJmsContentHeaderProperties().getEncoding() == null)
+ final String encoding = getJmsContentHeaderProperties().getEncoding();
+ if (encoding == null)
{
_data.put(text.getBytes());
}
else
{
- _data.put(text.getBytes(getJmsContentHeaderProperties().getEncoding()));
+ _data.put(text.getBytes(encoding));
}
_changedData=true;
}
@@ -164,7 +169,7 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text
{
try
{
- _decodedValue = _data.getString(Charset.defaultCharset().newDecoder());
+ _decodedValue = _data.getString(DEFAULT_CHARSET.newDecoder());
}
catch (CharacterCodingException e)
{
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java b/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
index 348988f06d..df7537f1e8 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
@@ -23,6 +23,7 @@ package org.apache.qpid.client.message;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.JMSException;
import java.util.HashMap;
@@ -31,7 +32,8 @@ import java.util.List;
public class MessageFactoryRegistry
{
- private final Map _mimeToFactoryMap = new HashMap();
+ private final Map<String, MessageFactory> _mimeStringToFactoryMap = new HashMap<String, MessageFactory>();
+ private final Map<AMQShortString, MessageFactory> _mimeShortStringToFactoryMap = new HashMap<AMQShortString, MessageFactory>();
public void registerFactory(String mimeType, MessageFactory mf)
{
@@ -39,12 +41,14 @@ public class MessageFactoryRegistry
{
throw new IllegalArgumentException("Message factory must not be null");
}
- _mimeToFactoryMap.put(mimeType, mf);
+ _mimeStringToFactoryMap.put(mimeType, mf);
+ _mimeShortStringToFactoryMap.put(new AMQShortString(mimeType), mf);
}
public MessageFactory deregisterFactory(String mimeType)
{
- return (MessageFactory) _mimeToFactoryMap.remove(mimeType);
+ _mimeShortStringToFactoryMap.remove(new AMQShortString(mimeType));
+ return _mimeStringToFactoryMap.remove(mimeType);
}
/**
@@ -63,7 +67,7 @@ public class MessageFactoryRegistry
List bodies) throws AMQException, JMSException
{
BasicContentHeaderProperties properties = (BasicContentHeaderProperties) contentHeader.properties;
- MessageFactory mf = (MessageFactory) _mimeToFactoryMap.get(properties.getContentType());
+ MessageFactory mf = _mimeShortStringToFactoryMap.get(properties.getContentTypeShortString());
if (mf == null)
{
throw new AMQException("Unsupport MIME type of " + properties.getContentType());
@@ -80,7 +84,7 @@ public class MessageFactoryRegistry
{
throw new IllegalArgumentException("Mime type must not be null");
}
- MessageFactory mf = (MessageFactory) _mimeToFactoryMap.get(mimeType);
+ MessageFactory mf = _mimeStringToFactoryMap.get(mimeType);
if (mf == null)
{
throw new AMQException("Unsupport MIME type of " + mimeType);
@@ -101,7 +105,7 @@ public class MessageFactoryRegistry
mf.registerFactory(JMSMapMessage.MIME_TYPE, new JMSMapMessageFactory());
mf.registerFactory("text/plain", new JMSTextMessageFactory());
mf.registerFactory("text/xml", new JMSTextMessageFactory());
- mf.registerFactory("application/octet-stream", new JMSBytesMessageFactory());
+ mf.registerFactory(JMSBytesMessage.MIME_TYPE, new JMSBytesMessageFactory());
mf.registerFactory(JMSObjectMessage.MIME_TYPE, new JMSObjectMessageFactory());
mf.registerFactory(JMSStreamMessage.MIME_TYPE, new JMSStreamMessageFactory());
mf.registerFactory(null, new JMSBytesMessageFactory());
diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
index f37af835e1..bd60b2c250 100644
--- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
@@ -37,14 +37,7 @@ import org.apache.qpid.client.state.AMQState;
import org.apache.qpid.client.state.AMQStateManager;
import org.apache.qpid.client.state.listener.SpecificMethodFrameListener;
import org.apache.qpid.codec.AMQCodecFactory;
-import org.apache.qpid.framing.AMQDataBlock;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ConnectionCloseOkBody;
-import org.apache.qpid.framing.ContentBody;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.HeartbeatBody;
+import org.apache.qpid.framing.*;
import org.apache.qpid.protocol.AMQConstant;
import org.apache.qpid.ssl.BogusSSLContextFactory;
@@ -99,7 +92,7 @@ public class AMQProtocolHandler extends IoHandlerAdapter
// We add a proxy for the state manager so that we can substitute the state manager easily in this class.
// We substitute the state manager when performing failover
- _frameListeners.add(new AMQMethodListener()
+/* _frameListeners.add(new AMQMethodListener()
{
public boolean methodReceived(AMQMethodEvent evt) throws AMQException
{
@@ -110,7 +103,7 @@ public class AMQProtocolHandler extends IoHandlerAdapter
{
_stateManager.error(e);
}
- });
+ });*/
}
public boolean isUseSSL()
@@ -284,11 +277,14 @@ public class AMQProtocolHandler extends IoHandlerAdapter
public void propagateExceptionToWaiters(Exception e)
{
_stateManager.error(e);
- final Iterator it = _frameListeners.iterator();
- while (it.hasNext())
+ if(!_frameListeners.isEmpty())
{
- final AMQMethodListener ml = (AMQMethodListener) it.next();
- ml.error(e);
+ final Iterator it = _frameListeners.iterator();
+ while (it.hasNext())
+ {
+ final AMQMethodListener ml = (AMQMethodListener) it.next();
+ ml.error(e);
+ }
}
}
@@ -296,12 +292,13 @@ public class AMQProtocolHandler extends IoHandlerAdapter
public void messageReceived(IoSession session, Object message) throws Exception
{
+ final long msgNumber = ++_messageReceivedCount;
- if (_messageReceivedCount++ % 1000 == 0)
+ if (_logger.isDebugEnabled() && (msgNumber % 1000 == 0))
{
_logger.debug("Received " + _messageReceivedCount + " protocol messages");
}
- Iterator it = _frameListeners.iterator();
+
AMQFrame frame = (AMQFrame) message;
HeartbeatDiagnostics.received(frame.bodyFrame instanceof HeartbeatBody);
@@ -314,13 +311,19 @@ public class AMQProtocolHandler extends IoHandlerAdapter
}
final AMQMethodEvent evt = new AMQMethodEvent(frame.channel, (AMQMethodBody) frame.bodyFrame, _protocolSession);
+
try
{
- boolean wasAnyoneInterested = false;
- while (it.hasNext())
+
+ boolean wasAnyoneInterested = _stateManager.methodReceived(evt);
+ if(!_frameListeners.isEmpty())
{
- final AMQMethodListener listener = (AMQMethodListener) it.next();
- wasAnyoneInterested = listener.methodReceived(evt) || wasAnyoneInterested;
+ Iterator it = _frameListeners.iterator();
+ while (it.hasNext())
+ {
+ final AMQMethodListener listener = (AMQMethodListener) it.next();
+ wasAnyoneInterested = listener.methodReceived(evt) || wasAnyoneInterested;
+ }
}
if (!wasAnyoneInterested)
{
@@ -329,11 +332,15 @@ public class AMQProtocolHandler extends IoHandlerAdapter
}
catch (AMQException e)
{
- it = _frameListeners.iterator();
- while (it.hasNext())
+ _stateManager.error(e);
+ if(!_frameListeners.isEmpty())
{
- final AMQMethodListener listener = (AMQMethodListener) it.next();
- listener.error(e);
+ Iterator it = _frameListeners.iterator();
+ while (it.hasNext())
+ {
+ final AMQMethodListener listener = (AMQMethodListener) it.next();
+ listener.error(e);
+ }
}
exceptionCaught(session, e);
}
@@ -359,17 +366,21 @@ public class AMQProtocolHandler extends IoHandlerAdapter
public void messageSent(IoSession session, Object message) throws Exception
{
- if (_messagesOut++ % 1000 == 0)
+ final long sentMessages = _messagesOut++;
+
+ final boolean debug = _logger.isDebugEnabled();
+
+ if (debug && (sentMessages % 1000 == 0))
{
_logger.debug("Sent " + _messagesOut + " protocol messages");
}
_connection.bytesSent(session.getWrittenBytes());
- if (_logger.isDebugEnabled())
+ if (debug)
{
_logger.debug("Sent frame " + message);
}
}
-
+/*
public void addFrameListener(AMQMethodListener listener)
{
_frameListeners.add(listener);
@@ -379,7 +390,7 @@ public class AMQProtocolHandler extends IoHandlerAdapter
{
_frameListeners.remove(listener);
}
-
+ */
public void attainState(AMQState s) throws AMQException
{
_stateManager.attainState(s);
@@ -423,9 +434,13 @@ public class AMQProtocolHandler extends IoHandlerAdapter
// When control resumes before this line, a reply will have been received
// that matches the criteria defined in the blocking listener
}
+ catch (AMQException e)
+ {
+ throw e;
+ }
finally
{
- // If we don't remove the listener then no-one will
+ // If we don't removeKey the listener then no-one will
_frameListeners.remove(listener);
}
@@ -480,7 +495,7 @@ public class AMQProtocolHandler extends IoHandlerAdapter
0, // classId
0, // methodId
AMQConstant.REPLY_SUCCESS.getCode(), // replyCode
- "JMS client is closing the connection."); // replyText
+ new AMQShortString("JMS client is closing the connection.")); // replyText
syncWrite(frame, ConnectionCloseOkBody.class);
_protocolSession.closeProtocolSession();
@@ -518,7 +533,7 @@ public class AMQProtocolHandler extends IoHandlerAdapter
}
}
- public String generateQueueName()
+ public AMQShortString generateQueueName()
{
return _protocolSession.generateQueueName();
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
index 6a40fd3133..ca622a98ba 100644
--- a/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
+++ b/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java
@@ -31,11 +31,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.ConnectionTuneParameters;
import org.apache.qpid.client.message.UnexpectedBodyReceivedException;
import org.apache.qpid.client.message.UnprocessedMessage;
-import org.apache.qpid.framing.AMQDataBlock;
-import org.apache.qpid.framing.ContentBody;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.ProtocolInitiation;
-import org.apache.qpid.framing.ProtocolVersionList;
+import org.apache.qpid.framing.*;
import org.apache.commons.lang.StringUtils;
import javax.jms.JMSException;
@@ -381,7 +377,7 @@ public class AMQProtocolSession implements ProtocolVersionList
_protocolHandler.failover(host, port);
}
- protected String generateQueueName()
+ protected AMQShortString generateQueueName()
{
int id;
synchronized(_queueIdLock)
@@ -390,7 +386,7 @@ public class AMQProtocolSession implements ProtocolVersionList
}
//get rid of / and : and ; from address for spec conformance
String localAddress = StringUtils.replaceChars(_minaProtocolSession.getLocalAddress().toString(),"/;:","");
- return "tmp_" + localAddress + "_" + id;
+ return new AMQShortString("tmp_" + localAddress + "_" + id);
}
/**
@@ -407,7 +403,7 @@ public class AMQProtocolSession implements ProtocolVersionList
}
}
- public void confirmConsumerCancelled(int channelId, String consumerTag)
+ public void confirmConsumerCancelled(int channelId, AMQShortString consumerTag)
{
final Integer chId = channelId;
final AMQSession session = (AMQSession) _channelId2SessionMap.get(chId);
diff --git a/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java b/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
index 4291cb3259..ddbea9a557 100644
--- a/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
+++ b/java/client/src/main/java/org/apache/qpid/client/security/amqplain/AmqPlainSaslClient.java
@@ -73,8 +73,8 @@ public class AmqPlainSaslClient implements SaslClient
throw new SaslException("Error handling SASL callbacks: " + e, e);
}
FieldTable table = FieldTableFactory.newFieldTable();
- table.put("LOGIN", nameCallback.getName());
- table.put("PASSWORD", pwdCallback.getPassword());
+ table.setString("LOGIN", nameCallback.getName());
+ table.setString("PASSWORD", new String(pwdCallback.getPassword()));
return table.getDataAsBytes();
}
diff --git a/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java b/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
index 5497cafed4..b724bbfc05 100644
--- a/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
+++ b/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
@@ -29,6 +29,7 @@ import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.url.AMQBindingURL;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.url.URLSyntaxException;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
@@ -232,10 +233,14 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor
*/
protected Queue createQueue(Object value)
{
- if (value instanceof String)
+ if(value instanceof AMQShortString)
+ {
+ return new AMQQueue((AMQShortString) value);
+ }
+ else if (value instanceof String)
{
- return new AMQQueue((String) value);
+ return new AMQQueue(new AMQShortString((String) value));
}
else if (value instanceof BindingURL)
@@ -251,9 +256,13 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor
*/
protected Topic createTopic(Object value)
{
- if (value instanceof String)
+ if(value instanceof AMQShortString)
+ {
+ return new AMQTopic((AMQShortString)value);
+ }
+ else if (value instanceof String)
{
- return new AMQTopic((String) value);
+ return new AMQTopic(new AMQShortString((String) value));
}
else if (value instanceof BindingURL)
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
index d12ab01bdc..a1763ddc73 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
@@ -25,6 +25,8 @@ import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.exchange.ExchangeDefaults;
import javax.jms.*;
@@ -50,10 +52,10 @@ public class RecoverTest extends TestCase
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue queue = new AMQQueue("someQ", "someQ", false, true);
+ Queue queue = new AMQQueue(new AMQShortString("someQ"), new AMQShortString("someQ"), false, true);
MessageConsumer consumer = consumerSession.createConsumer(queue);
//force synch to ensure the consumer has resulted in a bound queue
- ((AMQSession) consumerSession).declareExchangeSynch("amq.direct", "direct");
+ ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_NAME);
Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -107,10 +109,10 @@ public class RecoverTest extends TestCase
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue queue = new AMQQueue("someQ", "someQ", false, true);
+ Queue queue = new AMQQueue(new AMQShortString("someQ"), new AMQShortString("someQ"), false, true);
MessageConsumer consumer = consumerSession.createConsumer(queue);
//force synch to ensure the consumer has resulted in a bound queue
- ((AMQSession) consumerSession).declareExchangeSynch("amq.direct", "direct");
+ ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_NAME);
Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -171,8 +173,8 @@ public class RecoverTest extends TestCase
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue queue = new AMQQueue("Q1", "Q1", false, true);
- Queue queue2 = new AMQQueue("Q2", "Q2", false, true);
+ Queue queue = new AMQQueue(new AMQShortString("Q1"), new AMQShortString("Q1"), false, true);
+ Queue queue2 = new AMQQueue(new AMQShortString("Q2"), new AMQShortString("Q2"), false, true);
MessageConsumer consumer = consumerSession.createConsumer(queue);
MessageConsumer consumer2 = consumerSession.createConsumer(queue2);
@@ -210,7 +212,7 @@ public class RecoverTest extends TestCase
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
final Session consumerSession = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = new AMQQueue("Q1", "Q1", false, true);
+ Queue queue = new AMQQueue(new AMQShortString("Q1"), new AMQShortString("Q1"), false, true);
MessageProducer producer = consumerSession.createProducer(queue);
producer.send(consumerSession.createTextMessage("hello"));
MessageConsumer consumer = consumerSession.createConsumer(queue);
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
index ad180e3a89..fb347053c7 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableKeyEnumeratorTest.java
@@ -35,16 +35,20 @@ import junit.framework.TestCase;
public class FieldTableKeyEnumeratorTest extends TestCase
{
+ public void testTrue()
+ {
+
+ }
public void testKeyEnumeration()
{
FieldTable result = FieldTableFactory.newFieldTable();
- result.put("one", 1L);
- result.put("two", 2L);
- result.put("three", 3L);
- result.put("four", 4L);
- result.put("five", 5L);
+ result.setObject("one", 1L);
+ result.setObject("two", 2L);
+ result.setObject("three", 3L);
+ result.setObject("four", 4L);
+ result.setObject("five", 5L);
- Iterator iterator = result.keySet().iterator();
+ Iterator iterator = result.keys().iterator();
try
{
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
index f4efd64dbb..5af55d6625 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
@@ -85,11 +85,11 @@ public class FieldTableMessageTest extends TestCase implements MessageListener
private FieldTable load() throws IOException
{
FieldTable result = FieldTableFactory.newFieldTable();
- result.put("one", 1L);
- result.put("two", 2L);
- result.put("three", 3L);
- result.put("four", 4L);
- result.put("five", 5L);
+ result.setLong("one", 1L);
+ result.setLong("two", 2L);
+ result.setLong("three", 3L);
+ result.setLong("four", 4L);
+ result.setLong("five", 5L);
return result;
}
@@ -133,10 +133,9 @@ public class FieldTableMessageTest extends TestCase implements MessageListener
{
ByteBuffer buffer = ((JMSBytesMessage) m).getData();
FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
- for (Object o : _expected.keySet())
- {
- String key = (String) o;
- assertEquals("Values for " + key + " did not match", _expected.get(key), actual.get(key));
+ for (String key : _expected.keys())
+ {
+ assertEquals("Values for " + key + " did not match", _expected.getObject(key), actual.getObject(key));
}
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
index 17679788bd..7423a3d8f0 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
@@ -29,12 +29,7 @@ import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.message.JMSTextMessage;
import org.apache.qpid.testutil.VMBrokerSetup;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
+import javax.jms.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -81,7 +76,7 @@ public class PropertyValueTest extends TestCase implements MessageListener
{
_connection = connection;
_destination = destination;
- _session = (AMQSession) connection.createSession(false, AMQSession.AUTO_ACKNOWLEDGE);
+ _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//set up a slow consumer
_session.createConsumer(destination).setMessageListener(this);
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
index 903f6a9da9..81481bc94d 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
@@ -75,7 +75,7 @@ public class TextMessageTest extends TestCase implements MessageListener
{
_connection = connection;
_destination = destination;
- _session = (AMQSession) connection.createSession(false, AMQSession.AUTO_ACKNOWLEDGE);
+ _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//set up a slow consumer
_session.createConsumer(destination).setMessageListener(this);
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
index 22015dbc93..691acbb213 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/SpecialQueue.java
@@ -21,6 +21,7 @@
package org.apache.qpid.test.unit.client.forwardall;
import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.framing.AMQShortString;
/**
* Queue that allows several private queues to be registered and bound
@@ -29,15 +30,19 @@ import org.apache.qpid.client.AMQQueue;
*/
class SpecialQueue extends AMQQueue
{
- private final String name;
+ private final AMQShortString name;
SpecialQueue(String name)
{
+ this(new AMQShortString(name));
+ }
+ SpecialQueue(AMQShortString name)
+ {
super(name, true);
this.name = name;
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
return name;
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
index eee9b2de9f..64898a1b9a 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/protocol/AMQProtocolSessionTest.java
@@ -23,6 +23,7 @@ package org.apache.qpid.test.unit.client.protocol;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.protocol.AMQProtocolHandler;
import org.apache.qpid.client.protocol.AMQProtocolSession;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.mina.common.IoSession;
import junit.framework.TestCase;
@@ -45,7 +46,7 @@ public class AMQProtocolSessionTest extends TestCase
return (TestIoSession) _minaProtocolSession;
}
- public String genQueueName()
+ public AMQShortString genQueueName()
{
return generateQueueName();
}
@@ -80,26 +81,26 @@ public class AMQProtocolSessionTest extends TestCase
public void testGenerateQueueName()
{
- String testAddress;
+ AMQShortString testAddress;
- //test address with / and ; chars which generateQueueName should remove
+ //test address with / and ; chars which generateQueueName should removeKey
_testSession.getMinaProtocolSession().setStringLocalAddress(_brokenAddress);
_testSession.getMinaProtocolSession().setLocalPort(_port);
testAddress = _testSession.genQueueName();
- assertEquals("Failure when generating a queue exchange from an address with special chars",_generatedAddress,testAddress);
+ assertEquals("Failure when generating a queue exchange from an address with special chars",_generatedAddress,testAddress.toString());
//test empty address
_testSession.getMinaProtocolSession().setStringLocalAddress(_emptyAddress);
testAddress = _testSession.genQueueName();
- assertEquals("Failure when generating a queue exchange from an empty address",_generatedAddress_2,testAddress);
+ assertEquals("Failure when generating a queue exchange from an empty address",_generatedAddress_2,testAddress.toString());
//test address with no special chars
_testSession.getMinaProtocolSession().setStringLocalAddress(_validAddress);
testAddress = _testSession.genQueueName();
- assertEquals("Failure when generating a queue exchange from an address with no special chars",_generatedAddress_3,testAddress);
+ assertEquals("Failure when generating a queue exchange from an address with no special chars",_generatedAddress_3,testAddress.toString());
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/message/JMSDestinationTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/message/JMSDestinationTest.java
index c14b5317c7..23e3b9cc88 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/message/JMSDestinationTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/message/JMSDestinationTest.java
@@ -11,6 +11,7 @@ import org.apache.qpid.url.AMQBindingURL;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import javax.jms.*;
@@ -41,7 +42,7 @@ public class JMSDestinationTest extends TestCase
{
Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Queue queue = new AMQQueue("someQ", "someQ", false, true);
+ Queue queue = new AMQQueue(new AMQShortString("someQ"), new AMQShortString("someQ"), false, true);
MessageConsumer consumer = consumerSession.createConsumer(queue);
Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
index 794316d2f5..8a6e279142 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/topic/TopicSessionTest.java
@@ -170,7 +170,7 @@ public class TopicSessionTest extends TestCase
con.start();
TextMessage tm = session1.createTextMessage("Hello");
publisher.publish(tm);
- tm = (TextMessage) consumer1.receive(2000);
+ tm = (TextMessage) consumer1.receive(200000L);
assertNotNull(tm);
String msgText = tm.getText();
assertEquals("Hello", msgText);
@@ -178,7 +178,7 @@ public class TopicSessionTest extends TestCase
msgText = tm.getText();
assertNull(msgText);
publisher.publish(tm);
- tm = (TextMessage) consumer1.receive(2000);
+ tm = (TextMessage) consumer1.receive(20000000L);
assertNotNull(tm);
msgText = tm.getText();
assertNull(msgText);
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java
index c604709078..3c1b50fb99 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java
@@ -29,13 +29,7 @@ import org.apache.qpid.client.state.AMQState;
import org.apache.qpid.client.state.AMQStateManager;
import org.apache.qpid.client.state.IllegalStateTransitionException;
import org.apache.qpid.client.state.StateAwareMethodListener;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ConnectionOpenOkBody;
-import org.apache.qpid.framing.ConnectionSecureBody;
-import org.apache.qpid.framing.ConnectionStartBody;
-import org.apache.qpid.framing.ConnectionTuneBody;
+import org.apache.qpid.framing.*;
import java.util.HashMap;
import java.util.Map;
@@ -127,9 +121,9 @@ public class ClientHandlerRegistry extends AMQStateManager
class ConnectionTuneHandler extends ConnectionTuneMethodHandler
{
- protected AMQFrame createConnectionOpenFrame(int channel, String path, String capabilities, boolean insist)
+ protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist)
{
- return super.createConnectionOpenFrame(channel, path, ClusterCapability.add(capabilities, _identity), insist);
+ return super.createConnectionOpenFrame(channel, path, new AMQShortString(ClusterCapability.add(capabilities, _identity)), insist);
}
}
}
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClusterCapability.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClusterCapability.java
index 0411019334..57c48f0611 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClusterCapability.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClusterCapability.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.cluster;
+import org.apache.qpid.framing.AMQShortString;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -28,22 +30,22 @@ public class ClusterCapability
public static final String PATTERN = ".*\\bcluster_peer=(\\S*:\\d*)\b*.*";
public static final String PEER = "cluster_peer";
- public static String add(String original, MemberHandle identity)
+ public static AMQShortString add(AMQShortString original, MemberHandle identity)
{
- return original == null ? peer(identity) : original + " " + peer(identity);
+ return original == null ? peer(identity) : new AMQShortString(original + " " + peer(identity));
}
- private static String peer(MemberHandle identity)
+ private static AMQShortString peer(MemberHandle identity)
{
- return PEER + "=" + identity.getDetails();
+ return new AMQShortString(PEER + "=" + identity.getDetails());
}
- public static boolean contains(String in)
+ public static boolean contains(AMQShortString in)
{
- return in != null && in.contains(in);
+ return in != null; // && in.contains(in);
}
- public static MemberHandle getPeer(String in)
+ public static MemberHandle getPeer(AMQShortString in)
{
Matcher matcher = Pattern.compile(PATTERN).matcher(in);
if (matcher.matches())
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/DefaultGroupManager.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/DefaultGroupManager.java
index a7936be8db..d8d2220a8e 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/DefaultGroupManager.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/DefaultGroupManager.java
@@ -109,7 +109,7 @@ public class DefaultGroupManager implements GroupManager, MemberFailureListener,
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
ClusterPingBody ping = new ClusterPingBody((byte)8, (byte)0);
- ping.broker = _group.getLocal().getDetails();
+ ping.broker = new AMQShortString(_group.getLocal().getDetails());
ping.responseRequired = true;
ping.load = _loadTable.getLocalLoad();
BlockingHandler handler = new BlockingHandler();
@@ -157,7 +157,7 @@ public class DefaultGroupManager implements GroupManager, MemberFailureListener,
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
ClusterJoinBody join = new ClusterJoinBody((byte)8, (byte)0);
- join.broker = _group.getLocal().getDetails();
+ join.broker = new AMQShortString(_group.getLocal().getDetails());
send(leader, new SimpleBodySendable(join));
}
@@ -178,7 +178,7 @@ public class DefaultGroupManager implements GroupManager, MemberFailureListener,
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
ClusterLeaveBody leave = new ClusterLeaveBody((byte)8, (byte)0);
- leave.broker = _group.getLocal().getDetails();
+ leave.broker = new AMQShortString(_group.getLocal().getDetails());
send(getLeader(), new SimpleBodySendable(leave));
}
@@ -201,7 +201,7 @@ public class DefaultGroupManager implements GroupManager, MemberFailureListener,
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
ClusterSuspectBody suspect = new ClusterSuspectBody((byte)8, (byte)0);
- suspect.broker = broker.getDetails();
+ suspect.broker = new AMQShortString(broker.getDetails());
send(getLeader(), new SimpleBodySendable(suspect));
}
}
@@ -225,7 +225,7 @@ public class DefaultGroupManager implements GroupManager, MemberFailureListener,
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
ClusterJoinBody request = new ClusterJoinBody((byte)8, (byte)0);
- request.broker = member.getDetails();
+ request.broker = new AMQShortString(member.getDetails());
Broker leader = getLeader();
send(leader, new SimpleBodySendable(request));
_logger.info(new LogMessage("Passed join request for {0} to {1}", member, leader));
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/MemberHandle.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/MemberHandle.java
index b14fede5aa..b8099a12f7 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/MemberHandle.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/MemberHandle.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.cluster;
+import org.apache.qpid.framing.AMQShortString;
+
public interface MemberHandle
{
public String getHost();
@@ -30,5 +32,5 @@ public interface MemberHandle
public boolean matches(String host, int port);
- public String getDetails();
+ public AMQShortString getDetails();
}
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/MinaBrokerProxy.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/MinaBrokerProxy.java
index 275ed39b5f..8557fc17c7 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/MinaBrokerProxy.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/MinaBrokerProxy.java
@@ -180,7 +180,7 @@ public class MinaBrokerProxy extends Broker implements MethodHandler
{
//signal redirection to waiting thread
ConnectionRedirectBody redirect = (ConnectionRedirectBody) method;
- String[] parts = redirect.host.split(":");
+ String[] parts = redirect.host.toString().split(":");
_connectionMonitor.redirect(parts[0], Integer.parseInt(parts[1]));
}
else
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleMemberHandle.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleMemberHandle.java
index b6d5e3d88d..1255094b1d 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleMemberHandle.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleMemberHandle.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.server.cluster;
+import org.apache.qpid.framing.AMQShortString;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
@@ -37,6 +39,11 @@ public class SimpleMemberHandle implements MemberHandle
_port = port;
}
+ public SimpleMemberHandle(AMQShortString details)
+ {
+ this(details.toString());
+ }
+
public SimpleMemberHandle(String details)
{
String[] parts = details.split(":");
@@ -84,14 +91,14 @@ public class SimpleMemberHandle implements MemberHandle
return _host.equals(host) && _port == port;
}
- public String getDetails()
+ public AMQShortString getDetails()
{
- return _host + ":" + _port;
+ return new AMQShortString(_host + ":" + _port);
}
public String toString()
{
- return getDetails();
+ return getDetails().toString();
}
static List<MemberHandle> stringToMembers(String membership)
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChannelQueueManager.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChannelQueueManager.java
index 022ee098ab..9cff310a8a 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChannelQueueManager.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChannelQueueManager.java
@@ -28,11 +28,7 @@ import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.protocol.AMQMethodEvent;
import org.apache.qpid.server.cluster.util.LogMessage;
import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.QueueDeclareBody;
-import org.apache.qpid.framing.QueueBindBody;
-import org.apache.qpid.framing.QueueDeleteBody;
-import org.apache.qpid.framing.BasicConsumeBody;
+import org.apache.qpid.framing.*;
import org.apache.log4j.Logger;
import java.util.Map;
@@ -46,7 +42,7 @@ import java.util.HashMap;
class ChannelQueueManager
{
private static final Logger _logger = Logger.getLogger(ChannelQueueManager.class);
- private final Map<Integer, String> _channelQueues = new HashMap<Integer, String>();
+ private final Map<Integer, AMQShortString> _channelQueues = new HashMap<Integer, AMQShortString>();
ClusterMethodHandler<QueueDeclareBody> createQueueDeclareHandler()
{
@@ -68,15 +64,15 @@ class ChannelQueueManager
return new BasicConsumeHandler();
}
- private void set(int channel, String queue)
+ private void set(int channel, AMQShortString queue)
{
_channelQueues.put(channel, queue);
_logger.info(new LogMessage("Set default queue for {0} to {1}", channel, queue));
}
- private String get(int channel)
+ private AMQShortString get(int channel)
{
- String queue = _channelQueues.get(channel);
+ AMQShortString queue = _channelQueues.get(channel);
_logger.info(new LogMessage("Default queue for {0} is {1}", channel, queue));
return queue;
}
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ClusterMethodHandlerFactory.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ClusterMethodHandlerFactory.java
index 46ba3e5015..f90373cd98 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ClusterMethodHandlerFactory.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ClusterMethodHandlerFactory.java
@@ -21,34 +21,7 @@
package org.apache.qpid.server.cluster.handler;
import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQFrame;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.BasicCancelBody;
-import org.apache.qpid.framing.BasicConsumeBody;
-import org.apache.qpid.framing.BasicPublishBody;
-import org.apache.qpid.framing.ChannelCloseBody;
-import org.apache.qpid.framing.ChannelFlowBody;
-import org.apache.qpid.framing.ChannelOpenBody;
-import org.apache.qpid.framing.ClusterJoinBody;
-import org.apache.qpid.framing.ClusterLeaveBody;
-import org.apache.qpid.framing.ClusterMembershipBody;
-import org.apache.qpid.framing.ClusterPingBody;
-import org.apache.qpid.framing.ClusterSuspectBody;
-import org.apache.qpid.framing.ConnectionCloseBody;
-import org.apache.qpid.framing.ConnectionOpenBody;
-import org.apache.qpid.framing.ConnectionSecureOkBody;
-import org.apache.qpid.framing.ConnectionStartOkBody;
-import org.apache.qpid.framing.ConnectionTuneOkBody;
-import org.apache.qpid.framing.ExchangeDeclareBody;
-import org.apache.qpid.framing.ExchangeDeleteBody;
-import org.apache.qpid.framing.QueueBindBody;
-import org.apache.qpid.framing.QueueDeclareBody;
-import org.apache.qpid.framing.QueueDeleteBody;
-import org.apache.qpid.framing.ClusterSynchBody;
-import org.apache.qpid.framing.BasicQosBody;
-import org.apache.qpid.framing.TxSelectBody;
-import org.apache.qpid.framing.TxCommitBody;
-import org.apache.qpid.framing.TxRollbackBody;
+import org.apache.qpid.framing.*;
import org.apache.qpid.server.cluster.ClusterCapability;
import org.apache.qpid.server.cluster.ClusteredProtocolSession;
import org.apache.qpid.server.cluster.GroupManager;
@@ -236,7 +209,7 @@ public class ClusterMethodHandlerFactory implements MethodHandlerFactory
void postHandle(AMQStateManager stateMgr, AMQProtocolSession session, AMQMethodEvent<ConnectionOpenBody> evt)
{
- String capabilities = evt.getMethod().capabilities;
+ AMQShortString capabilities = evt.getMethod().capabilities;
if (ClusterCapability.contains(capabilities))
{
ClusteredProtocolSession.setSessionPeer(session, ClusterCapability.getPeer(capabilities));
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/LocalQueueDeclareHandler.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/LocalQueueDeclareHandler.java
index 1e6bc26444..6b876095a4 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/LocalQueueDeclareHandler.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/LocalQueueDeclareHandler.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.cluster.handler;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.QueueDeclareBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.cluster.ClusteredProtocolSession;
import org.apache.qpid.server.cluster.GroupManager;
import org.apache.qpid.server.cluster.util.LogMessage;
@@ -45,9 +46,9 @@ public class LocalQueueDeclareHandler extends QueueDeclareHandler
_groupMgr = groupMgr;
}
- protected String createName()
+ protected AMQShortString createName()
{
- return super.createName() + "@" + _groupMgr.getLocal().getDetails();
+ return new AMQShortString(super.createName().toString() + "@" + _groupMgr.getLocal().getDetails());
}
protected AMQQueue createQueue(QueueDeclareBody body, QueueRegistry registry, AMQProtocolSession session) throws AMQException
@@ -60,7 +61,7 @@ public class LocalQueueDeclareHandler extends QueueDeclareHandler
//need to get peer from the session...
MemberHandle peer = ClusteredProtocolSession.getSessionPeer(session);
_logger.debug(new LogMessage("Creating proxied queue {0} on behalf of {1}", body.queue, peer));
- return new RemoteQueueProxy(peer, _groupMgr, body.queue, body.durable, peer.getDetails(), body.autoDelete, registry);
+ return new RemoteQueueProxy(peer, _groupMgr, body.queue, body.durable, new AMQShortString(peer.getDetails()), body.autoDelete, registry);
}
else
{
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ConsumerCounts.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ConsumerCounts.java
index 832e4830ab..722ec1b256 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ConsumerCounts.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ConsumerCounts.java
@@ -22,6 +22,7 @@ package org.apache.qpid.server.cluster.replay;
import org.apache.qpid.framing.AMQMethodBody;
import org.apache.qpid.framing.BasicConsumeBody;
+import org.apache.qpid.framing.AMQShortString;
import java.util.Map;
import java.util.HashMap;
@@ -29,19 +30,19 @@ import java.util.List;
class ConsumerCounts
{
- private final Map<String, Integer> _counts = new HashMap<String, Integer>();
+ private final Map<AMQShortString, Integer> _counts = new HashMap<AMQShortString, Integer>();
- synchronized void increment(String queue)
+ synchronized void increment(AMQShortString queue)
{
_counts.put(queue, get(queue) + 1);
}
- synchronized void decrement(String queue)
+ synchronized void decrement(AMQShortString queue)
{
_counts.put(queue, get(queue) - 1);
}
- private int get(String queue)
+ private int get(AMQShortString queue)
{
Integer count = _counts.get(queue);
return count == null ? 0 : count;
@@ -49,7 +50,7 @@ class ConsumerCounts
synchronized void replay(List<AMQMethodBody> messages)
{
- for(String queue : _counts.keySet())
+ for(AMQShortString queue : _counts.keySet())
{
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ReplayStore.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ReplayStore.java
index 338817e892..3193c206c7 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ReplayStore.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/replay/ReplayStore.java
@@ -22,15 +22,7 @@ package org.apache.qpid.server.cluster.replay;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQMethodBody;
-import org.apache.qpid.framing.ExchangeDeclareBody;
-import org.apache.qpid.framing.ExchangeDeleteBody;
-import org.apache.qpid.framing.QueueBindBody;
-import org.apache.qpid.framing.QueueDeclareBody;
-import org.apache.qpid.framing.QueueDeleteBody;
-import org.apache.qpid.framing.ClusterSynchBody;
-import org.apache.qpid.framing.BasicConsumeBody;
-import org.apache.qpid.framing.BasicCancelBody;
+import org.apache.qpid.framing.*;
import org.apache.qpid.server.cluster.ClusteredProtocolSession;
import org.apache.qpid.server.cluster.util.LogMessage;
import org.apache.qpid.server.cluster.util.Bindings;
@@ -57,11 +49,11 @@ public class ReplayStore implements ReplayManager, StateAwareMethodListener
private final Map<Class<? extends AMQMethodBody>, MethodRecorder> _globalRecorders = new HashMap<Class<? extends AMQMethodBody>, MethodRecorder>();
private final Map<Class<? extends AMQMethodBody>, MethodRecorder> _localRecorders = new HashMap<Class<? extends AMQMethodBody>, MethodRecorder>();
- private final Map<String, QueueDeclareBody> _sharedQueues = new ConcurrentHashMap<String, QueueDeclareBody>();
- private final Map<String, QueueDeclareBody> _privateQueues = new ConcurrentHashMap<String, QueueDeclareBody>();
- private final Bindings<String, String, QueueBindBody> _sharedBindings = new Bindings<String, String, QueueBindBody>();
- private final Bindings<String, String, QueueBindBody> _privateBindings = new Bindings<String, String, QueueBindBody>();
- private final Map<String, ExchangeDeclareBody> _exchanges = new ConcurrentHashMap<String, ExchangeDeclareBody>();
+ private final Map<AMQShortString, QueueDeclareBody> _sharedQueues = new ConcurrentHashMap<AMQShortString, QueueDeclareBody>();
+ private final Map<AMQShortString, QueueDeclareBody> _privateQueues = new ConcurrentHashMap<AMQShortString, QueueDeclareBody>();
+ private final Bindings<AMQShortString, AMQShortString, QueueBindBody> _sharedBindings = new Bindings<AMQShortString, AMQShortString, QueueBindBody>();
+ private final Bindings<AMQShortString, AMQShortString, QueueBindBody> _privateBindings = new Bindings<AMQShortString, AMQShortString, QueueBindBody>();
+ private final Map<AMQShortString, ExchangeDeclareBody> _exchanges = new ConcurrentHashMap<AMQShortString, ExchangeDeclareBody>();
private final ConsumerCounts _consumers = new ConsumerCounts();
public ReplayStore()
@@ -204,15 +196,15 @@ public class ReplayStore implements ReplayManager, StateAwareMethodListener
private static class QueueDeclareRecorder extends ChainedMethodRecorder<QueueDeclareBody>
{
private final boolean _exclusive;
- private final Map<String, QueueDeclareBody> _queues;
+ private final Map<AMQShortString, QueueDeclareBody> _queues;
- QueueDeclareRecorder(boolean exclusive, Map<String, QueueDeclareBody> queues)
+ QueueDeclareRecorder(boolean exclusive, Map<AMQShortString, QueueDeclareBody> queues)
{
_queues = queues;
_exclusive = exclusive;
}
- QueueDeclareRecorder(boolean exclusive, Map<String, QueueDeclareBody> queues, QueueDeclareRecorder recorder)
+ QueueDeclareRecorder(boolean exclusive, Map<AMQShortString, QueueDeclareBody> queues, QueueDeclareRecorder recorder)
{
super(recorder);
_queues = queues;
@@ -236,15 +228,15 @@ public class ReplayStore implements ReplayManager, StateAwareMethodListener
private class QueueDeleteRecorder extends ChainedMethodRecorder<QueueDeleteBody>
{
- private final Map<String, QueueDeclareBody> _queues;
- private final Bindings<String, String, QueueBindBody> _bindings;
+ private final Map<AMQShortString, QueueDeclareBody> _queues;
+ private final Bindings<AMQShortString, AMQShortString, QueueBindBody> _bindings;
- QueueDeleteRecorder(Map<String, QueueDeclareBody> queues, Bindings<String, String, QueueBindBody> bindings)
+ QueueDeleteRecorder(Map<AMQShortString, QueueDeclareBody> queues, Bindings<AMQShortString, AMQShortString, QueueBindBody> bindings)
{
this(queues, bindings, null);
}
- QueueDeleteRecorder(Map<String, QueueDeclareBody> queues, Bindings<String, String, QueueBindBody> bindings, QueueDeleteRecorder recorder)
+ QueueDeleteRecorder(Map<AMQShortString, QueueDeclareBody> queues, Bindings<AMQShortString, AMQShortString, QueueBindBody> bindings, QueueDeleteRecorder recorder)
{
super(recorder);
_queues = queues;
@@ -267,16 +259,16 @@ public class ReplayStore implements ReplayManager, StateAwareMethodListener
private class QueueBindRecorder extends ChainedMethodRecorder<QueueBindBody>
{
- private final Map<String, QueueDeclareBody> _queues;
- private final Bindings<String, String, QueueBindBody> _bindings;
+ private final Map<AMQShortString, QueueDeclareBody> _queues;
+ private final Bindings<AMQShortString, AMQShortString, QueueBindBody> _bindings;
- QueueBindRecorder(Map<String, QueueDeclareBody> queues, Bindings<String, String, QueueBindBody> bindings)
+ QueueBindRecorder(Map<AMQShortString, QueueDeclareBody> queues, Bindings<AMQShortString, AMQShortString, QueueBindBody> bindings)
{
_queues = queues;
_bindings = bindings;
}
- QueueBindRecorder(Map<String, QueueDeclareBody> queues, Bindings<String, String, QueueBindBody> bindings, QueueBindRecorder recorder)
+ QueueBindRecorder(Map<AMQShortString, QueueDeclareBody> queues, Bindings<AMQShortString, AMQShortString, QueueBindBody> bindings, QueueBindRecorder recorder)
{
super(recorder);
_queues = queues;
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/queue/ClusteredQueue.java b/java/cluster/src/main/java/org/apache/qpid/server/queue/ClusteredQueue.java
index 50b2fa0b66..6898ffcec2 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/queue/ClusteredQueue.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/queue/ClusteredQueue.java
@@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicCancelBody;
import org.apache.qpid.framing.QueueDeleteBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.cluster.*;
import org.apache.qpid.server.cluster.util.LogMessage;
import org.apache.qpid.server.protocol.AMQProtocolSession;
@@ -45,7 +46,7 @@ public class ClusteredQueue extends AMQQueue
private final GroupManager _groupMgr;
private final NestedSubscriptionManager _subscriptions;
- public ClusteredQueue(GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry)
+ public ClusteredQueue(GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry, new ClusteredSubscriptionManager());
@@ -53,7 +54,7 @@ public class ClusteredQueue extends AMQQueue
_subscriptions = ((ClusteredSubscriptionManager) getSubscribers()).getAllSubscribers();
}
- public ClusteredQueue(GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
+ public ClusteredQueue(GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry, asyncDelivery, new ClusteredSubscriptionManager(),
@@ -84,7 +85,7 @@ public class ClusteredQueue extends AMQQueue
}
}
- public void unregisterProtocolSession(AMQProtocolSession ps, int channel, String consumerTag) throws AMQException
+ public void unregisterProtocolSession(AMQProtocolSession ps, int channel, AMQShortString consumerTag) throws AMQException
{
//handle locally:
super.unregisterProtocolSession(ps, channel, consumerTag);
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java b/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java
index 8315d46b5d..89ce0bc8b1 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/queue/PrivateQueue.java
@@ -25,6 +25,7 @@ import org.apache.qpid.server.cluster.SimpleSendable;
import org.apache.qpid.server.cluster.GroupManager;
import org.apache.qpid.server.cluster.SimpleBodySendable;
import org.apache.qpid.framing.QueueDeleteBody;
+import org.apache.qpid.framing.AMQShortString;
import java.util.concurrent.Executor;
@@ -36,7 +37,7 @@ public class PrivateQueue extends AMQQueue
{
private final GroupManager _groupMgr;
- public PrivateQueue(GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry)
+ public PrivateQueue(GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry);
@@ -44,7 +45,7 @@ public class PrivateQueue extends AMQQueue
}
- public PrivateQueue(GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
+ public PrivateQueue(GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry, asyncDelivery);
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteQueueProxy.java b/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteQueueProxy.java
index f8eba282e2..a6cce05a03 100644
--- a/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteQueueProxy.java
+++ b/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteQueueProxy.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.queue;
import org.apache.log4j.Logger;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicPublishBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.cluster.ClusteredProtocolSession;
import org.apache.qpid.server.cluster.GroupManager;
import org.apache.qpid.server.cluster.MemberHandle;
@@ -42,7 +43,7 @@ public class RemoteQueueProxy extends AMQQueue
private final MemberHandle _target;
private final GroupManager _groupMgr;
- public RemoteQueueProxy(MemberHandle target, GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry)
+ public RemoteQueueProxy(MemberHandle target, GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry);
@@ -51,7 +52,7 @@ public class RemoteQueueProxy extends AMQQueue
_groupMgr.addMemberhipChangeListener(new ProxiedQueueCleanup(target, this));
}
- public RemoteQueueProxy(MemberHandle target, GroupManager groupMgr, String name, boolean durable, String owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
+ public RemoteQueueProxy(MemberHandle target, GroupManager groupMgr, AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, QueueRegistry queueRegistry, Executor asyncDelivery)
throws AMQException
{
super(name, durable, owner, autoDelete, queueRegistry, asyncDelivery);
diff --git a/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java b/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
index 76b1da8754..830a00f4c2 100644
--- a/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
+++ b/java/cluster/src/test/java/org/apache/qpid/server/cluster/ClusterCapabilityTest.java
@@ -21,13 +21,14 @@
package org.apache.qpid.server.cluster;
import junit.framework.TestCase;
+import org.apache.qpid.framing.AMQShortString;
public class ClusterCapabilityTest extends TestCase
{
public void testStartWithNull()
{
MemberHandle peer = new SimpleMemberHandle("myhost:9999");
- String c = ClusterCapability.add(null, peer);
+ AMQShortString c = ClusterCapability.add(null, peer);
assertTrue(ClusterCapability.contains(c));
assertTrue(peer.matches(ClusterCapability.getPeer(c)));
}
@@ -35,7 +36,7 @@ public class ClusterCapabilityTest extends TestCase
public void testStartWithText()
{
MemberHandle peer = new SimpleMemberHandle("myhost:9999");
- String c = ClusterCapability.add("existing text", peer);
+ AMQShortString c = ClusterCapability.add(new AMQShortString("existing text"), peer);
assertTrue(ClusterCapability.contains(c));
assertTrue(peer.matches(ClusterCapability.getPeer(c)));
}
diff --git a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
index c427285f4a..70209cd2a3 100644
--- a/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
+++ b/java/cluster/src/test/java/org/apache/qpid/server/cluster/SimpleClusterTest.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.cluster;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQSession;
@@ -36,7 +37,7 @@ public class SimpleClusterTest extends TestCase
AMQConnection con = new AMQConnection("localhost:9000", "guest", "guest", "test", "/test");
AMQSession session = (AMQSession) con.createSession(false, AMQSession.NO_ACKNOWLEDGE);
System.out.println("Session created");
- session.declareExchange("my_exchange", "direct");
+ session.declareExchange(new AMQShortString("my_exchange"), new AMQShortString("direct"));
System.out.println("Exchange declared");
con.close();
System.out.println("Connection closed");
diff --git a/java/common/src/main/java/org/apache/qpid/AMQChannelException.java b/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
index 2ead0a03e6..9255590afb 100644
--- a/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
+++ b/java/common/src/main/java/org/apache/qpid/AMQChannelException.java
@@ -22,6 +22,7 @@ package org.apache.qpid;
import org.apache.qpid.framing.ChannelCloseBody;
import org.apache.qpid.framing.AMQFrame;
+import org.apache.qpid.framing.AMQShortString;
public class AMQChannelException extends AMQException
{
@@ -51,6 +52,6 @@ public class AMQChannelException extends AMQException
public AMQFrame getCloseFrame(int channel)
{
- return ChannelCloseBody.createAMQFrame(channel, major, minor, _classId, _methodId, getErrorCode(), getMessage());
+ return ChannelCloseBody.createAMQFrame(channel, major, minor, _classId, _methodId, getErrorCode(), new AMQShortString(getMessage()));
}
}
diff --git a/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java b/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
index 56219755a3..d8aa9bf5ca 100644
--- a/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
+++ b/java/common/src/main/java/org/apache/qpid/common/AMQPFilterTypes.java
@@ -20,20 +20,22 @@
*/
package org.apache.qpid.common;
+import org.apache.qpid.framing.AMQShortString;
+
public enum AMQPFilterTypes
{
JMS_SELECTOR("x-filter-jms-selector"),
NO_CONSUME("x-filter-no-consume"),
AUTO_CLOSE("x-filter-auto-close");
- private final String _value;
+ private final AMQShortString _value;
AMQPFilterTypes(String value)
{
- _value = value;
+ _value = new AMQShortString(value);
}
- public String getValue()
+ public AMQShortString getValue()
{
return _value;
}
diff --git a/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java b/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
index e67a5ba7fe..729cdb871e 100644
--- a/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
+++ b/java/common/src/main/java/org/apache/qpid/exchange/ExchangeDefaults.java
@@ -20,17 +20,19 @@
*/
package org.apache.qpid.exchange;
+import org.apache.qpid.framing.AMQShortString;
+
public class ExchangeDefaults
{
- public final static String TOPIC_EXCHANGE_NAME = "amq.topic";
+ public final static AMQShortString TOPIC_EXCHANGE_NAME = new AMQShortString("amq.topic");
- public final static String TOPIC_EXCHANGE_CLASS = "topic";
+ public final static AMQShortString TOPIC_EXCHANGE_CLASS = new AMQShortString("topic");
- public final static String DIRECT_EXCHANGE_NAME = "amq.direct";
+ public final static AMQShortString DIRECT_EXCHANGE_NAME = new AMQShortString("amq.direct");
- public final static String DIRECT_EXCHANGE_CLASS = "direct";
+ public final static AMQShortString DIRECT_EXCHANGE_CLASS = new AMQShortString("direct");
- public final static String HEADERS_EXCHANGE_NAME = "amq.match";
+ public final static AMQShortString HEADERS_EXCHANGE_NAME = new AMQShortString("amq.match");
- public final static String HEADERS_EXCHANGE_CLASS = "headers";
+ public final static AMQShortString HEADERS_EXCHANGE_CLASS = new AMQShortString("headers");
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
new file mode 100644
index 0000000000..6dbdb27026
--- /dev/null
+++ b/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
@@ -0,0 +1,334 @@
+package org.apache.qpid.framing;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.log4j.Logger;
+
+import java.util.Arrays;
+
+/**
+ * A short string is a representation of an AMQ Short String
+ * Short strings differ from the Java String class by being limited to on ASCII characters (0-127)
+ * and thus can be held more effectively in a byte buffer.
+ *
+ */
+public final class AMQShortString implements CharSequence
+{
+ private static final Logger _logger = Logger.getLogger(AMQShortString.class);
+
+ private final ByteBuffer _data;
+ private int _hashCode;
+ private static final char[] EMPTY_CHAR_ARRAY = new char[0];
+
+ public AMQShortString(String data)
+ {
+ this(data == null ? EMPTY_CHAR_ARRAY : data.toCharArray());
+ if(data != null) _hashCode = data.hashCode();
+ }
+
+ public AMQShortString(char[] data)
+ {
+ if(data == null)
+ {
+ throw new NullPointerException("Cannot create AMQShortString with null char[]");
+ }
+ final int length = data.length;
+ final byte[] stringBytes = new byte[length];
+ for(int i = 0; i < length; i++)
+ {
+ stringBytes[i] = (byte) (0xFF & data[i]);
+ }
+
+ _data = ByteBuffer.wrap(stringBytes);
+ _data.rewind();
+
+ }
+
+ public AMQShortString(CharSequence charSequence)
+ {
+ final int length = charSequence.length();
+ final byte[] stringBytes = new byte[length];
+ int hash = 0;
+ for(int i = 0 ; i < length; i++)
+ {
+ stringBytes[i] = ((byte) (0xFF & charSequence.charAt(i)));
+ hash = (31 * hash) + stringBytes[i];
+
+ }
+ _data = ByteBuffer.wrap(stringBytes);
+ _data.rewind();
+ _hashCode = hash;
+
+ }
+
+ private AMQShortString(ByteBuffer data)
+ {
+ _data = data;
+
+ }
+
+
+ /**
+ * Get the length of the short string
+ * @return length of the underlying byte array
+ */
+ public int length()
+ {
+ return _data.limit();
+ }
+
+ public char charAt(int index)
+ {
+
+ return (char) _data.get(index);
+
+ }
+
+ public CharSequence subSequence(int start, int end)
+ {
+ return new CharSubSequence(start,end);
+ }
+
+ public int writeToByteArray(byte[] encoding, int pos)
+ {
+ final int size = length();
+ encoding[pos++] = (byte) length();
+ for(int i = 0; i < size; i++)
+ {
+ encoding[pos++] = _data.get(i);
+ }
+ return pos;
+ }
+
+ public static AMQShortString readFromByteArray(byte[] byteEncodedDestination, int pos)
+ {
+
+ final byte len = byteEncodedDestination[pos];
+ if(len == 0)
+ {
+ return null;
+ }
+ ByteBuffer data = ByteBuffer.wrap(byteEncodedDestination,pos+1,len).slice();
+
+
+ return new AMQShortString(data);
+ }
+
+ public static AMQShortString readFromBuffer(ByteBuffer buffer)
+ {
+ final short length = buffer.getUnsigned();
+ if (length == 0)
+ {
+ return null;
+ }
+ else
+ {
+ ByteBuffer data = buffer.slice();
+ data.limit(length);
+ data.rewind();
+ buffer.skip(length);
+
+ return new AMQShortString(data);
+ }
+ }
+
+ public void writeToBuffer(ByteBuffer buffer)
+ {
+
+
+ final int size = length();
+ if (size != 0)
+ {
+
+ buffer.put((byte)size);
+ if(_data.buf().hasArray())
+ {
+ buffer.put(_data.array(),_data.arrayOffset(),length());
+ }
+ else
+ {
+
+ for(int i = 0; i < size; i++)
+ {
+
+ buffer.put(_data.get(i));
+ }
+ }
+ }
+ else
+ {
+ // really writing out unsigned byte
+ buffer.put((byte) 0);
+ }
+
+ }
+
+ private final class CharSubSequence implements CharSequence
+ {
+ private final int _offset;
+ private final int _end;
+
+
+ public CharSubSequence(final int offset, final int end)
+ {
+ _offset = offset;
+ _end = end;
+ }
+
+
+ public int length()
+ {
+ return _end - _offset;
+ }
+
+ public char charAt(int index)
+ {
+ return AMQShortString.this.charAt(index + _offset);
+ }
+
+ public CharSequence subSequence(int start, int end)
+ {
+ return new CharSubSequence(start+_offset,end+_offset);
+ }
+ }
+
+
+
+ public char[] asChars()
+ {
+ final int size = length();
+ final char[] chars = new char[size];
+
+
+
+
+ for(int i = 0 ; i < size; i++)
+ {
+ chars[i] = (char) _data.get(i);
+ }
+ return chars;
+ }
+
+
+
+ public String asString()
+ {
+ return new String(asChars());
+ }
+
+ public boolean equals(Object o)
+ {
+ if(o == null)
+ {
+ return false;
+ }
+ if(o == this)
+ {
+ return true;
+ }
+ if(o instanceof AMQShortString)
+ {
+
+ final AMQShortString otherString = (AMQShortString) o;
+
+ if(otherString.length() != length())
+ {
+ return false;
+ }
+ if((_hashCode != 0) && (otherString._hashCode != 0) && (_hashCode != otherString._hashCode))
+ {
+ return false;
+ }
+ final int size = length();
+ for(int i = 0; i < size; i++)
+ {
+ if(_data.get(i) != otherString._data.get(i))
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+
+ }
+ return (o instanceof CharSequence) && equals((CharSequence)o);
+
+ }
+
+ public boolean equals(CharSequence s)
+ {
+ if(s == null)
+ {
+ return false;
+ }
+ if(s.length() != length())
+ {
+ return false;
+ }
+ for(int i = 0; i < length(); i++)
+ {
+ if(charAt(i)!= s.charAt(i))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = _hashCode;
+ if(hash == 0)
+ {
+ final int size = length();
+
+
+ for(int i = 0; i < size; i++)
+ {
+ hash = (31 * hash) + _data.get(i);
+ }
+ _hashCode = hash;
+ }
+
+ return hash;
+ }
+
+ public void setDirty()
+ {
+ _hashCode = 0;
+ }
+
+ public String toString()
+ {
+ return asString();
+ }
+
+
+ public int compareTo(AMQShortString name)
+ {
+ if(name == null)
+ {
+ return 1;
+ }
+ else
+ {
+
+ if(name.length() < length())
+ {
+ return - name.compareTo(this);
+ }
+
+
+
+ for(int i = 0; i < length() ; i++)
+ {
+ final byte d = _data.get(i);
+ final byte n = name._data.get(i);
+ if(d < n) return -1;
+ if(d > n) return 1;
+ }
+
+ return length() == name.length() ? 0 : -1;
+ }
+ }
+}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
index fc80d93f82..14d1d0c7b0 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
@@ -22,11 +22,18 @@ package org.apache.qpid.framing;
import org.apache.log4j.Logger;
import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQPInvalidClassException;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
+import java.util.Enumeration;
public class BasicContentHeaderProperties implements ContentHeaderProperties
{
private static final Logger _logger = Logger.getLogger(BasicContentHeaderProperties.class);
+ private static final AMQShortString ZERO_STRING = null;
+
/**
* We store the encoded form when we decode the content header so that if we need to
* write it out without modifying it we can do so without incurring the expense of
@@ -51,35 +58,33 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
*/
private boolean _decodedContentType = true;
- private String _contentType;
+ private AMQShortString _contentType;
- private String _encoding;
+ private AMQShortString _encoding;
private FieldTable _headers;
- private JMSPropertyFieldTable _jmsHeaders;
-
private byte _deliveryMode;
private byte _priority;
- private String _correlationId;
+ private AMQShortString _correlationId;
- private String _replyTo;
+ private AMQShortString _replyTo;
private long _expiration;
- private String _messageId;
+ private AMQShortString _messageId;
private long _timestamp;
- private String _type;
+ private AMQShortString _type;
- private String _userId;
+ private AMQShortString _userId;
- private String _appId;
+ private AMQShortString _appId;
- private String _clusterId;
+ private AMQShortString _clusterId;
private int _propertyFlags = 0;
@@ -127,7 +132,14 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
}
if ((_propertyFlags & (1 << 8)) > 0)
{
- size += EncodingUtils.encodedShortStringLength(String.valueOf(_expiration));
+ if(_expiration == 0L)
+ {
+ size+=EncodingUtils.encodedShortStringLength(ZERO_STRING);
+ }
+ else
+ {
+ size += EncodingUtils.encodedShortStringLength(_expiration);
+ }
}
if ((_propertyFlags & (1 << 7)) > 0)
{
@@ -215,7 +227,14 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
}
if ((_propertyFlags & (1 << 8)) > 0)
{
- EncodingUtils.writeShortStringBytes(buffer, String.valueOf(_expiration));
+ if(_expiration == 0L)
+ {
+ EncodingUtils.writeShortStringBytes(buffer, ZERO_STRING);
+ }
+ else
+ {
+ EncodingUtils.writeShortStringBytes(buffer, String.valueOf(_expiration));
+ }
}
if ((_propertyFlags & (1 << 7)) > 0)
{
@@ -269,16 +288,15 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
{
if ((_propertyFlags & (1 << 15)) > 0)
{
- _contentType = EncodingUtils.readShortString(buffer);
+ _contentType = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 14)) > 0)
{
- _encoding = EncodingUtils.readShortString(buffer);
+ _encoding = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 13)) > 0)
{
_headers = EncodingUtils.readFieldTable(buffer);
- setJMSHeaders();
}
if ((_propertyFlags & (1 << 12)) > 0)
{
@@ -290,19 +308,19 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
}
if ((_propertyFlags & (1 << 10)) > 0)
{
- _correlationId = EncodingUtils.readShortString(buffer);
+ _correlationId = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 9)) > 0)
{
- _replyTo = EncodingUtils.readShortString(buffer);
+ _replyTo = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 8)) > 0)
{
- _expiration = Long.parseLong(EncodingUtils.readShortString(buffer));
+ _expiration = EncodingUtils.readLongAsShortString(buffer);
}
if ((_propertyFlags & (1 << 7)) > 0)
{
- _messageId = EncodingUtils.readShortString(buffer);
+ _messageId = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 6)) > 0)
{
@@ -310,19 +328,19 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
}
if ((_propertyFlags & (1 << 5)) > 0)
{
- _type = EncodingUtils.readShortString(buffer);
+ _type = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 4)) > 0)
{
- _userId = EncodingUtils.readShortString(buffer);
+ _userId = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 3)) > 0)
{
- _appId = EncodingUtils.readShortString(buffer);
+ _appId = EncodingUtils.readAMQShortString(buffer);
}
if ((_propertyFlags & (1 << 2)) > 0)
{
- _clusterId = EncodingUtils.readShortString(buffer);
+ _clusterId = EncodingUtils.readAMQShortString(buffer);
}
}
catch (AMQFrameDecodingException e)
@@ -361,7 +379,6 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
if ((_propertyFlags & (1 << 13)) > 0)
{
_headers = EncodingUtils.readFieldTable(buffer);
- setJMSHeaders();
}
_decodedHeaders = true;
@@ -378,7 +395,7 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
if ((_propertyFlags & (1 << 15)) > 0)
{
- _contentType = EncodingUtils.readShortString(buffer);
+ _contentType = EncodingUtils.readAMQShortString(buffer);
}
_decodedContentType = true;
@@ -408,30 +425,45 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
}
}
- public String getContentType()
+ public AMQShortString getContentTypeShortString()
{
decodeContentTypeIfNecessary();
return _contentType;
}
- public void setContentType(String contentType)
+
+ public String getContentType()
+ {
+ decodeContentTypeIfNecessary();
+ return _contentType == null ? null : _contentType.toString();
+ }
+
+ public void setContentType(AMQShortString contentType)
{
clearEncodedForm();
_propertyFlags |= (1 << 15);
_contentType = contentType;
}
+
+ public void setContentType(String contentType)
+ {
+ clearEncodedForm();
+ _propertyFlags |= (1 << 15);
+ _contentType = contentType == null ? null : new AMQShortString(contentType);
+ }
+
public String getEncoding()
{
decodeIfNecessary();
- return _encoding;
+ return _encoding == null ? null : _encoding.toString();
}
public void setEncoding(String encoding)
{
clearEncodedForm();
_propertyFlags |= (1 << 14);
- _encoding = encoding;
+ _encoding = encoding == null ? null : new AMQShortString(encoding);
}
public FieldTable getHeaders()
@@ -451,27 +483,8 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
clearEncodedForm();
_propertyFlags |= (1 << 13);
_headers = headers;
- setJMSHeaders();
}
- private void setJMSHeaders()
- {
- if (_jmsHeaders == null)
- {
- _jmsHeaders = new JMSPropertyFieldTable(_headers);
- }
- else
- {
- _jmsHeaders.setFieldTable(_headers);
- }
- }
-
- public JMSPropertyFieldTable getJMSHeaders()
- {
- //This will ensure we have a blank header
- getHeaders();
- return _jmsHeaders;
- }
public byte getDeliveryMode()
{
@@ -502,24 +515,30 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
public String getCorrelationId()
{
decodeIfNecessary();
- return _correlationId;
+ return _correlationId == null ? null : _correlationId.toString();
}
public void setCorrelationId(String correlationId)
{
clearEncodedForm();
_propertyFlags |= (1 << 10);
- _correlationId = correlationId;
+ _correlationId = correlationId == null ? null : new AMQShortString(correlationId);
}
public String getReplyTo()
{
decodeIfNecessary();
- return _replyTo;
+ return _replyTo == null ? null : _replyTo.toString();
}
public void setReplyTo(String replyTo)
{
+ setReplyTo(replyTo == null ? null : new AMQShortString(replyTo));
+ }
+
+ public void setReplyTo(AMQShortString replyTo)
+ {
+
clearEncodedForm();
_propertyFlags |= (1 << 9);
_replyTo = replyTo;
@@ -542,14 +561,14 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
public String getMessageId()
{
decodeIfNecessary();
- return _messageId;
+ return _messageId == null ? null : _messageId.toString();
}
public void setMessageId(String messageId)
{
clearEncodedForm();
_propertyFlags |= (1 << 7);
- _messageId = messageId;
+ _messageId = messageId == null ? null : new AMQShortString(messageId);
}
public long getTimestamp()
@@ -568,57 +587,528 @@ public class BasicContentHeaderProperties implements ContentHeaderProperties
public String getType()
{
decodeIfNecessary();
- return _type;
+ return _type == null ? null : _type.toString();
}
public void setType(String type)
{
clearEncodedForm();
_propertyFlags |= (1 << 5);
- _type = type;
+ _type = type == null ? null : new AMQShortString(type);
}
public String getUserId()
{
decodeIfNecessary();
- return _userId;
+ return _userId == null ? null : _userId.toString();
}
public void setUserId(String userId)
{
clearEncodedForm();
_propertyFlags |= (1 << 4);
- _userId = userId;
+ _userId = userId == null ? null : new AMQShortString(userId);
}
public String getAppId()
{
decodeIfNecessary();
- return _appId;
+ return _appId == null ? null : _appId.toString();
}
public void setAppId(String appId)
{
clearEncodedForm();
_propertyFlags |= (1 << 3);
- _appId = appId;
+ _appId = appId == null ? null : new AMQShortString(appId);
}
public String getClusterId()
{
decodeIfNecessary();
- return _clusterId;
+ return _clusterId == null ? null : _clusterId.toString();
}
public void setClusterId(String clusterId)
{
clearEncodedForm();
_propertyFlags |= (1 << 2);
- _clusterId = clusterId;
+ _clusterId = clusterId == null ? null : new AMQShortString(clusterId);
}
public String toString()
{
return "reply-to = " + _replyTo + " propertyFlags = " + _propertyFlags;
}
+
+ // MapMessage Interface
+ public boolean getBoolean(String string) throws JMSException
+ {
+ Boolean b = getHeaders().getBoolean(string);
+
+ if (b == null)
+ {
+ if (getHeaders().containsKey(string))
+ {
+ Object str = getHeaders().getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getBoolean can't use " + string + " item.");
+ }
+ else
+ {
+ return Boolean.valueOf((String) str);
+ }
+ }
+ else
+ {
+ b = Boolean.valueOf(null);
+ }
+ }
+
+ return b;
+ }
+
+ public boolean getBoolean(AMQShortString string) throws JMSException
+ {
+ Boolean b = getHeaders().getBoolean(string);
+
+ if (b == null)
+ {
+ if (getHeaders().containsKey(string))
+ {
+ Object str = getHeaders().getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getBoolean can't use " + string + " item.");
+ }
+ else
+ {
+ return Boolean.valueOf((String) str);
+ }
+ }
+ else
+ {
+ b = Boolean.valueOf(null);
+ }
+ }
+
+ return b;
+ }
+
+ public char getCharacter(String string) throws JMSException
+ {
+ Character c = getHeaders().getCharacter(string);
+
+ if (c == null)
+ {
+ if (getHeaders().isNullStringValue(string))
+ {
+ throw new NullPointerException("Cannot convert null char");
+ }
+ else
+ {
+ throw new MessageFormatException("getChar can't use " + string + " item.");
+ }
+ }
+ else
+ {
+ return (char) c;
+ }
+ }
+
+ public byte[] getBytes(String string) throws JMSException
+ {
+ return getBytes(new AMQShortString(string));
+ }
+
+ public byte[] getBytes(AMQShortString string) throws JMSException
+ {
+ byte[] bs = getHeaders().getBytes(string);
+
+ if (bs == null)
+ {
+ throw new MessageFormatException("getBytes can't use " + string + " item.");
+ }
+ else
+ {
+ return bs;
+ }
+ }
+
+ public byte getByte(String string) throws JMSException
+ {
+ Byte b = getHeaders().getByte(string);
+ if (b == null)
+ {
+ if (getHeaders().containsKey(string))
+ {
+ Object str = getHeaders().getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getByte can't use " + string + " item.");
+ }
+ else
+ {
+ return Byte.valueOf((String) str);
+ }
+ }
+ else
+ {
+ b = Byte.valueOf(null);
+ }
+ }
+
+ return b;
+ }
+
+ public short getShort(String string) throws JMSException
+ {
+ Short s = getHeaders().getShort(string);
+
+ if (s == null)
+ {
+ s = Short.valueOf(getByte(string));
+ }
+
+ return s;
+ }
+
+ public int getInteger(String string) throws JMSException
+ {
+ Integer i = getHeaders().getInteger(string);
+
+ if (i == null)
+ {
+ i = Integer.valueOf(getShort(string));
+ }
+
+ return i;
+ }
+
+ public long getLong(String string) throws JMSException
+ {
+ Long l = getHeaders().getLong(string);
+
+ if (l == null)
+ {
+ l = Long.valueOf(getInteger(string));
+ }
+
+ return l;
+ }
+
+ public float getFloat(String string) throws JMSException
+ {
+ Float f = getHeaders().getFloat(string);
+
+ if (f == null)
+ {
+ if (getHeaders().containsKey(string))
+ {
+ Object str = getHeaders().getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getFloat can't use " + string + " item.");
+ }
+ else
+ {
+ return Float.valueOf((String) str);
+ }
+ }
+ else
+ {
+ f = Float.valueOf(null);
+ }
+
+ }
+
+ return f;
+ }
+
+ public double getDouble(String string) throws JMSException
+ {
+ Double d = getHeaders().getDouble(string);
+
+ if (d == null)
+ {
+ d = Double.valueOf(getFloat(string));
+ }
+
+ return d;
+ }
+
+ public String getString(String string) throws JMSException
+ {
+ String s = getHeaders().getString(string);
+
+ if (s == null)
+ {
+ if (getHeaders().containsKey(string))
+ {
+ Object o = getHeaders().getObject(string);
+ if (o instanceof byte[])
+ {
+ throw new MessageFormatException("getObject couldn't find " + string + " item.");
+ }
+ else
+ {
+ if (o == null)
+ {
+ return null;
+ }
+ else
+ {
+ s = String.valueOf(o);
+ }
+ }
+ }
+ }
+
+ return s;
+ }
+
+ public Object getObject(String string) throws JMSException
+ {
+ return getHeaders().getObject(string);
+ }
+
+ public void setBoolean(AMQShortString string, boolean b) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setBoolean(string, b);
+ }
+
+ public void setBoolean(String string, boolean b) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setBoolean(string, b);
+ }
+
+ public void setChar(String string, char c) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setChar(string, c);
+ }
+
+ public Object setBytes(AMQShortString string, byte[] bytes)
+ {
+ return getHeaders().setBytes(string, bytes);
+ }
+
+ public Object setBytes(String string, byte[] bytes)
+ {
+ return getHeaders().setBytes(string, bytes);
+ }
+
+ public Object setBytes(String string, byte[] bytes, int start, int length)
+ {
+ return getHeaders().setBytes(string, bytes, start, length);
+ }
+
+ public void setByte(String string, byte b) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setByte(string, b);
+ }
+
+ public void setShort(String string, short i) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setShort(string, i);
+ }
+
+ public void setInteger(String string, int i) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setInteger(string, i);
+ }
+
+ public void setLong(String string, long l) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setLong(string, l);
+ }
+
+ public void setFloat(String string, float v) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setFloat(string, v);
+ }
+
+ public void setDouble(String string, double v) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setDouble(string, v);
+ }
+
+ public void setString(String string, String string1) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setString(string, string1);
+ }
+
+ public void setString(AMQShortString string, String string1) throws JMSException
+ {
+ checkPropertyName(string);
+ getHeaders().setString(string, string1);
+ }
+
+ public void setObject(String string, Object object) throws JMSException
+ {
+ checkPropertyName(string);
+ try
+ {
+ getHeaders().setObject(string, object);
+ }
+ catch (AMQPInvalidClassException aice)
+ {
+ throw new MessageFormatException("Only primatives are allowed object is:" + object.getClass());
+ }
+ }
+
+ public boolean itemExists(String string) throws JMSException
+ {
+ return getHeaders().containsKey(string);
+ }
+
+ public Enumeration getPropertyNames()
+ {
+ return getHeaders().getPropertyNames();
+ }
+
+ public void clear()
+ {
+ getHeaders().clear();
+ }
+
+ public boolean propertyExists(AMQShortString propertyName)
+ {
+ return getHeaders().propertyExists(propertyName);
+ }
+
+ public boolean propertyExists(String propertyName)
+ {
+ return getHeaders().propertyExists(propertyName);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ return getHeaders().setObject(key.toString(), value);
+ }
+
+ public Object remove(AMQShortString propertyName)
+ {
+ return getHeaders().remove(propertyName);
+ }
+
+ public Object remove(String propertyName)
+ {
+ return getHeaders().remove(propertyName);
+ }
+
+ public boolean isEmpty()
+ {
+ return getHeaders().isEmpty();
+ }
+
+ public void writeToBuffer(ByteBuffer data)
+ {
+ getHeaders().writeToBuffer(data);
+ }
+
+ public Enumeration getMapNames()
+ {
+ return getPropertyNames();
+ }
+
+ protected static void checkPropertyName(CharSequence propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name must not be null");
+ }
+ else if (propertyName.length() == 0)
+ {
+ throw new IllegalArgumentException("Property name must not be the empty string");
+ }
+
+ checkIdentiferFormat(propertyName);
+ }
+
+ protected static void checkIdentiferFormat(CharSequence propertyName)
+ {
+// JMS requirements 3.5.1 Property Names
+// Identifiers:
+// - An identifier is an unlimited-length character sequence that must begin
+// with a Java identifier start character; all following characters must be Java
+// identifier part characters. An identifier start character is any character for
+// which the method Character.isJavaIdentifierStart returns true. This includes
+// '_' and '$'. An identifier part character is any character for which the
+// method Character.isJavaIdentifierPart returns true.
+// - Identifiers cannot be the names NULL, TRUE, or FALSE.
+// – Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, IS, or
+// ESCAPE.
+// – Identifiers are either header field references or property references. The
+// type of a property value in a message selector corresponds to the type
+// used to set the property. If a property that does not exist in a message is
+// referenced, its value is NULL. The semantics of evaluating NULL values
+// in a selector are described in Section 3.8.1.2, “Null Values.”
+// – The conversions that apply to the get methods for properties do not
+// apply when a property is used in a message selector expression. For
+// example, suppose you set a property as a string value, as in the
+// following:
+// myMessage.setStringProperty("NumberOfOrders", "2");
+// The following expression in a message selector would evaluate to false,
+// because a string cannot be used in an arithmetic expression:
+// "NumberOfOrders > 1"
+// – Identifiers are case sensitive.
+// – Message header field references are restricted to JMSDeliveryMode,
+// JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and
+// JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be
+// null and if so are treated as a NULL value.
+
+ if (Boolean.getBoolean("strict-jms"))
+ {
+ // JMS start character
+ if (!(Character.isJavaIdentifierStart(propertyName.charAt(0))))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' does not start with a valid JMS identifier start character");
+ }
+
+ // JMS part character
+ int length = propertyName.length();
+ for (int c = 1; c < length; c++)
+ {
+ if (!(Character.isJavaIdentifierPart(propertyName.charAt(c))))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' contains an invalid JMS identifier character");
+ }
+ }
+
+
+
+
+ // JMS invalid names
+ if ((propertyName.equals("NULL")
+ || propertyName.equals("TRUE")
+ || propertyName.equals("FALSE")
+ || propertyName.equals("NOT")
+ || propertyName.equals("AND")
+ || propertyName.equals("OR")
+ || propertyName.equals("BETWEEN")
+ || propertyName.equals("LIKE")
+ || propertyName.equals("IN")
+ || propertyName.equals("IS")
+ || propertyName.equals("ESCAPE")))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' is not allowed in JMS");
+ }
+ }
+
+ }
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java b/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
index 3a2e4b3b3c..d5fccf9409 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/ContentBody.java
@@ -28,6 +28,15 @@ public class ContentBody extends AMQBody
public ByteBuffer payload;
+ public ContentBody()
+ {
+ }
+
+ public ContentBody(ByteBuffer payload)
+ {
+ this.payload = payload;
+ }
+
protected byte getFrameType()
{
return TYPE;
diff --git a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
index ebda2c5d2b..67b2d16ec0 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
@@ -35,6 +35,7 @@ public class EncodingUtils
public static final int SIZEOF_UNSIGNED_SHORT = 2;
public static final int SIZEOF_UNSIGNED_INT = 4;
+ private static final boolean[] ALL_FALSE_ARRAY = new boolean[8];
public static int encodedShortStringLength(String s)
{
@@ -48,6 +49,120 @@ public class EncodingUtils
}
}
+
+ public static int encodedShortStringLength(short s)
+ {
+ if( s == 0 )
+ {
+ return 1 + 1;
+ }
+
+ int len = 0;
+ if(s < 0)
+ {
+ len=1;
+ // sloppy - doesn't work of Integer.MIN_VALUE
+ s=(short)-s;
+ }
+
+ if(s>9999)
+ {
+ return 1+5;
+ }
+ else if(s>999)
+ {
+ return 1+4;
+ }
+ else if(s>99)
+ {
+ return 1+3;
+ }
+ else if(s>9)
+ {
+ return 1+2;
+ }
+ else
+ {
+ return 1+1;
+ }
+
+ }
+
+
+ public static int encodedShortStringLength(int i)
+ {
+ if( i == 0 )
+ {
+ return 1 + 1;
+ }
+
+ int len = 0;
+ if(i < 0)
+ {
+ len=1;
+ // sloppy - doesn't work of Integer.MIN_VALUE
+ i=-i;
+ }
+
+ // range is now 1 - 2147483647
+ if(i < Short.MAX_VALUE)
+ {
+ return len + encodedShortStringLength((short)i);
+ }
+ else if (i > 999999)
+ {
+ return len + 6 + encodedShortStringLength((short)(i/1000000));
+ }
+ else // if (i > 99999)
+ {
+ return len + 5 + encodedShortStringLength((short)(i/100000));
+ }
+
+ }
+
+ public static int encodedShortStringLength(long l)
+ {
+ if(l == 0)
+ {
+ return 1 + 1;
+ }
+
+ int len = 0;
+ if(l < 0)
+ {
+ len=1;
+ // sloppy - doesn't work of Long.MIN_VALUE
+ l=-l;
+ }
+ if(l < Integer.MAX_VALUE)
+ {
+ return len + encodedShortStringLength((int) l);
+ }
+ else if(l > 9999999999L)
+ {
+ return len + 10 + encodedShortStringLength((int) (l / 10000000000L));
+ }
+ else
+ {
+ return len + 1 + encodedShortStringLength((int) (l / 10L));
+ }
+
+ }
+
+
+ public static int encodedShortStringLength(AMQShortString s)
+ {
+ if (s == null)
+ {
+ return 1;
+ }
+ else
+ {
+ return (short) (1 + s.length());
+ }
+ }
+
+
public static int encodedLongStringLength(String s)
{
if (s == null)
@@ -124,6 +239,21 @@ public class EncodingUtils
}
}
+
+ public static void writeShortStringBytes(ByteBuffer buffer, AMQShortString s)
+ {
+ if (s != null)
+ {
+
+ s.writeToBuffer(buffer);
+ }
+ else
+ {
+ // really writing out unsigned byte
+ buffer.put((byte) 0);
+ }
+ }
+
public static void writeLongStringBytes(ByteBuffer buffer, String s)
{
assert s == null || s.length() <= 0xFFFE;
@@ -284,13 +414,27 @@ public class EncodingUtils
public static boolean[] readBooleans(ByteBuffer buffer)
{
- byte packedValue = buffer.get();
- boolean[] result = new boolean[8];
+ final byte packedValue = buffer.get();
+ if(packedValue == 0)
+ {
+ return ALL_FALSE_ARRAY;
+ }
+ final boolean[] result = new boolean[8];
- for (int i = 0; i < 8; i++)
+ result[0] = ((packedValue & 1) != 0);
+ result[1] = ((packedValue & (1 << 1)) != 0);
+ result[2] = ((packedValue & (1 << 2)) != 0);
+ result[3] = ((packedValue & (1 << 3)) != 0);
+ if((packedValue & 0xF0) == 0)
{
- result[i] = ((packedValue & (1 << i)) != 0);
+ result[0] = ((packedValue & 1) != 0);
}
+ result[4] = ((packedValue & (1 << 4)) != 0);
+ result[5] = ((packedValue & (1 << 5)) != 0);
+ result[6] = ((packedValue & (1 << 6)) != 0);
+ result[7] = ((packedValue & (1 << 7)) != 0);
+
+
return result;
}
@@ -313,6 +457,12 @@ public class EncodingUtils
return null;
}
+ public static AMQShortString readAMQShortString(ByteBuffer buffer)
+ {
+ return AMQShortString.readFromBuffer(buffer);
+
+ }
+
public static String readShortString(ByteBuffer buffer)
{
short length = buffer.getUnsigned();
@@ -628,4 +778,83 @@ public class EncodingUtils
writeByte(buffer, (byte) character);
}
+
+
+ public static void main(String[] args)
+ {
+ long[] nums = { 1000000000000000000L,
+ 100000000000000000L,
+ 10000000000000000L,
+ 1000000000000000L,
+ 100000000000000L,
+ 10000000000000L,
+ 1000000000000L,
+ 100000000000L,
+ 10000000000L,
+ 1000000000L,
+ 100000000L,
+ 10000000L,
+ 1000000L,
+ 100000L,
+ 10000L,
+ 1000L,
+ 100L,
+ 10L,
+ 1L,
+ 0L,
+ 787987932453564535L,
+ 543289830889480230L,
+ 3748104703875785L,
+ 463402485702857L,
+ 87402780489392L,
+ 1190489015032L,
+ 134303883744L
+ };
+
+
+
+
+ for(int i = 0; i < nums.length; i++)
+ {
+ ByteBuffer buffer = ByteBuffer.allocate(25);
+ writeShortStringBytes(buffer, String.valueOf(nums[i]));
+ buffer.flip();
+ System.out.println(nums[i] + " : " + readLongAsShortString(buffer));
+ }
+ }
+
+ public static long readLongAsShortString(ByteBuffer buffer)
+ {
+ short length = buffer.getUnsigned();
+ short pos = 0;
+ if(length == 0)
+ {
+ return 0L;
+ }
+ byte digit = buffer.get();
+ boolean isNegative;
+ long result = 0;
+ if(digit == (byte)'-')
+ {
+ isNegative = true;
+ pos++;
+ digit = buffer.get();
+ }
+ else
+ {
+ isNegative = false;
+ }
+ result = digit - (byte)'0';
+ pos++;
+
+ while(pos < length)
+ {
+ pos++;
+ digit = buffer.get();
+ result = (result << 3) + (result << 1);
+ result += digit - (byte)'0';
+ }
+
+ return result;
+ }
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index 3c18683609..147601b9f9 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
@@ -31,17 +31,16 @@ public class FieldTable
{
private static final Logger _logger = Logger.getLogger(FieldTable.class);
- private LinkedHashMap<String, AMQTypedValue> _properties;
+ private ByteBuffer _encodedForm;
+ private LinkedHashMap<AMQShortString, AMQTypedValue> _properties;
+ private long _encodedSize;
+ private static final int INITIAL_HASHMAP_CAPACITY = 16;
public FieldTable()
{
super();
- _properties = new LinkedHashMap<String, AMQTypedValue>();
-
}
-
-
/**
* Construct a new field table.
*
@@ -52,14 +51,105 @@ public class FieldTable
public FieldTable(ByteBuffer buffer, long length) throws AMQFrameDecodingException
{
this();
- setFromBuffer(buffer, length);
+ _encodedForm = buffer.slice();
+ _encodedForm.limit((int)length);
+ _encodedSize = length;
+ buffer.skip((int)length);
}
+ private AMQTypedValue getProperty(AMQShortString string)
+ {
+ synchronized(this)
+ {
+ if(_properties == null)
+ {
+ if(_encodedForm == null)
+ {
+ return null;
+ }
+ else
+ {
+ populateFromBuffer();
+ }
+ }
+ }
+
+ if(_properties == null)
+ {
+ return null;
+ }
+ else
+ {
+ return _properties.get(string);
+ }
+ }
+
+ private void populateFromBuffer()
+ {
+ try
+ {
+ setFromBuffer(_encodedForm, _encodedSize);
+ }
+ catch (AMQFrameDecodingException e)
+ {
+ _logger.error("Error decoding FieldTable in deferred decoding mode ", e);
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+
+ private AMQTypedValue setProperty(AMQShortString key, AMQTypedValue val)
+ {
+ initMapIfNecessary();
+ _encodedForm = null;
+ if(val == null)
+ {
+ return removeKey(key);
+ }
+ AMQTypedValue oldVal = _properties.put(key,val);
+ if(oldVal != null)
+ {
+ _encodedSize -= oldVal.getEncodingSize();
+ }
+ else
+ {
+ _encodedSize += EncodingUtils.encodedShortStringLength(key) + 1;
+ }
+ _encodedSize += val.getEncodingSize();
+
+ return oldVal;
+ }
+
+ private void initMapIfNecessary()
+ {
+ synchronized(this)
+ {
+ if(_properties == null)
+ {
+ if(_encodedForm == null)
+ {
+ _properties = new LinkedHashMap<AMQShortString,AMQTypedValue>();
+ }
+ else
+ {
+ populateFromBuffer();
+ }
+ }
+
+ }
+ }
+
+
public Boolean getBoolean(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getBoolean(new AMQShortString(string));
+ }
+
+ public Boolean getBoolean(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.BOOLEAN))
{
return (Boolean) value.getValue();
@@ -70,9 +160,15 @@ public class FieldTable
}
}
+
public Byte getByte(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getByte(new AMQShortString(string));
+ }
+
+ public Byte getByte(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.BYTE))
{
return (Byte) value.getValue();
@@ -85,7 +181,12 @@ public class FieldTable
public Short getShort(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getShort(new AMQShortString(string));
+ }
+
+ public Short getShort(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.SHORT))
{
return (Short) value.getValue();
@@ -98,7 +199,12 @@ public class FieldTable
public Integer getInteger(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getInteger(new AMQShortString(string));
+ }
+
+ public Integer getInteger(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.INT))
{
return (Integer) value.getValue();
@@ -111,7 +217,12 @@ public class FieldTable
public Long getLong(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getLong(new AMQShortString(string));
+ }
+
+ public Long getLong(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.LONG))
{
return (Long) value.getValue();
@@ -124,7 +235,12 @@ public class FieldTable
public Float getFloat(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getFloat(new AMQShortString(string));
+ }
+
+ public Float getFloat(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.FLOAT))
{
return (Float) value.getValue();
@@ -137,7 +253,12 @@ public class FieldTable
public Double getDouble(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getDouble(new AMQShortString(string));
+ }
+
+ public Double getDouble(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.DOUBLE))
{
return (Double) value.getValue();
@@ -150,7 +271,12 @@ public class FieldTable
public String getString(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getString(new AMQShortString(string));
+ }
+
+ public String getString(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if ((value != null) && ((value.getType() == AMQType.WIDE_STRING) ||
(value.getType() == AMQType.ASCII_STRING)))
{
@@ -170,7 +296,12 @@ public class FieldTable
public Character getCharacter(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getCharacter(new AMQShortString(string));
+ }
+
+ public Character getCharacter(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.ASCII_CHARACTER))
{
return (Character) value.getValue();
@@ -183,7 +314,12 @@ public class FieldTable
public byte[] getBytes(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getBytes(new AMQShortString(string));
+ }
+
+ public byte[] getBytes(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if (value != null && (value.getType() == AMQType.BINARY))
{
return (byte[]) value.getValue();
@@ -196,7 +332,12 @@ public class FieldTable
public Object getObject(String string)
{
- AMQTypedValue value = _properties.get(string);
+ return getObject(new AMQShortString(string));
+ }
+
+ public Object getObject(AMQShortString string)
+ {
+ AMQTypedValue value = getProperty(string);
if(value != null)
{
return value.getValue();
@@ -209,92 +350,172 @@ public class FieldTable
}
// ************ Setters
-
public Object setBoolean(String string, boolean b)
{
+ return setBoolean(new AMQShortString(string), b);
+ }
+
+ public Object setBoolean(AMQShortString string, boolean b)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.BOOLEAN.asTypedValue(b));
+ return setProperty(string, AMQType.BOOLEAN.asTypedValue(b));
}
public Object setByte(String string, byte b)
{
+ return setByte(new AMQShortString(string), b);
+ }
+
+ public Object setByte(AMQShortString string, byte b)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.BYTE.asTypedValue(b));
+ return setProperty(string, AMQType.BYTE.asTypedValue(b));
}
public Object setShort(String string, short i)
{
+ return setShort(new AMQShortString(string), i);
+ }
+
+ public Object setShort(AMQShortString string, short i)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.SHORT.asTypedValue(i));
+ return setProperty(string, AMQType.SHORT.asTypedValue(i));
}
+
public Object setInteger(String string, int i)
{
+ return setInteger(new AMQShortString(string), i);
+ }
+
+ public Object setInteger(AMQShortString string, int i)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.INT.asTypedValue(i));
+ return setProperty(string, AMQType.INT.asTypedValue(i));
}
+
public Object setLong(String string, long l)
{
+ return setLong(new AMQShortString(string), l);
+ }
+
+ public Object setLong(AMQShortString string, long l)
+ {
+ checkPropertyName(string);
+ return setProperty(string, AMQType.LONG.asTypedValue(l));
+ }
+
+
+ public Object setFloat(String string, float f)
+ {
+ return setFloat(new AMQShortString(string), f);
+ }
+
+ public Object setFloat(AMQShortString string, float v)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.LONG.asTypedValue(l));
+ return setProperty(string, AMQType.FLOAT.asTypedValue(v));
}
- public Object setFloat(String string, float v)
+ public Object setDouble(String string, double d)
+ {
+ return setDouble(new AMQShortString(string), d);
+ }
+
+
+ public Object setDouble(AMQShortString string, double v)
{
checkPropertyName(string);
- return _properties.put(string, AMQType.FLOAT.asTypedValue(v));
+ return setProperty(string, AMQType.DOUBLE.asTypedValue(v));
}
- public Object setDouble(String string, double v)
+
+ public Object setString(String string, String s)
+ {
+ return setString(new AMQShortString(string), s);
+ }
+
+ public Object setAsciiString(AMQShortString string, String value)
{
checkPropertyName(string);
- return _properties.put(string, AMQType.DOUBLE.asTypedValue(v));
+ if (value == null)
+ {
+ return setProperty(string, AMQType.VOID.asTypedValue(null));
+ }
+ else
+ {
+ return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value));
+ }
+
}
- public Object setString(String string, String value)
+ public Object setString(AMQShortString string, String value)
{
checkPropertyName(string);
if (value == null)
{
- return _properties.put(string, AMQType.VOID.asTypedValue(null));
+ return setProperty(string, AMQType.VOID.asTypedValue(null));
}
else
{
//FIXME: determine string encoding and set either WIDE or ASCII string
// if ()
{
- return _properties.put(string, AMQType.WIDE_STRING.asTypedValue(value));
+ return setProperty(string, AMQType.WIDE_STRING.asTypedValue(value));
}
// else
// {
-// return _properties.put(string, AMQType.ASCII_STRING.asTypedValue(value));
+// return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value));
// }
}
}
+
public Object setChar(String string, char c)
{
+ return setChar(new AMQShortString(string), c);
+ }
+
+
+ public Object setChar(AMQShortString string, char c)
+ {
checkPropertyName(string);
- return _properties.put(string, AMQType.ASCII_CHARACTER.asTypedValue(c));
+ return setProperty(string, AMQType.ASCII_CHARACTER.asTypedValue(c));
}
- public Object setBytes(String string, byte[] bytes)
+
+ public Object setBytes(String string, byte[] b)
+ {
+ return setBytes(new AMQShortString(string), b);
+ }
+
+ public Object setBytes(AMQShortString string, byte[] bytes)
{
checkPropertyName(string);
- return _properties.put(string, AMQType.BINARY.asTypedValue(bytes));
+ return setProperty(string, AMQType.BINARY.asTypedValue(bytes));
}
public Object setBytes(String string, byte[] bytes, int start, int length)
{
+ return setBytes(new AMQShortString(string), bytes,start,length);
+ }
+
+ public Object setBytes(AMQShortString string, byte[] bytes, int start, int length)
+ {
checkPropertyName(string);
byte[] newBytes = new byte[length];
System.arraycopy(bytes,start,newBytes,0,length);
return setBytes(string, bytes);
}
+ public Object setObject(String string, Object o)
+ {
+ return setObject(new AMQShortString(string), o);
+ }
- public Object setObject(String string, Object object)
+ public Object setObject(AMQShortString string, Object object)
{
if (object instanceof Boolean)
{
@@ -343,7 +564,7 @@ public class FieldTable
public boolean isNullStringValue(String name)
{
- AMQTypedValue value = _properties.get(name);
+ AMQTypedValue value = getProperty(new AMQShortString(name));
return (value != null) && (value.getType() == AMQType.VOID);
}
@@ -351,7 +572,12 @@ public class FieldTable
public Enumeration getPropertyNames()
{
- return Collections.enumeration(_properties.keySet());
+ return Collections.enumeration(keys());
+ }
+
+ public boolean propertyExists(AMQShortString propertyName)
+ {
+ return itemExists(propertyName);
}
public boolean propertyExists(String propertyName)
@@ -359,25 +585,32 @@ public class FieldTable
return itemExists(propertyName);
}
- public boolean itemExists(String string)
+ public boolean itemExists(AMQShortString string)
{
+ initMapIfNecessary();
return _properties.containsKey(string);
}
+ public boolean itemExists(String string)
+ {
+ return itemExists(new AMQShortString(string));
+ }
+
public String toString()
{
+ initMapIfNecessary();
return _properties.toString();
}
- private void checkPropertyName(String propertyName)
+ private void checkPropertyName(AMQShortString propertyName)
{
if (propertyName == null)
{
throw new IllegalArgumentException("Property name must not be null");
}
- else if ("".equals(propertyName))
+ else if (propertyName.length()==0)
{
throw new IllegalArgumentException("Property name must not be the empty string");
}
@@ -386,7 +619,7 @@ public class FieldTable
}
- protected static void checkIdentiferFormat(String propertyName)
+ protected static void checkIdentiferFormat(AMQShortString propertyName)
{
// AMQP Spec: 4.2.5.5 Field Tables
// Guidelines for implementers:
@@ -448,20 +681,31 @@ public class FieldTable
public long getEncodedSize()
{
+ return _encodedSize;
+ }
+
+ private void recalculateEncodedSize()
+ {
+
int encodedSize = 0;
- for(Map.Entry<String,AMQTypedValue> e : _properties.entrySet())
+ if(_properties != null)
{
- encodedSize += EncodingUtils.encodedShortStringLength(e.getKey());
- encodedSize++; // the byte for the encoding Type
- encodedSize += e.getValue().getEncodingSize();
+ for(Map.Entry<AMQShortString,AMQTypedValue> e : _properties.entrySet())
+ {
+ encodedSize += EncodingUtils.encodedShortStringLength(e.getKey());
+ encodedSize++; // the byte for the encoding Type
+ encodedSize += e.getValue().getEncodingSize();
+ }
}
- return encodedSize;
+ _encodedSize = encodedSize;
}
public void addAll(FieldTable fieldTable)
{
+ initMapIfNecessary();
_properties.putAll(fieldTable._properties);
+ recalculateEncodedSize();
}
@@ -473,135 +717,209 @@ public class FieldTable
public Object processOverElements(FieldTableElementProcessor processor)
{
- for(Map.Entry<String,AMQTypedValue> e : _properties.entrySet())
+ initMapIfNecessary();
+ if(_properties != null)
{
- boolean result = processor.processElement(e.getKey(), e.getValue());
- if(!result)
+ for(Map.Entry<AMQShortString,AMQTypedValue> e : _properties.entrySet())
{
- break;
+ boolean result = processor.processElement(e.getKey().toString(), e.getValue());
+ if(!result)
+ {
+ break;
+ }
}
}
return processor.getResult();
+
+
}
public int size()
{
+ initMapIfNecessary();
return _properties.size();
+
}
public boolean isEmpty()
{
- return _properties.isEmpty();
+ return size() ==0;
}
- public boolean containsKey(String key)
+ public boolean containsKey(AMQShortString key)
{
+ initMapIfNecessary();
return _properties.containsKey(key);
}
+ public boolean containsKey(String key)
+ {
+ return containsKey(new AMQShortString(key));
+ }
+
public Set<String> keys()
{
- return _properties.keySet();
+ initMapIfNecessary();
+ Set<String> keys = new LinkedHashSet<String>();
+ for(AMQShortString key : _properties.keySet())
+ {
+ keys.add(key.toString());
+ }
+ return keys;
}
- public Object get(Object key)
+ public Object get(AMQShortString key)
{
- return getObject((String)key);
+ return getObject(key);
}
- public Object put(Object key, Object value)
+
+ public Object put(AMQShortString key, Object value)
{
- return setObject(key.toString(), value);
+ return setObject(key, value);
}
-
+
public Object remove(String key)
{
+
+ return remove(new AMQShortString(key));
+
+ }
+
+ public Object remove(AMQShortString key)
+ {
+ AMQTypedValue val = removeKey(key);
+ return val == null ? null : val.getValue();
+
+ }
+
+
+ public AMQTypedValue removeKey(AMQShortString key)
+ {
+ initMapIfNecessary();
+ _encodedForm = null;
AMQTypedValue value = _properties.remove(key);
- return value == null ? null : value.getValue();
+ if(value == null)
+ {
+ return null;
+ }
+ else
+ {
+ _encodedSize -= EncodingUtils.encodedShortStringLength(key);
+ _encodedSize--;
+ _encodedSize -= value.getEncodingSize();
+ return value;
+ }
+
}
public void clear()
{
+ initMapIfNecessary();
+ _encodedForm = null;
_properties.clear();
+ _encodedSize = 0;
}
- public Set keySet()
+ public Set<AMQShortString> keySet()
{
+ initMapIfNecessary();
return _properties.keySet();
}
private void putDataInBuffer(ByteBuffer buffer)
{
- final Iterator<Map.Entry<String,AMQTypedValue>> it = _properties.entrySet().iterator();
+ if(_encodedForm != null)
+ {
+ buffer.put(_encodedForm);
+ }
+ else if(_properties != null)
+ {
+ final Iterator<Map.Entry<AMQShortString,AMQTypedValue>> it = _properties.entrySet().iterator();
- //If there are values then write out the encoded Size... could check _encodedSize != 0
- // write out the total length, which we have kept up to date as data is added
+ //If there are values then write out the encoded Size... could check _encodedSize != 0
+ // write out the total length, which we have kept up to date as data is added
- while (it.hasNext())
- {
- final Map.Entry<String,AMQTypedValue> me = it.next();
- try
+ while (it.hasNext())
{
- if (_logger.isTraceEnabled())
+ final Map.Entry<AMQShortString,AMQTypedValue> me = it.next();
+ try
{
- _logger.trace("Writing Property:" + me.getKey() +
- " Type:" + me.getValue().getType() +
- " Value:" + me.getValue().getValue());
- _logger.trace("Buffer Position:" + buffer.position() +
- " Remaining:" + buffer.remaining());
- }
+ if (_logger.isTraceEnabled())
+ {
+ _logger.trace("Writing Property:" + me.getKey() +
+ " Type:" + me.getValue().getType() +
+ " Value:" + me.getValue().getValue());
+ _logger.trace("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
+ }
- //Write the actual parameter name
- EncodingUtils.writeShortStringBytes(buffer, me.getKey());
- me.getValue().writeToBuffer(buffer);
- }
- catch (Exception e)
- {
- if (_logger.isTraceEnabled())
+ //Write the actual parameter name
+ EncodingUtils.writeShortStringBytes(buffer, me.getKey());
+ me.getValue().writeToBuffer(buffer);
+ }
+ catch (Exception e)
{
- _logger.trace("Exception thrown:" + e);
- _logger.trace("Writing Property:" + me.getKey() +
- " Type:" + me.getValue().getType() +
- " Value:" + me.getValue().getValue());
- _logger.trace("Buffer Position:" + buffer.position() +
- " Remaining:" + buffer.remaining());
+ if (_logger.isTraceEnabled())
+ {
+ _logger.trace("Exception thrown:" + e);
+ _logger.trace("Writing Property:" + me.getKey() +
+ " Type:" + me.getValue().getType() +
+ " Value:" + me.getValue().getValue());
+ _logger.trace("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
+ }
+ throw new RuntimeException(e);
}
- throw new RuntimeException(e);
}
}
}
- public void setFromBuffer(ByteBuffer buffer, long length) throws AMQFrameDecodingException
+ private void setFromBuffer(ByteBuffer buffer, long length) throws AMQFrameDecodingException
{
- final boolean trace = _logger.isTraceEnabled();
- int sizeRead = 0;
- while (sizeRead < length)
+ final boolean trace = _logger.isTraceEnabled();
+ if(length > 0)
{
- int sizeRemaining = buffer.remaining();
- final String key = EncodingUtils.readShortString(buffer);
- AMQTypedValue value = AMQTypedValue.readFromBuffer(buffer);
- sizeRead += (sizeRemaining - buffer.remaining());
- if (trace)
+ final int expectedRemaining = buffer.remaining()-(int)length;
+
+ _properties = new LinkedHashMap<AMQShortString,AMQTypedValue>(INITIAL_HASHMAP_CAPACITY);
+
+ do
{
- _logger.trace("FieldTable::PropFieldTable(buffer," + length + "): Read type '" + value.getType() + "', key '" + key + "', value '" + value.getValue() + "' (now read " + sizeRead + " of " + length + " encoded bytes)...");
+
+ final AMQShortString key = EncodingUtils.readAMQShortString(buffer);
+ AMQTypedValue value = AMQTypedValue.readFromBuffer(buffer);
+
+ if (trace)
+ {
+ _logger.trace("FieldTable::PropFieldTable(buffer," + length + "): Read type '" + value.getType() + "', key '" + key + "', value '" + value.getValue() + "'");
+ }
+
+
+
+ _properties.put(key,value);
+
+
+
}
+ while (buffer.remaining() > expectedRemaining);
- _properties.put(key,value);
}
+ _encodedSize = length;
if (trace)
{
diff --git a/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
deleted file mode 100644
index d78034cf2f..0000000000
--- a/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
-*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.framing;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.qpid.AMQPInvalidClassException;
-
-import javax.jms.MessageFormatException;
-import javax.jms.JMSException;
-import java.util.Enumeration;
-
-
-public class JMSPropertyFieldTable
-{
- private FieldTable _fieldtable;
-
- public JMSPropertyFieldTable(FieldTable table)
- {
- _fieldtable = table;
- }
-
-
- private void checkPropertyName(String propertyName)
- {
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name must not be null");
- }
- else if ("".equals(propertyName))
- {
- throw new IllegalArgumentException("Property name must not be the empty string");
- }
-
- checkIdentiferFormat(propertyName);
- }
-
- protected static void checkIdentiferFormat(String propertyName)
- {
-// JMS requirements 3.5.1 Property Names
-// Identifiers:
-// - An identifier is an unlimited-length character sequence that must begin
-// with a Java identifier start character; all following characters must be Java
-// identifier part characters. An identifier start character is any character for
-// which the method Character.isJavaIdentifierStart returns true. This includes
-// '_' and '$'. An identifier part character is any character for which the
-// method Character.isJavaIdentifierPart returns true.
-// - Identifiers cannot be the names NULL, TRUE, or FALSE.
-// – Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, IS, or
-// ESCAPE.
-// – Identifiers are either header field references or property references. The
-// type of a property value in a message selector corresponds to the type
-// used to set the property. If a property that does not exist in a message is
-// referenced, its value is NULL. The semantics of evaluating NULL values
-// in a selector are described in Section 3.8.1.2, “Null Values.”
-// – The conversions that apply to the get methods for properties do not
-// apply when a property is used in a message selector expression. For
-// example, suppose you set a property as a string value, as in the
-// following:
-// myMessage.setStringProperty("NumberOfOrders", "2");
-// The following expression in a message selector would evaluate to false,
-// because a string cannot be used in an arithmetic expression:
-// "NumberOfOrders > 1"
-// – Identifiers are case sensitive.
-// – Message header field references are restricted to JMSDeliveryMode,
-// JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and
-// JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be
-// null and if so are treated as a NULL value.
-
- if (Boolean.getBoolean("strict-jms"))
- {
- // JMS start character
- if (!(Character.isJavaIdentifierStart(propertyName.charAt(0))))
- {
- throw new IllegalArgumentException("Identifier '" + propertyName + "' does not start with a valid JMS identifier start character");
- }
-
- // JMS part character
- int length = propertyName.length();
- for (int c = 1; c < length; c++)
- {
- if (!(Character.isJavaIdentifierPart(propertyName.charAt(c))))
- {
- throw new IllegalArgumentException("Identifier '" + propertyName + "' contains an invalid JMS identifier character");
- }
- }
-
- // JMS invalid names
- if ((propertyName.equals("NULL")
- || propertyName.equals("TRUE")
- || propertyName.equals("FALSE")
- || propertyName.equals("NOT")
- || propertyName.equals("AND")
- || propertyName.equals("OR")
- || propertyName.equals("BETWEEN")
- || propertyName.equals("LIKE")
- || propertyName.equals("IN")
- || propertyName.equals("IS")
- || propertyName.equals("ESCAPE")))
- {
- throw new IllegalArgumentException("Identifier '" + propertyName + "' is not allowed in JMS");
- }
- }
-
- }
-
- // MapMessage Interface
- public boolean getBoolean(String string) throws JMSException
- {
- Boolean b = _fieldtable.getBoolean(string);
-
- if (b == null)
- {
- if (_fieldtable.containsKey(string))
- {
- Object str = _fieldtable.getObject(string);
-
- if (str == null || !(str instanceof String))
- {
- throw new MessageFormatException("getBoolean can't use " + string + " item.");
- }
- else
- {
- return Boolean.valueOf((String) str);
- }
- }
- else
- {
- b = Boolean.valueOf(null);
- }
- }
-
- return b;
- }
-
- public char getCharacter(String string) throws JMSException
- {
- Character c = _fieldtable.getCharacter(string);
-
- if (c == null)
- {
- if (_fieldtable.isNullStringValue(string))
- {
- throw new NullPointerException("Cannot convert null char");
- }
- else
- {
- throw new MessageFormatException("getChar can't use " + string + " item.");
- }
- }
- else
- {
- return (char) c;
- }
- }
-
- public byte[] getBytes(String string) throws JMSException
- {
- byte[] bs = _fieldtable.getBytes(string);
-
- if (bs == null)
- {
- throw new MessageFormatException("getBytes can't use " + string + " item.");
- }
- else
- {
- return bs;
- }
- }
-
- public byte getByte(String string) throws JMSException
- {
- Byte b = _fieldtable.getByte(string);
- if (b == null)
- {
- if (_fieldtable.containsKey(string))
- {
- Object str = _fieldtable.getObject(string);
-
- if (str == null || !(str instanceof String))
- {
- throw new MessageFormatException("getByte can't use " + string + " item.");
- }
- else
- {
- return Byte.valueOf((String) str);
- }
- }
- else
- {
- b = Byte.valueOf(null);
- }
- }
-
- return b;
- }
-
- public short getShort(String string) throws JMSException
- {
- Short s = _fieldtable.getShort(string);
-
- if (s == null)
- {
- s = Short.valueOf(getByte(string));
- }
-
- return s;
- }
-
- public int getInteger(String string) throws JMSException
- {
- Integer i = _fieldtable.getInteger(string);
-
- if (i == null)
- {
- i = Integer.valueOf(getShort(string));
- }
-
- return i;
- }
-
- public long getLong(String string) throws JMSException
- {
- Long l = _fieldtable.getLong(string);
-
- if (l == null)
- {
- l = Long.valueOf(getInteger(string));
- }
-
- return l;
- }
-
- public float getFloat(String string) throws JMSException
- {
- Float f = _fieldtable.getFloat(string);
-
- if (f == null)
- {
- if (_fieldtable.containsKey(string))
- {
- Object str = _fieldtable.getObject(string);
-
- if (str == null || !(str instanceof String))
- {
- throw new MessageFormatException("getFloat can't use " + string + " item.");
- }
- else
- {
- return Float.valueOf((String) str);
- }
- }
- else
- {
- f = Float.valueOf(null);
- }
-
- }
-
- return f;
- }
-
- public double getDouble(String string) throws JMSException
- {
- Double d = _fieldtable.getDouble(string);
-
- if (d == null)
- {
- d = Double.valueOf(getFloat(string));
- }
-
- return d;
- }
-
- public String getString(String string) throws JMSException
- {
- String s = _fieldtable.getString(string);
-
- if (s == null)
- {
- if (_fieldtable.containsKey(string))
- {
- Object o = _fieldtable.getObject(string);
- if (o instanceof byte[])
- {
- throw new MessageFormatException("getObject couldn't find " + string + " item.");
- }
- else
- {
- if (o == null)
- {
- return null;
- }
- else
- {
- s = String.valueOf(o);
- }
- }
- }
- }
-
- return s;
- }
-
- public Object getObject(String string) throws JMSException
- {
- return _fieldtable.getObject(string);
- }
-
- public void setBoolean(String string, boolean b) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setBoolean(string, b);
- }
-
- public void setChar(String string, char c) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setChar(string, c);
- }
-
- public Object setBytes(String string, byte[] bytes)
- {
- return _fieldtable.setBytes(string, bytes, 0, bytes.length);
- }
-
- public Object setBytes(String string, byte[] bytes, int start, int length)
- {
- return _fieldtable.setBytes(string, bytes, start, length);
- }
-
- public void setByte(String string, byte b) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setByte(string, b);
- }
-
- public void setShort(String string, short i) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setShort(string, i);
- }
-
- public void setInteger(String string, int i) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setInteger(string, i);
- }
-
- public void setLong(String string, long l) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setLong(string, l);
- }
-
- public void setFloat(String string, float v) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setFloat(string, v);
- }
-
- public void setDouble(String string, double v) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setDouble(string, v);
- }
-
- public void setString(String string, String string1) throws JMSException
- {
- checkPropertyName(string);
- _fieldtable.setString(string, string1);
- }
-
- public void setObject(String string, Object object) throws JMSException
- {
- checkPropertyName(string);
- try
- {
- _fieldtable.setObject(string, object);
- }
- catch (AMQPInvalidClassException aice)
- {
- throw new MessageFormatException("Only primatives are allowed object is:" + object.getClass());
- }
- }
-
- public boolean itemExists(String string) throws JMSException
- {
- return _fieldtable.containsKey(string);
- }
-
- public void setFieldTable(FieldTable headers)
- {
- _fieldtable = headers;
- }
-
- public Enumeration getPropertyNames()
- {
- return _fieldtable.getPropertyNames();
- }
-
- public void clear()
- {
- _fieldtable.clear();
- }
-
- public boolean propertyExists(String propertyName)
- {
- return _fieldtable.propertyExists(propertyName);
- }
-
- public Object put(Object key, Object value)
- {
- return _fieldtable.put(key, value);
- }
-
- public Object remove(String propertyName)
- {
- return _fieldtable.remove(propertyName);
- }
-
- public boolean isEmpty()
- {
- return _fieldtable.isEmpty();
- }
-
- public void writeToBuffer(ByteBuffer data)
- {
- _fieldtable.writeToBuffer(data);
- }
-
- public Enumeration getMapNames()
- {
- return getPropertyNames();
- }
-}
diff --git a/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
index a0d243ca30..0b9bf56875 100644
--- a/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
+++ b/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.protocol;
+import org.apache.qpid.framing.AMQShortString;
+
import java.util.Map;
import java.util.HashMap;
@@ -27,14 +29,14 @@ public final class AMQConstant
{
private int _code;
- private String _name;
+ private AMQShortString _name;
private static Map _codeMap = new HashMap();
private AMQConstant(int code, String name, boolean map)
{
_code = code;
- _name = name;
+ _name = new AMQShortString(name);
if (map)
{
_codeMap.put(new Integer(code), this);
@@ -51,7 +53,7 @@ public final class AMQConstant
return _code;
}
- public String getName()
+ public AMQShortString getName()
{
return _name;
}
diff --git a/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java b/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
index b6a0bd500a..11e6652bd7 100644
--- a/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
+++ b/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
@@ -23,6 +23,7 @@ package org.apache.qpid.url;
import org.apache.qpid.url.BindingURL;
import org.apache.qpid.url.URLHelper;
import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import java.util.HashMap;
import java.net.URI;
@@ -31,10 +32,10 @@ import java.net.URISyntaxException;
public class AMQBindingURL implements BindingURL
{
String _url;
- String _exchangeClass;
- String _exchangeName;
- String _destinationName;
- String _queueName;
+ AMQShortString _exchangeClass;
+ AMQShortString _exchangeName;
+ AMQShortString _destinationName;
+ AMQShortString _queueName;
private HashMap<String, String> _options;
@@ -84,7 +85,7 @@ public class AMQBindingURL implements BindingURL
if (connection.getPath() == null ||
connection.getPath().equals(""))
{
- URLHelper.parseError(_url.indexOf(_exchangeName) + _exchangeName.length(),
+ URLHelper.parseError(_url.indexOf(_exchangeName.toString()) + _exchangeName.length(),
"Destination or Queue requried", _url);
}
else
@@ -92,7 +93,7 @@ public class AMQBindingURL implements BindingURL
int slash = connection.getPath().indexOf("/", 1);
if (slash == -1)
{
- URLHelper.parseError(_url.indexOf(_exchangeName) + _exchangeName.length(),
+ URLHelper.parseError(_url.indexOf(_exchangeName.toString()) + _exchangeName.length(),
"Destination requried", _url);
}
else
@@ -121,6 +122,26 @@ public class AMQBindingURL implements BindingURL
}
}
+ private void setExchangeClass(String exchangeClass)
+ {
+ setExchangeClass(new AMQShortString(exchangeClass));
+ }
+
+ private void setQueueName(String name)
+ {
+ setQueueName(new AMQShortString(name));
+ }
+
+ private void setDestinationName(String name)
+ {
+ setDestinationName(new AMQShortString(name));
+ }
+
+ private void setExchangeName(String exchangeName)
+ {
+ setExchangeName(new AMQShortString(exchangeName));
+ }
+
private void processOptions()
{
//this is where we would parse any options that needed more than just storage.
@@ -131,22 +152,22 @@ public class AMQBindingURL implements BindingURL
return _url;
}
- public String getExchangeClass()
+ public AMQShortString getExchangeClass()
{
return _exchangeClass;
}
- public void setExchangeClass(String exchangeClass)
+ public void setExchangeClass(AMQShortString exchangeClass)
{
_exchangeClass = exchangeClass;
}
- public String getExchangeName()
+ public AMQShortString getExchangeName()
{
return _exchangeName;
}
- public void setExchangeName(String name)
+ public void setExchangeName(AMQShortString name)
{
_exchangeName = name;
@@ -156,17 +177,17 @@ public class AMQBindingURL implements BindingURL
}
}
- public String getDestinationName()
+ public AMQShortString getDestinationName()
{
return _destinationName;
}
- public void setDestinationName(String name)
+ public void setDestinationName(AMQShortString name)
{
_destinationName = name;
}
- public String getQueueName()
+ public AMQShortString getQueueName()
{
if (_exchangeClass.equals(ExchangeDefaults.TOPIC_EXCHANGE_CLASS))
{
@@ -174,7 +195,7 @@ public class AMQBindingURL implements BindingURL
{
if (containsOption(BindingURL.OPTION_CLIENTID) && containsOption(BindingURL.OPTION_SUBSCRIPTION))
{
- return getOption(BindingURL.OPTION_CLIENTID + ":" + BindingURL.OPTION_SUBSCRIPTION);
+ return new AMQShortString(getOption(BindingURL.OPTION_CLIENTID + ":" + BindingURL.OPTION_SUBSCRIPTION));
}
else
{
@@ -192,7 +213,7 @@ public class AMQBindingURL implements BindingURL
}
}
- public void setQueueName(String name)
+ public void setQueueName(AMQShortString name)
{
_queueName = name;
}
@@ -212,7 +233,7 @@ public class AMQBindingURL implements BindingURL
return _options.containsKey(key);
}
- public String getRoutingKey()
+ public AMQShortString getRoutingKey()
{
if (_exchangeClass.equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
{
@@ -221,15 +242,15 @@ public class AMQBindingURL implements BindingURL
if (containsOption(BindingURL.OPTION_ROUTING_KEY))
{
- return getOption(OPTION_ROUTING_KEY);
+ return new AMQShortString(getOption(OPTION_ROUTING_KEY));
}
return getDestinationName();
}
- public void setRoutingKey(String key)
+ public void setRoutingKey(AMQShortString key)
{
- setOption(OPTION_ROUTING_KEY, key);
+ setOption(OPTION_ROUTING_KEY, key.toString());
}
diff --git a/java/common/src/main/java/org/apache/qpid/url/BindingURL.java b/java/common/src/main/java/org/apache/qpid/url/BindingURL.java
index 76690b3230..86a8420d30 100644
--- a/java/common/src/main/java/org/apache/qpid/url/BindingURL.java
+++ b/java/common/src/main/java/org/apache/qpid/url/BindingURL.java
@@ -20,6 +20,8 @@
*/
package org.apache.qpid.url;
+import org.apache.qpid.framing.AMQShortString;
+
/*
Binding URL format:
<exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']*
@@ -36,21 +38,21 @@ public interface BindingURL
String getURL();
- String getExchangeClass();
+ AMQShortString getExchangeClass();
- void setExchangeClass(String exchangeClass);
+ void setExchangeClass(AMQShortString name);
- String getExchangeName();
+ AMQShortString getExchangeName();
- void setExchangeName(String name);
+ void setExchangeName(AMQShortString name);
- String getDestinationName();
+ AMQShortString getDestinationName();
- void setDestinationName(String name);
+ void setDestinationName(AMQShortString name);
- String getQueueName();
+ AMQShortString getQueueName();
- void setQueueName(String name);
+ void setQueueName(AMQShortString name);
String getOption(String key);
@@ -58,9 +60,9 @@ public interface BindingURL
boolean containsOption(String key);
- String getRoutingKey();
+ AMQShortString getRoutingKey();
- void setRoutingKey(String key);
+ void setRoutingKey(AMQShortString key);
String toString();
}
diff --git a/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java
deleted file mode 100644
index 94c97ef808..0000000000
--- a/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java
+++ /dev/null
@@ -1,1016 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *
- */
-package org.apache.qpid.framing;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import java.util.Enumeration;
-
-import org.apache.log4j.Logger;
-
-import javax.jms.JMSException;
-import javax.jms.MessageFormatException;
-
-public class JMSPropertyFieldTableTest extends TestCase
-{
-
- private static final Logger _logger = Logger.getLogger(JMSPropertyFieldTableTest.class);
-
-
- public void setUp()
- {
- System.getProperties().setProperty("strict-jms", "true");
- }
-
- public void tearDown()
- {
- System.getProperties().remove("strict-jms");
- }
-
- /**
- * Test that setting a similar named value replaces any previous value set on that name
- */
- public void testReplacement() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- //Set a boolean value
- table1.setBoolean("value", true);
-
- // reset value to an integer
- table1.setInteger("value", Integer.MAX_VALUE);
-
- //Check boolean value is null
- try
- {
- table1.getBoolean("value");
- }
- catch (MessageFormatException mfe)
- {
- //normal execution
- }
- // ... and integer value is good
- Assert.assertEquals(Integer.MAX_VALUE, table1.getInteger("value"));
- }
-
- public void testRemoval() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- //Set a boolean value
- table1.setBoolean("value", true);
-
- Assert.assertTrue(table1.getBoolean("value"));
-
- table1.remove("value");
-
- //Check boolean value is null
- try
- {
- table1.getBoolean("value");
- }
- catch (MessageFormatException mfe)
- {
- //normal execution
- }
- }
-
-
- /**
- * Set a boolean and check that we can only get it back as a boolean and a string
- * Check that attempting to lookup a non existent value returns null
- */
- public void testBoolean() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setBoolean("value", true);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Test Getting right value back
- Assert.assertEquals(true, table1.getBoolean("value"));
-
- //Check we don't get anything back for other gets
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getShort("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getDouble("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getInteger("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getLong("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- //except value as a string
- Assert.assertEquals("true", table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value will return false
- Assert.assertFalse(table1.getBoolean("Rubbish"));
- }
-
- /**
- * Set a byte and check that we can only get it back as a byte and a string
- * Check that attempting to lookup a non existent value returns null
- */
- public void testByte() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setByte("value", Byte.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getDouble("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- Assert.assertEquals(Byte.MAX_VALUE, (byte) table1.getShort("value"));
- Assert.assertEquals(Byte.MAX_VALUE, (byte) table1.getInteger("value"));
- Assert.assertEquals(Byte.MAX_VALUE, (byte) table1.getLong("value"));
- Assert.assertEquals(Byte.MAX_VALUE, table1.getByte("value"));
- //... and a the string value of it.
- Assert.assertEquals("" + Byte.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- try
- {
- table1.getByte("Rubbish");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException mfs)
- {
- //normal Execution
- }
-
- }
-
-
- /**
- * Set a short and check that we can only get it back as a short and a string
- * Check that attempting to lookup a non existent value returns null
- */
- public void testShort() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setShort("value", Short.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
-
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- try
- {
- table1.getDouble("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
-
- Assert.assertEquals(Short.MAX_VALUE, (short) table1.getLong("value"));
- Assert.assertEquals(Short.MAX_VALUE, (short) table1.getInteger("value"));
- Assert.assertEquals(Short.MAX_VALUE, table1.getShort("value"));
-
- //... and a the string value of it.
- Assert.assertEquals("" + Short.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- try
- {
- table1.getShort("Rubbish");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException mfe)
- {
- //normal path
- }
- }
-
-
- /**
- * Set a double and check that we can only get it back as a double
- * Check that attempting to lookup a non existent value returns null
- */
- public void testDouble() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setDouble("value", Double.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getShort("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getInteger("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getLong("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
- Assert.assertEquals(Double.MAX_VALUE, table1.getDouble("value"));
- //... and a the string value of it.
- Assert.assertEquals("" + Double.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- try
- {
- table1.getDouble("Rubbish");
- fail("Should throw NullPointerException as float.valueOf will try sunreadJavaFormatString");
- }
- catch (NullPointerException mfe)
- {
- //normal path
- }
-
- }
-
-
- /**
- * Set a float and check that we can only get it back as a float
- * Check that attempting to lookup a non existent value returns null
- */
- public void testFloat() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setFloat("value", Float.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getShort("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getInteger("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getLong("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
-
- Assert.assertEquals(Float.MAX_VALUE, table1.getFloat("value"));
- Assert.assertEquals(Float.MAX_VALUE, (float) table1.getDouble("value"));
-
- //... and a the string value of it.
- Assert.assertEquals("" + Float.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- try
- {
- table1.getFloat("Rubbish");
- fail("Should throw NullPointerException as float.valueOf will try sunreadJavaFormatString");
- }
- catch (NullPointerException mfe)
- {
- //normal path
- }
- }
-
-
- /**
- * Set an int and check that we can only get it back as an int
- * Check that attempting to lookup a non existent value returns null
- */
- public void testInt() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setInteger("value", Integer.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getShort("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getDouble("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
-
- Assert.assertEquals(Integer.MAX_VALUE, table1.getLong("value"));
-
- Assert.assertEquals(Integer.MAX_VALUE, table1.getInteger("value"));
-
- //... and a the string value of it.
- Assert.assertEquals("" + Integer.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- try
- {
- table1.getInteger("Rubbish");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException mfe)
- {
- //normal path
- }
- }
-
-
- /**
- * Set a long and check that we can only get it back as a long
- * Check that attempting to lookup a non existent value returns null
- */
- public void testLong() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setLong("value", Long.MAX_VALUE);
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- try
- {
- table1.getBoolean("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getByte("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getShort("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getDouble("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
- try
- {
- table1.getInteger("value");
- fail("Should throw MessageFormatException");
- }
- catch (MessageFormatException mfs)
- {
- //normal Execution
- }
-
-
- Assert.assertEquals(Long.MAX_VALUE, table1.getLong("value"));
-
- //... and a the string value of it.
- Assert.assertEquals("" + Long.MAX_VALUE, table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- // Table should now have zero length for encoding
- checkEmpty(table1);
-
- //Looking up an invalid value
- try
- {
- table1.getLong("Rubbish");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException mfs)
- {
- //normal Execution
- }
-
- }
-
-
- /**
- * Calls all methods that can be used to check the table is empty
- * - getEncodedSize
- * - isEmpty
- * - length
- *
- * @param table to check is empty
- */
- private void checkEmpty(JMSPropertyFieldTable table)
- {
- Assert.assertFalse(table.getPropertyNames().hasMoreElements());
- }
-
-
- /**
- * Set a String and check that we can only get it back as a String
- * Check that attempting to lookup a non existent value returns null
- */
- public void testString() throws JMSException
- {
- JMSPropertyFieldTable table1 = new JMSPropertyFieldTable(new FieldTable());
- table1.setString("value", "Hello");
- Assert.assertTrue(table1.propertyExists("value"));
-
- //Tets lookups we shouldn't get anything back for other gets
- //we should get right value back for this type ....
- Assert.assertEquals(false, table1.getBoolean("value"));
-
- try
- {
- table1.getByte("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
- try
- {
- table1.getShort("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
- try
- {
- table1.getDouble("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
- try
- {
- table1.getFloat("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
- try
- {
- table1.getInteger("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
- try
- {
- table1.getLong("value");
- fail("Should throw NumberFormatException");
- }
- catch (NumberFormatException nfs)
- {
- //normal Execution
- }
-
- Assert.assertEquals("Hello", table1.getString("value"));
-
- table1.remove("value");
- //but after a remove it doesn't
- Assert.assertFalse(table1.propertyExists("value"));
-
- checkEmpty(table1);
-
- //Looking up an invalid value returns null
- Assert.assertEquals(null, table1.getString("Rubbish"));
-
- //Additional Test that haven't been covered for string
- table1.setObject("value", "Hello");
- //Check that it was set correctly
- Assert.assertEquals("Hello", table1.getString("value"));
- }
-
-
- public void testValues() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
- table.setBoolean("bool", true);
- table.setDouble("double", Double.MAX_VALUE);
- table.setFloat("float", Float.MAX_VALUE);
- table.setInteger("int", Integer.MAX_VALUE);
- table.setLong("long", Long.MAX_VALUE);
- table.setShort("short", Short.MAX_VALUE);
- table.setString("string", "Hello");
- table.setString("nullstring", null);
-
- table.setObject("objectbool", true);
- table.setObject("objectdouble", Double.MAX_VALUE);
- table.setObject("objectfloat", Float.MAX_VALUE);
- table.setObject("objectint", Integer.MAX_VALUE);
- table.setObject("objectlong", Long.MAX_VALUE);
- table.setObject("objectshort", Short.MAX_VALUE);
- table.setObject("objectstring", "Hello");
-
-
- Assert.assertEquals(true, table.getBoolean("bool"));
-
- Assert.assertEquals(Double.MAX_VALUE, table.getDouble("double"));
- Assert.assertEquals(Float.MAX_VALUE, table.getFloat("float"));
- Assert.assertEquals(Integer.MAX_VALUE, table.getInteger("int"));
- Assert.assertEquals(Long.MAX_VALUE, table.getLong("long"));
- Assert.assertEquals(Short.MAX_VALUE, table.getShort("short"));
- Assert.assertEquals("Hello", table.getString("string"));
- Assert.assertEquals(null, table.getString("null-string"));
-
- Assert.assertEquals(true, table.getObject("objectbool"));
- Assert.assertEquals(Double.MAX_VALUE, table.getObject("objectdouble"));
- Assert.assertEquals(Float.MAX_VALUE, table.getObject("objectfloat"));
- Assert.assertEquals(Integer.MAX_VALUE, table.getObject("objectint"));
- Assert.assertEquals(Long.MAX_VALUE, table.getObject("objectlong"));
- Assert.assertEquals(Short.MAX_VALUE, table.getObject("objectshort"));
- Assert.assertEquals("Hello", table.getObject("objectstring"));
- }
-
- /**
- * Additional test checkPropertyName doesn't accept Null
- */
- public void testCheckPropertyNameasNull() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- try
- {
- table.setObject(null, "String");
- fail("Null property name is not allowed");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
- checkEmpty(table);
- }
-
-
- /**
- * Additional test checkPropertyName doesn't accept an empty String
- */
- public void testCheckPropertyNameasEmptyString() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- try
- {
- table.setObject("", "String");
- fail("empty property name is not allowed");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
- checkEmpty(table);
- }
-
-
- /**
- * Additional test checkPropertyName doesn't accept an empty String
- */
- public void testCheckPropertyNamehasMaxLength() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- StringBuffer longPropertyName = new StringBuffer(129);
-
- for (int i = 0; i < 129; i++)
- {
- longPropertyName.append("x");
- }
-
- try
- {
- table.setObject(longPropertyName.toString(), "String");
- fail("property name must be < 128 characters");
- }
- catch (IllegalArgumentException iae)
- {
- _logger.warn("JMS requires infinite property names AMQP limits us to 128 characters");
- }
-
- checkEmpty(table);
- }
-
-
- /**
- * Additional test checkPropertyName starts with a letter
- */
- public void testCheckPropertyNameStartCharacterIsLetter() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- //Try a name that starts with a number
- try
- {
- table.setObject("1", "String");
- fail("property name must start with a letter");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
-
- checkEmpty(table);
- }
-
- /**
- * Additional test checkPropertyName starts with a letter
- */
- public void testCheckPropertyNameContainsInvalidCharacter() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- //Try a name that starts with a number
- try
- {
- table.setObject("hello there", "String");
- fail("property name cannot contain spaces");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
-
- checkEmpty(table);
- }
-
-
- /**
- * Additional test checkPropertyName starts with a letter
- */
- public void testCheckPropertyNameIsInvalid() throws JMSException
- {
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- //Try a name that starts with a number
- try
- {
- table.setObject("ESCAPE", "String");
- fail("property name must not contains spaces");
- }
- catch (IllegalArgumentException iae)
- {
- //normal path
- }
-
- checkEmpty(table);
- }
-
- /**
- * Additional test checkPropertyName starts with a hash or a dollar
- */
- public void testCheckPropertyNameStartCharacterIsHashorDollar() throws JMSException
- {
- _logger.warn("Test:testCheckPropertyNameStartCharacterIsHashorDollar will fail JMS compilance as # and $ are not valid in a jms identifier");
-// JMSPropertyFieldTable table = new JMSPropertyFieldTable();
-//
-// //Try a name that starts with a number
-// try
-// {
-// table.setObject("#", "String");
-// table.setObject("$", "String");
-// }
-// catch (IllegalArgumentException iae)
-// {
-// fail("property name are allowed to start with # and $s in AMQP");
-// }
- }
-
- /**
- * Test the contents of the sets
- */
- public void testSets()
- {
-
- JMSPropertyFieldTable table = new JMSPropertyFieldTable(new FieldTable());
-
- table.put("n1", "1");
- table.put("n2", "2");
- table.put("n3", "3");
-
- Enumeration enumerator = table.getPropertyNames();
- Assert.assertEquals("n1", enumerator.nextElement());
- Assert.assertEquals("n2", enumerator.nextElement());
- Assert.assertEquals("n3", enumerator.nextElement());
- Assert.assertFalse(enumerator.hasMoreElements());
- }
-
- public static junit.framework.Test suite()
- {
- return new junit.framework.TestSuite(JMSPropertyFieldTableTest.class);
- }
-
-}
diff --git a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index c259d3ee8a..e0692594c7 100644
--- a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
@@ -25,8 +25,6 @@ import junit.framework.TestCase;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
import org.apache.mina.common.ByteBuffer;
import org.apache.log4j.Logger;
@@ -227,7 +225,7 @@ public class PropertyFieldTableTest extends TestCase
//... and a the string value of it.
Assert.assertEquals("" + Double.MAX_VALUE, table1.getString("value"));
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
// Table should now have zero length for encoding
@@ -265,7 +263,7 @@ public class PropertyFieldTableTest extends TestCase
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
// Table should now have zero length for encoding
@@ -303,7 +301,7 @@ public class PropertyFieldTableTest extends TestCase
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
// Table should now have zero length for encoding
@@ -341,7 +339,7 @@ public class PropertyFieldTableTest extends TestCase
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
// Table should now have zero length for encoding
@@ -380,7 +378,7 @@ public class PropertyFieldTableTest extends TestCase
Assert.assertEquals(null, table1.getString("value"));
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
// Table should now have zero length for encoding
@@ -440,7 +438,7 @@ public class PropertyFieldTableTest extends TestCase
Assert.assertTrue(table1.containsKey("value"));
table1.remove("value");
- //but after a remove it doesn't
+ //but after a removeKey it doesn't
Assert.assertFalse(table1.containsKey("value"));
checkEmpty(table1);
@@ -457,23 +455,7 @@ public class PropertyFieldTableTest extends TestCase
- public void testKeyEnumeration()
- {
- FieldTable table = new FieldTable();
- table.setLong("one", 1L);
- table.setLong("two", 2L);
- table.setLong("three", 3L);
- table.setLong("four", 4L);
- table.setLong("five", 5L);
-
- Enumeration e = table.getPropertyNames();
-
- Assert.assertTrue("one".equals(e.nextElement()));
- Assert.assertTrue("two".equals(e.nextElement()));
- Assert.assertTrue("three".equals(e.nextElement()));
- Assert.assertTrue("four".equals(e.nextElement()));
- Assert.assertTrue("five".equals(e.nextElement()));
- }
+
public void testValues()
{
@@ -758,7 +740,7 @@ public class PropertyFieldTableTest extends TestCase
try
{
- table.setObject(null, "String");
+ table.setObject((String)null, "String");
fail("Null property name is not allowed");
}
catch (IllegalArgumentException iae)
@@ -868,9 +850,9 @@ public class PropertyFieldTableTest extends TestCase
{
FieldTable table = new FieldTable();
- table.put("StringProperty", "String");
+ table.setObject("StringProperty", "String");
- Assert.assertEquals("String", table.get("StringProperty"));
+ Assert.assertEquals("String", table.getString("StringProperty"));
//Test Clear
@@ -887,15 +869,15 @@ public class PropertyFieldTableTest extends TestCase
FieldTable table = new FieldTable();
- table.put("n1", "1");
- table.put("n2", "2");
- table.put("n3", "3");
+ table.setObject("n1", "1");
+ table.setObject("n2", "2");
+ table.setObject("n3", "3");
+
+
+ Assert.assertEquals("1", table.getObject("n1"));
+ Assert.assertEquals("2", table.getObject("n2"));
+ Assert.assertEquals("3", table.getObject("n3"));
- Iterator iterator = table.keySet().iterator();
- Assert.assertEquals("n1", iterator.next());
- Assert.assertEquals("n2", iterator.next());
- Assert.assertEquals("n3", iterator.next());
- Assert.assertFalse(iterator.hasNext());
diff --git a/java/systests/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java b/java/systests/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
index 21ad1b6a7f..ec27b8a191 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
@@ -23,6 +23,7 @@ import org.apache.qpid.server.management.ManagedBroker;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.framing.AMQShortString;
public class AMQBrokerManagerMBeanTest extends TestCase
{
@@ -35,26 +36,26 @@ public class AMQBrokerManagerMBeanTest extends TestCase
String exchange2 = "testExchange2_" + System.currentTimeMillis();
String exchange3 = "testExchange3_" + System.currentTimeMillis();
- assertTrue(_exchangeRegistry.getExchange(exchange1) == null);
- assertTrue(_exchangeRegistry.getExchange(exchange2) == null);
- assertTrue(_exchangeRegistry.getExchange(exchange3) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange1)) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange2)) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange3)) == null);
ManagedBroker mbean = new AMQBrokerManagerMBean();
mbean.createNewExchange(exchange1,"direct",false, false);
mbean.createNewExchange(exchange2,"topic",false, false);
mbean.createNewExchange(exchange3,"headers",false, false);
- assertTrue(_exchangeRegistry.getExchange(exchange1) != null);
- assertTrue(_exchangeRegistry.getExchange(exchange2) != null);
- assertTrue(_exchangeRegistry.getExchange(exchange3) != null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange1)) != null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange2)) != null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange3)) != null);
mbean.unregisterExchange(exchange1);
mbean.unregisterExchange(exchange2);
mbean.unregisterExchange(exchange3);
- assertTrue(_exchangeRegistry.getExchange(exchange1) == null);
- assertTrue(_exchangeRegistry.getExchange(exchange2) == null);
- assertTrue(_exchangeRegistry.getExchange(exchange3) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange1)) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange2)) == null);
+ assertTrue(_exchangeRegistry.getExchange(new AMQShortString(exchange3)) == null);
}
public void testQueueOperations() throws Exception
@@ -62,13 +63,13 @@ public class AMQBrokerManagerMBeanTest extends TestCase
String queueName = "testQueue_" + System.currentTimeMillis();
ManagedBroker mbean = new AMQBrokerManagerMBean();
- assertTrue(_queueRegistry.getQueue(queueName) == null);
+ assertTrue(_queueRegistry.getQueue(new AMQShortString(queueName)) == null);
mbean.createNewQueue(queueName, false, "test", true);
- assertTrue(_queueRegistry.getQueue(queueName) != null);
+ assertTrue(_queueRegistry.getQueue(new AMQShortString(queueName)) != null);
mbean.deleteQueue(queueName);
- assertTrue(_queueRegistry.getQueue(queueName) == null);
+ assertTrue(_queueRegistry.getQueue(new AMQShortString(queueName)) == null);
}
@Override
diff --git a/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java b/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
index 6bcf640e4c..52afecdb6a 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
@@ -73,7 +73,7 @@ public class AbstractHeadersExchangeTestBase extends TestCase
protected TestQueue bind(String queue, FieldTable bindings) throws AMQException
{
- return bind(new TestQueue(queue), bindings);
+ return bind(new TestQueue(new AMQShortString(queue)), bindings);
}
protected TestQueue bind(TestQueue queue, String... bindings) throws AMQException
@@ -144,7 +144,7 @@ public class AbstractHeadersExchangeTestBase extends TestCase
for (String s : entries)
{
String[] parts = s.split("=", 2);
- headers.put(parts[0], parts.length > 1 ? parts[1] : "");
+ headers.setObject(parts[0], parts.length > 1 ? parts[1] : "");
}
return headers;
}
@@ -154,7 +154,7 @@ public class AbstractHeadersExchangeTestBase extends TestCase
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Establish some way to determine the version for the test.
BasicPublishBody request = new BasicPublishBody((byte)8, (byte)0);
- request.routingKey = id;
+ request.routingKey = new AMQShortString(id);
return request;
}
@@ -176,9 +176,9 @@ public class AbstractHeadersExchangeTestBase extends TestCase
{
final List<HeadersExchangeTest.Message> messages = new ArrayList<HeadersExchangeTest.Message>();
- public TestQueue(String name) throws AMQException
+ public TestQueue(AMQShortString name) throws AMQException
{
- super(name, false, "test", true, ApplicationRegistry.getInstance().getQueueRegistry());
+ super(name, false, new AMQShortString("test"), true, ApplicationRegistry.getInstance().getQueueRegistry());
}
/**
diff --git a/java/systests/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java b/java/systests/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
index bb88d2e8d0..39c47118da 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
@@ -22,6 +22,8 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.management.ManagedObject;
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
@@ -43,12 +45,12 @@ public class ExchangeMBeanTest extends TestCase
public void testDirectExchangeMBean() throws Exception
{
DestNameExchange exchange = new DestNameExchange();
- exchange.initialise("amq.direct", false, 0, true);
+ exchange.initialise(ExchangeDefaults.DIRECT_EXCHANGE_NAME, false, 0, true);
ManagedObject managedObj = exchange.getManagedObject();
ManagedExchange mbean = (ManagedExchange)managedObj;
- mbean.createNewBinding(_queue.getName(), "binding1");
- mbean.createNewBinding(_queue.getName(), "binding2");
+ mbean.createNewBinding(_queue.getName().toString(), "binding1");
+ mbean.createNewBinding(_queue.getName().toString(), "binding2");
TabularData data = mbean.bindings();
ArrayList<CompositeData> list = new ArrayList<CompositeData>(data.values());
@@ -70,12 +72,12 @@ public class ExchangeMBeanTest extends TestCase
public void testTopicExchangeMBean() throws Exception
{
DestWildExchange exchange = new DestWildExchange();
- exchange.initialise("amq.topic", false, 0, true);
+ exchange.initialise(ExchangeDefaults.TOPIC_EXCHANGE_NAME, false, 0, true);
ManagedObject managedObj = exchange.getManagedObject();
ManagedExchange mbean = (ManagedExchange)managedObj;
- mbean.createNewBinding(_queue.getName(), "binding1");
- mbean.createNewBinding(_queue.getName(), "binding2");
+ mbean.createNewBinding(_queue.getName().toString(), "binding1");
+ mbean.createNewBinding(_queue.getName().toString(), "binding2");
TabularData data = mbean.bindings();
ArrayList<CompositeData> list = new ArrayList<CompositeData>(data.values());
@@ -97,19 +99,19 @@ public class ExchangeMBeanTest extends TestCase
public void testHeadersExchangeMBean() throws Exception
{
HeadersExchange exchange = new HeadersExchange();
- exchange.initialise("amq.headers", false, 0, true);
+ exchange.initialise(ExchangeDefaults.HEADERS_EXCHANGE_NAME, false, 0, true);
ManagedObject managedObj = exchange.getManagedObject();
ManagedExchange mbean = (ManagedExchange)managedObj;
- mbean.createNewBinding(_queue.getName(), "key1=binding1,key2=binding2");
- mbean.createNewBinding(_queue.getName(), "key3=binding3");
+ mbean.createNewBinding(_queue.getName().toString(), "key1=binding1,key2=binding2");
+ mbean.createNewBinding(_queue.getName().toString(), "key3=binding3");
TabularData data = mbean.bindings();
ArrayList<CompositeData> list = new ArrayList<CompositeData>(data.values());
assertTrue(list.size() == 2);
// test general exchange properties
- assertEquals(mbean.getName(), "amq.headers");
+ assertEquals(mbean.getName(), "amq.match");
assertEquals(mbean.getExchangeType(), "headers");
assertTrue(mbean.getTicketNo() == 0);
assertTrue(!mbean.isDurable());
@@ -121,7 +123,7 @@ public class ExchangeMBeanTest extends TestCase
{
super.setUp();
_queueRegistry = ApplicationRegistry.getInstance().getQueueRegistry();
- _queue = new AMQQueue("testQueue", false, "ExchangeMBeanTest", false, _queueRegistry);
+ _queue = new AMQQueue(new AMQShortString("testQueue"), false, new AMQShortString("ExchangeMBeanTest"), false, _queueRegistry);
_queueRegistry.registerQueue(_queue);
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
index 3ff3f9cc43..d4a8f6c7f9 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
@@ -21,6 +21,7 @@ import junit.framework.TestCase;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicPublishBody;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.RequiredDeliveryException;
import org.apache.qpid.server.txn.TransactionalContext;
@@ -77,7 +78,7 @@ public class AMQQueueMBeanTest extends TestCase
_protocolSession = new MockProtocolSession(_messageStore);
_protocolSession.addChannel(_channel);
- _queue.registerProtocolSession(_protocolSession, 1, "test", false, null);
+ _queue.registerProtocolSession(_protocolSession, 1, new AMQShortString("test"), false, null);
assertTrue(_queueMBean.getActiveConsumerCount() == 1);
SubscriptionSet _subscribers = (SubscriptionSet) mgr;
@@ -174,7 +175,7 @@ public class AMQQueueMBeanTest extends TestCase
{
super.setUp();
_queueRegistry = new DefaultQueueRegistry();
- _queue = new AMQQueue("testQueue", false, "AMQueueMBeanTest", false, _queueRegistry);
+ _queue = new AMQQueue(new AMQShortString("testQueue"), false, new AMQShortString("AMQueueMBeanTest"), false, _queueRegistry);
_queueMBean = new AMQQueueMBean(_queue);
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
index 0180c2d30c..222b2c696a 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/AckTest.java
@@ -26,6 +26,7 @@ import org.apache.qpid.AMQException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.BasicPublishBody;
import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.RequiredDeliveryException;
import org.apache.qpid.server.ack.UnacknowledgedMessage;
@@ -62,6 +63,8 @@ public class AckTest extends TestCase
private AMQQueue _queue;
+ private static final AMQShortString DEFAULT_CONSUMER_TAG = new AMQShortString("conTag");
+
public AckTest() throws Exception
{
ApplicationRegistry.initialise(new TestApplicationRegistry());
@@ -75,7 +78,7 @@ public class AckTest extends TestCase
_protocolSession = new MockProtocolSession(_messageStore);
_protocolSession.addChannel(_channel);
_subscriptionManager = new SubscriptionSet();
- _queue = new AMQQueue("myQ", false, "guest", true, new DefaultQueueRegistry(), _subscriptionManager);
+ _queue = new AMQQueue(new AMQShortString("myQ"), false, new AMQShortString("guest"), true, new DefaultQueueRegistry(), _subscriptionManager);
}
private void publishMessages(int count) throws AMQException
@@ -94,8 +97,8 @@ public class AckTest extends TestCase
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Establish some way to determine the version for the test.
BasicPublishBody publishBody = new BasicPublishBody((byte)8, (byte)0);
- publishBody.routingKey = "rk";
- publishBody.exchange = "someExchange";
+ publishBody.routingKey = new AMQShortString("rk");
+ publishBody.exchange = new AMQShortString("someExchange");
AMQMessage msg = new AMQMessage(_messageStore.getNewMessageId(), publishBody, txnContext);
if (persistent)
{
@@ -126,7 +129,7 @@ public class AckTest extends TestCase
*/
public void testAckChannelAssociationTest() throws AMQException
{
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
final int msgCount = 10;
publishMessages(msgCount, true);
@@ -154,7 +157,7 @@ public class AckTest extends TestCase
public void testNoAckMode() throws AMQException
{
// false arg means no acks expected
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", false);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, false);
final int msgCount = 10;
publishMessages(msgCount);
@@ -169,7 +172,7 @@ public class AckTest extends TestCase
*/
public void testSingleAckReceivedTest() throws AMQException
{
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
final int msgCount = 10;
publishMessages(msgCount);
@@ -198,7 +201,7 @@ public class AckTest extends TestCase
*/
public void testMultiAckReceivedTest() throws AMQException
{
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
final int msgCount = 10;
publishMessages(msgCount);
@@ -222,7 +225,7 @@ public class AckTest extends TestCase
*/
public void testMultiAckAllReceivedTest() throws AMQException
{
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
final int msgCount = 10;
publishMessages(msgCount);
@@ -246,7 +249,7 @@ public class AckTest extends TestCase
int lowMark = 5;
int highMark = 10;
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
_channel.setPrefetchLowMarkCount(lowMark);
_channel.setPrefetchHighMarkCount(highMark);
@@ -297,7 +300,7 @@ public class AckTest extends TestCase
public void testPrefetch() throws AMQException
{
- _subscription = new SubscriptionImpl(5, _protocolSession, "conTag", true);
+ _subscription = new SubscriptionImpl(5, _protocolSession, DEFAULT_CONSUMER_TAG, true);
_channel.setPrefetchCount(5);
assertTrue(_channel.getPrefetchCount() == 5);
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
index 8efefaeff5..e428b9ef60 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrencyTest.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.handler.OnCurrentThreadExecutor;
import java.util.*;
@@ -52,7 +53,7 @@ public class ConcurrencyTest extends MessageTestHelper
public ConcurrencyTest() throws Exception
{
- _deliveryMgr = new ConcurrentDeliveryManager(_subscriptionMgr, new AMQQueue("myQ", false, "guest", false,
+ _deliveryMgr = new ConcurrentDeliveryManager(_subscriptionMgr, new AMQQueue(new AMQShortString("myQ"), false, new AMQShortString("guest"), false,
new DefaultQueueRegistry()));
}
@@ -186,7 +187,7 @@ public class ConcurrencyTest extends MessageTestHelper
AMQMessage msg = nextMessage();
if (msg != null)
{
- _deliveryMgr.deliver(null, toString(), msg);
+ _deliveryMgr.deliver(null, new AMQShortString(toString()), msg);
}
}
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
index 3072d44f48..1943532a51 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/ConcurrentDeliveryManagerTest.java
@@ -21,6 +21,7 @@
package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.queue.ConcurrentDeliveryManager;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.DefaultQueueRegistry;
@@ -33,7 +34,7 @@ public class ConcurrentDeliveryManagerTest extends DeliveryManagerTest
try
{
System.setProperty("concurrentdeliverymanager","true");
- _mgr = new ConcurrentDeliveryManager(_subscriptions, new AMQQueue("myQ", false, "guest", false,
+ _mgr = new ConcurrentDeliveryManager(_subscriptions, new AMQQueue(new AMQShortString("myQ"), false, new AMQShortString("guest"), false,
new DefaultQueueRegistry()));
}
catch (Throwable t)
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
index fcd2806861..d88614298f 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/DeliveryManagerTest.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.queue;
import org.apache.qpid.server.handler.OnCurrentThreadExecutor;
import org.apache.qpid.server.store.StoreContext;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import junit.framework.TestSuite;
@@ -31,6 +32,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
protected final SubscriptionSet _subscriptions = new SubscriptionSet();
protected DeliveryManager _mgr;
protected StoreContext _storeContext = new StoreContext();
+ private static final AMQShortString DEFAULT_QUEUE_NAME = new AMQShortString("Me");
public DeliveryManagerTest() throws Exception
{
@@ -47,7 +49,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
for (int i = 0; i < batch; i++)
{
- _mgr.deliver(_storeContext, "Me", messages[i]);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
}
SubscriptionTestHelper s1 = new SubscriptionTestHelper("1");
@@ -57,7 +59,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
for (int i = batch; i < messages.length; i++)
{
- _mgr.deliver(_storeContext, "Me", messages[i]);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
}
assertTrue(s1.getMessages().isEmpty());
@@ -95,7 +97,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
for (int i = 0; i < batch; i++)
{
- _mgr.deliver(_storeContext, "Me", messages[i]);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
}
assertEquals(batch, s1.getMessages().size());
@@ -109,7 +111,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
s1.setSuspended(true);
for (int i = batch; i < messages.length; i++)
{
- _mgr.deliver(_storeContext, "Me", messages[i]);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, messages[i]);
}
_mgr.processAsync(new OnCurrentThreadExecutor());
@@ -131,7 +133,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
try
{
AMQMessage msg = message(true);
- _mgr.deliver(_storeContext, "Me", msg);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, msg);
msg.checkDeliveredToConsumer();
fail("expected exception did not occur");
}
@@ -153,7 +155,7 @@ abstract public class DeliveryManagerTest extends MessageTestHelper
_subscriptions.addSubscriber(s);
s.setSuspended(true);
AMQMessage msg = message(true);
- _mgr.deliver(_storeContext, "Me", msg);
+ _mgr.deliver(_storeContext, DEFAULT_QUEUE_NAME, msg);
msg.checkDeliveredToConsumer();
fail("expected exception did not occur");
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java b/java/systests/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java
index 87e5c43932..3586749f53 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java
@@ -23,6 +23,7 @@ package org.apache.qpid.server.queue;
import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQDataBlock;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.store.MessageStore;
@@ -53,12 +54,12 @@ public class MockProtocolSession implements AMQProtocolSession
{
}
- public String getContextKey()
+ public AMQShortString getContextKey()
{
return null;
}
- public void setContextKey(String contextKey)
+ public void setContextKey(AMQShortString contextKey)
{
}
diff --git a/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java b/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
index ebe8e192a0..3c5aab0911 100644
--- a/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
+++ b/java/systests/src/test/java/org/apache/qpid/server/queue/SynchronizedDeliveryManagerTest.java
@@ -25,6 +25,7 @@ import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.DefaultQueueRegistry;
import org.apache.qpid.server.queue.DeliveryManagerTest;
import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
import junit.framework.TestSuite;
@@ -35,7 +36,7 @@ public class SynchronizedDeliveryManagerTest extends DeliveryManagerTest
try
{
System.setProperty("concurrentdeliverymanager","false");
- _mgr = new SynchronizedDeliveryManager(_subscriptions, new AMQQueue("myQ", false, "guest", false,
+ _mgr = new SynchronizedDeliveryManager(_subscriptions, new AMQQueue(new AMQShortString("myQ"), false, new AMQShortString("guest"), false,
new DefaultQueueRegistry()));
}
catch (Throwable t)