summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-03-30 21:35:08 +0000
committerTed Ross <tross@apache.org>2010-03-30 21:35:08 +0000
commite030901ad61f156c481c76f9c552f424fd36319e (patch)
tree4324570b11ef6d57214876074e1a6fac8aec0d1d
parent555230c7a5fb9d5c9af0978f5400613e2533e68c (diff)
downloadqpid-python-e030901ad61f156c481c76f9c552f424fd36319e.tar.gz
Merged the trunk back into the QMF branch.
All the make-check tests now pass with the QMF updates. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qmf-devel0.7a@929307 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qmf/python/qmf.py30
-rw-r--r--qpid/cpp/bindings/qmf/ruby/qmf.rb22
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/agent_ruby.rb6
-rw-r--r--qpid/cpp/bindings/qmf/tests/python_agent.py8
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/python_console.py23
-rwxr-xr-xqpid/cpp/bindings/qmf/tests/ruby_console_test.rb17
-rw-r--r--qpid/cpp/examples/messaging/drain.cpp7
-rw-r--r--qpid/cpp/examples/messaging/map_receiver.cpp1
-rw-r--r--qpid/cpp/examples/messaging/map_sender.cpp1
-rw-r--r--qpid/cpp/examples/messaging/server.cpp1
-rw-r--r--qpid/cpp/examples/messaging/spout.cpp9
-rw-r--r--qpid/cpp/examples/messaging/topic_receiver.cpp1
-rw-r--r--qpid/cpp/include/qpid/client/amqp0_10/Codecs.h8
-rw-r--r--qpid/cpp/include/qpid/management/ManagementEvent.h2
-rw-r--r--qpid/cpp/include/qpid/management/ManagementObject.h25
-rw-r--r--qpid/cpp/include/qpid/messaging/Address.h12
-rw-r--r--qpid/cpp/include/qpid/messaging/Codec.h8
-rw-r--r--qpid/cpp/include/qpid/messaging/Connection.h6
-rw-r--r--qpid/cpp/include/qpid/messaging/Duration.h23
-rw-r--r--qpid/cpp/include/qpid/messaging/ListContent.h32
-rw-r--r--qpid/cpp/include/qpid/messaging/ListView.h12
-rw-r--r--qpid/cpp/include/qpid/messaging/MapContent.h22
-rw-r--r--qpid/cpp/include/qpid/messaging/MapView.h12
-rw-r--r--qpid/cpp/include/qpid/messaging/Message.h12
-rw-r--r--qpid/cpp/include/qpid/messaging/Receiver.h8
-rw-r--r--qpid/cpp/include/qpid/messaging/Session.h4
-rw-r--r--qpid/cpp/include/qpid/messaging/Uuid.h94
-rw-r--r--qpid/cpp/include/qpid/messaging/Variant.h174
-rw-r--r--qpid/cpp/include/qpid/types/Uuid.h94
-rw-r--r--qpid/cpp/include/qpid/types/Variant.h174
-rw-r--r--qpid/cpp/managementgen/qmfgen/management-types.xml14
-rwxr-xr-xqpid/cpp/managementgen/qmfgen/schema.py38
-rw-r--r--qpid/cpp/managementgen/qmfgen/templates/Class.cpp9
-rw-r--r--qpid/cpp/managementgen/qmfgen/templates/Class.h8
-rw-r--r--qpid/cpp/managementgen/qmfgen/templates/Event.cpp5
-rw-r--r--qpid/cpp/managementgen/qmfgen/templates/Event.h2
-rw-r--r--qpid/cpp/src/CMakeLists.txt5
-rw-r--r--qpid/cpp/src/Makefile.am9
-rw-r--r--qpid/cpp/src/qmf/engine/ValueImpl.cpp167
-rw-r--r--qpid/cpp/src/qmf/engine/ValueImpl.h13
-rw-r--r--qpid/cpp/src/qpid/acl/Acl.cpp6
-rw-r--r--qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp32
-rw-r--r--qpid/cpp/src/qpid/agent/ManagementAgentImpl.h10
-rw-r--r--qpid/cpp/src/qpid/broker/System.cpp4
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp8
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.h1
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/Codecs.cpp7
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/CodecsInternal.h6
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp5
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h8
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/FailoverUpdates.cpp2
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp14
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp9
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp3
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h1
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/SenderImpl.h1
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp6
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.h1
-rw-r--r--qpid/cpp/src/qpid/cluster/Cluster.cpp4
-rw-r--r--qpid/cpp/src/qpid/cluster/ClusterTimer.cpp1
-rw-r--r--qpid/cpp/src/qpid/management/ManagementAgent.cpp167
-rw-r--r--qpid/cpp/src/qpid/management/ManagementAgent.h30
-rw-r--r--qpid/cpp/src/qpid/management/ManagementObject.cpp22
-rw-r--r--qpid/cpp/src/qpid/messaging/Address.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/AddressParser.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/AddressParser.h20
-rw-r--r--qpid/cpp/src/qpid/messaging/Connection.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/ConnectionImpl.h8
-rw-r--r--qpid/cpp/src/qpid/messaging/Duration.cpp45
-rw-r--r--qpid/cpp/src/qpid/messaging/ListContent.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/ListView.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/MapContent.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/MapView.cpp2
-rw-r--r--qpid/cpp/src/qpid/messaging/Message.cpp16
-rw-r--r--qpid/cpp/src/qpid/messaging/MessageImpl.cpp4
-rw-r--r--qpid/cpp/src/qpid/messaging/MessageImpl.h9
-rw-r--r--qpid/cpp/src/qpid/types/Uuid.cpp (renamed from qpid/cpp/src/qpid/messaging/Uuid.cpp)6
-rw-r--r--qpid/cpp/src/qpid/types/Variant.cpp (renamed from qpid/cpp/src/qpid/messaging/Variant.cpp)6
-rw-r--r--qpid/cpp/src/tests/Address.cpp3
-rw-r--r--qpid/cpp/src/tests/ClientMessage.cpp4
-rw-r--r--qpid/cpp/src/tests/ManagementTest.cpp2
-rw-r--r--qpid/cpp/src/tests/MessagingSessionTests.cpp41
-rw-r--r--qpid/cpp/src/tests/Uuid.cpp16
-rw-r--r--qpid/cpp/src/tests/Variant.cpp4
-rw-r--r--qpid/cpp/src/tests/qpid_recv.cpp13
-rw-r--r--qpid/cpp/src/tests/qpid_send.cpp11
-rw-r--r--qpid/cpp/src/tests/qpid_stream.cpp5
-rw-r--r--qpid/extras/qmf/LICENSE.txt203
-rw-r--r--qpid/extras/qmf/NOTICE.txt20
-rw-r--r--qpid/extras/qmf/src/py/qmf/console.py59
-rw-r--r--qpid/java/broker/build.xml2
-rw-r--r--qpid/java/broker/etc/config.xml142
-rw-r--r--qpid/java/broker/etc/persistent_config.xml121
-rw-r--r--qpid/java/broker/etc/transient_config.xml118
-rw-r--r--qpid/java/broker/etc/virtualhosts.xml161
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java116
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java653
-rw-r--r--qpid/java/client/test/example_build.xml2
-rw-r--r--qpid/java/common.xml2
-rw-r--r--qpid/java/module.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml18
-rw-r--r--qpid/java/systests/etc/config-systests-acl-settings.xml136
-rw-r--r--qpid/java/systests/etc/config-systests-acl.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-derby-settings.xml40
-rw-r--r--qpid/java/systests/etc/config-systests-derby.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-2.xml28
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-3.xml28
-rw-r--r--qpid/java/systests/etc/config-systests-firewall-settings.xml2
-rw-r--r--qpid/java/systests/etc/config-systests-firewall.xml5
-rw-r--r--qpid/java/systests/etc/config-systests-settings.xml1
-rw-r--r--qpid/java/systests/etc/config-systests.xml2
-rw-r--r--qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml7
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml156
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-acl.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml54
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-derby.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml47
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml49
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests-firewall.xml29
-rw-r--r--qpid/java/systests/etc/virtualhosts-systests.xml28
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java2
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java19
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java28
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java47
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java100
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java300
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java92
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java139
-rw-r--r--qpid/java/test-profiles/Excludes2
-rw-r--r--qpid/java/test-profiles/JavaExcludes3
-rw-r--r--qpid/java/test-profiles/log4j-test.xml4
-rw-r--r--qpid/python/qpid/messaging/endpoints.py30
-rw-r--r--qpid/tests/LICENSE.txt203
-rw-r--r--qpid/tests/NOTICE.txt20
-rw-r--r--qpid/tools/LICENSE.txt203
-rw-r--r--qpid/tools/NOTICE.txt20
136 files changed, 3623 insertions, 1575 deletions
diff --git a/qpid/cpp/bindings/qmf/python/qmf.py b/qpid/cpp/bindings/qmf/python/qmf.py
index e4ab581dfd..5dc1330cdb 100644
--- a/qpid/cpp/bindings/qmf/python/qmf.py
+++ b/qpid/cpp/bindings/qmf/python/qmf.py
@@ -58,10 +58,9 @@ def qmf_to_native(val):
elif typecode == TYPE_INT32: return val.asInt()
elif typecode == TYPE_INT64: return val.asInt64()
elif typecode == TYPE_MAP: return value_to_dict(val)
+ elif typecode == TYPE_LIST: return value_to_list(val)
else:
# when TYPE_OBJECT
- # when TYPE_LIST
- # when TYPE_ARRAY
logging.error( "Unsupported type for get_attr? '%s'" % str(val.getType()) )
return None
@@ -98,11 +97,9 @@ def native_to_qmf(target, value):
elif typecode == TYPE_INT32: val.setInt(value)
elif typecode == TYPE_INT64: val.setInt64(value)
elif typecode == TYPE_MAP: dict_to_value(val, value)
+ elif typecode == TYPE_LIST: list_to_value(val, value)
else:
- # when TYPE_MAP
# when TYPE_OBJECT
- # when TYPE_LIST
- # when TYPE_ARRAY
logging.error("Unsupported type for get_attr? '%s'" % str(val.getType()))
return None
return val
@@ -129,6 +126,7 @@ def pick_qmf_type(value):
if value.__class__ == bool: return TYPE_BOOL
if value == None: return TYPE_BOOL
if value.__class__ == dict: return TYPE_MAP
+ if value.__class__ == list: return TYPE_LIST
raise "QMF type not known for native type %s" % value.__class__
@@ -140,7 +138,7 @@ def value_to_dict(val):
key = val.key(i)
mymap[key] = qmf_to_native(val.byKey(key))
return mymap
-
+
def dict_to_value(val, mymap):
for key, value in mymap.items():
@@ -149,6 +147,26 @@ def dict_to_value(val, mymap):
val.insert(key, native_to_qmf(typecode, value))
+def value_to_list(val):
+ mylist = []
+ if val.isList():
+ for i in range(val.listItemCount()):
+ mylist.append(qmf_to_native(val.listItem(i)))
+ return mylist
+ #if val.isArray():
+ # for i in range(val.arrayItemCount()):
+ # mylist.append(qmf_to_native(val.arrayItem(i)))
+ # return mylist
+
+ raise "value_to_list must be given a list value"
+
+
+def list_to_value(val, mylist):
+ for item in mylist:
+ typecode = pick_qmf_type(item)
+ val.appendToList(native_to_qmf(typecode, item))
+
+
##==============================================================================
## CONNECTION
##==============================================================================
diff --git a/qpid/cpp/bindings/qmf/ruby/qmf.rb b/qpid/cpp/bindings/qmf/ruby/qmf.rb
index ce824b3605..823cf9bf93 100644
--- a/qpid/cpp/bindings/qmf/ruby/qmf.rb
+++ b/qpid/cpp/bindings/qmf/ruby/qmf.rb
@@ -48,8 +48,8 @@ module Qmf
when TYPE_INT8, TYPE_INT16, TYPE_INT32 then val.asInt
when TYPE_INT64 then val.asInt64
when TYPE_MAP then value_to_dict(val)
+ when TYPE_LIST then value_to_list(val)
when TYPE_OBJECT
- when TYPE_LIST
when TYPE_ARRAY
end
end
@@ -77,8 +77,8 @@ module Qmf
when TYPE_INT8, TYPE_INT16, TYPE_INT32 then val.setInt(value)
when TYPE_INT64 then val.setInt64(value)
when TYPE_MAP then dict_to_value(val, value)
+ when TYPE_LIST then list_to_value(val, value)
when TYPE_OBJECT
- when TYPE_LIST
when TYPE_ARRAY
end
return val
@@ -112,6 +112,7 @@ module Qmf
return TYPE_BOOL if value.class == NilClass
return TYPE_MAP if value.class == Hash
+ return TYPE_LIST if value.class == Array
raise ArgumentError, "QMF type not known for native type #{value.class}"
end
@@ -134,6 +135,23 @@ module Qmf
val.insert(key, native_to_qmf(typecode, value))
end
end
+
+ def value_to_list(val)
+ # Assume val is of type Qmfengine::Value
+ raise ArgumentError, "value_to_dict must be given a map value" if !val.isList
+ list = []
+ for i in 0...val.listItemCount
+ list.push(qmf_to_native(val.listItem(i)))
+ end
+ return list
+ end
+
+ def list_to_value(val, list)
+ list.each do |value|
+ typecode = pick_qmf_type(value)
+ val.appendToList(native_to_qmf(typecode, value))
+ end
+ end
end
$util = Util.new
diff --git a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
index 86eefc59a6..92065031a2 100755
--- a/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
+++ b/qpid/cpp/bindings/qmf/tests/agent_ruby.rb
@@ -44,6 +44,7 @@ class Model
@parent_class.add_property(Qmf::SchemaProperty.new("lstrval", Qmf::TYPE_LSTR))
@parent_class.add_property(Qmf::SchemaProperty.new("mapval", Qmf::TYPE_MAP))
+ @parent_class.add_property(Qmf::SchemaProperty.new("listval", Qmf::TYPE_LIST))
@parent_class.add_statistic(Qmf::SchemaStatistic.new("queryCount", Qmf::TYPE_UINT32, :unit => "query", :desc => "Query count"))
@@ -246,6 +247,11 @@ class App < Qmf::AgentHandler
@parent.int16val = 0
@parent.int8val = 0
+ # a list containing a list that contains a map (so there!)
+ @parent.listval = ['a', 1, 'b', 2,
+ ['c', true, 3.1415,
+ {"hi" => 10, "lo" => 5}]]
+
@parent_oid = @agent.alloc_object_id(1)
@parent.set_object_id(@parent_oid)
diff --git a/qpid/cpp/bindings/qmf/tests/python_agent.py b/qpid/cpp/bindings/qmf/tests/python_agent.py
index 83531830b1..4974e0ec90 100644
--- a/qpid/cpp/bindings/qmf/tests/python_agent.py
+++ b/qpid/cpp/bindings/qmf/tests/python_agent.py
@@ -45,6 +45,7 @@ class Model:
self.parent_class.add_property(qmf.SchemaProperty("lstrval", qmf.TYPE_LSTR))
self.parent_class.add_property(qmf.SchemaProperty("mapval", qmf.TYPE_MAP))
+ self.parent_class.add_property(qmf.SchemaProperty("listval", qmf.TYPE_LIST))
self.parent_class.add_statistic(qmf.SchemaStatistic("queryCount", qmf.TYPE_UINT32, {"unit":"query", "desc":"Query count"}))
@@ -274,7 +275,7 @@ class App(qmf.AgentHandler):
## @todo how do we force a test failure?
# verify the properties() and statistics() object methods:
- assert len(self._parent.properties()) == 13
+ assert len(self._parent.properties()) == 14
assert len(self._parent.statistics()) == 1
self._parent.set_attr("name", "Parent One")
@@ -290,6 +291,11 @@ class App(qmf.AgentHandler):
self._parent.set_attr("int16val", 0)
self._parent.set_attr("int8val", 0)
+ # a list containing a list that contains a map (so there!)
+ self._parent.set_attr("listval", ['a', 1, 'b', 2,
+ ['c', True, 3.1415,
+ {"hi": 10, "lo": 5}]])
+
self._parent_oid = self._agent.alloc_object_id(1)
self._parent.set_object_id(self._parent_oid)
diff --git a/qpid/cpp/bindings/qmf/tests/python_console.py b/qpid/cpp/bindings/qmf/tests/python_console.py
index fe27c33c4b..883aa8da1a 100755
--- a/qpid/cpp/bindings/qmf/tests/python_console.py
+++ b/qpid/cpp/bindings/qmf/tests/python_console.py
@@ -48,7 +48,7 @@ class QmfInteropTests(TestBase010):
self.assertEqual(len(parents), 1)
parent = parents[0]
for seq in range(10):
- result = parent.echo(seq)
+ result = parent.echo(seq, _timeout=5)
self.assertEqual(result.status, 0)
self.assertEqual(result.text, "OK")
self.assertEqual(result.sequence, seq)
@@ -202,7 +202,26 @@ class QmfInteropTests(TestBase010):
self.assertEqual(queue[3].arguments["strval"], "TEST")
self.assertEqual(queue[4].arguments["uint32val"], 0)
self.assertEqual(queue[4].arguments["strval"], "LONG_TEST")
-
+
+
+ def test_G_basic_map_list_data(self):
+ self.startQmf();
+ qmf = self.qmf
+
+ parents = qmf.getObjects(_class="parent")
+ self.assertEqual(len(parents), 1)
+ parent = parents[0]
+
+ # see agent for structure of listval
+
+ self.assertTrue(isinstance(parent.listval, list))
+ self.assertEqual(len(parent.listval), 5)
+ self.assertTrue(isinstance(parent.listval[4], list))
+ self.assertEqual(len(parent.listval[4]), 4)
+ self.assertTrue(isinstance(parent.listval[4][3], dict))
+ self.assertEqual(parent.listval[4][3]["hi"], 10)
+ self.assertEqual(parent.listval[4][3]["lo"], 5)
+
def getProperty(self, msg, name):
for h in msg.headers:
diff --git a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
index 3a771aaafd..9ef0ef57a8 100755
--- a/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
+++ b/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
@@ -266,6 +266,23 @@ class ConsoleTest < ConsoleTestBase
end
end
+
+
+ def test_G_basic_map_list_data
+ parent = @qmfc.object(:class => "parent")
+ assert(parent, "Number of 'parent' objects")
+
+ # see agent for structure of listval
+
+ assert(parent.listval.class == Array)
+ assert_equal(parent.listval.length, 5)
+ assert(parent.listval[4].class == Array)
+ assert_equal(parent.listval[4].length, 4)
+ assert(parent.listval[4][3].class == Hash)
+ assert_equal(parent.listval[4][3]["hi"], 10)
+ assert_equal(parent.listval[4][3]["lo"], 5)
+ end
+
end
app = ConsoleTest.new
diff --git a/qpid/cpp/examples/messaging/drain.cpp b/qpid/cpp/examples/messaging/drain.cpp
index 38f6bdbb98..a2fa0f1138 100644
--- a/qpid/cpp/examples/messaging/drain.cpp
+++ b/qpid/cpp/examples/messaging/drain.cpp
@@ -32,6 +32,7 @@
#include <iostream>
using namespace qpid::messaging;
+using namespace qpid::types;
struct Options : public qpid::Options
{
@@ -63,8 +64,8 @@ struct Options : public qpid::Options
Duration getTimeout()
{
- if (forever) return INFINITE_DURATION;
- else return timeout*DURATION_SEC;
+ if (forever) return Duration::FOREVER;
+ else return timeout*Duration::SECOND;
}
bool parse(int argc, char** argv)
@@ -101,7 +102,7 @@ int main(int argc, char** argv)
Duration timeout = options.getTimeout();
Message message;
while (receiver.fetch(message, timeout)) {
- std::cout << "Message(properties=" << message.getHeaders() << ", content='" ;
+ std::cout << "Message(properties=" << message.getProperties() << ", content='" ;
if (message.getContentType() == "amqp/map") {
std::cout << MapView(message);
} else {
diff --git a/qpid/cpp/examples/messaging/map_receiver.cpp b/qpid/cpp/examples/messaging/map_receiver.cpp
index cdbae6007e..cdbb931299 100644
--- a/qpid/cpp/examples/messaging/map_receiver.cpp
+++ b/qpid/cpp/examples/messaging/map_receiver.cpp
@@ -31,6 +31,7 @@
#include <sstream>
using namespace qpid::messaging;
+using namespace qpid::types;
using std::stringstream;
using std::string;
diff --git a/qpid/cpp/examples/messaging/map_sender.cpp b/qpid/cpp/examples/messaging/map_sender.cpp
index 037bb55201..dec918e836 100644
--- a/qpid/cpp/examples/messaging/map_sender.cpp
+++ b/qpid/cpp/examples/messaging/map_sender.cpp
@@ -31,6 +31,7 @@
#include <sstream>
using namespace qpid::messaging;
+using namespace qpid::types;
using std::stringstream;
using std::string;
diff --git a/qpid/cpp/examples/messaging/server.cpp b/qpid/cpp/examples/messaging/server.cpp
index 046a209e2f..837e5b7103 100644
--- a/qpid/cpp/examples/messaging/server.cpp
+++ b/qpid/cpp/examples/messaging/server.cpp
@@ -25,7 +25,6 @@
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Session.h>
-#include <qpid/messaging/Variant.h>
#include <algorithm>
#include <cstdlib>
diff --git a/qpid/cpp/examples/messaging/spout.cpp b/qpid/cpp/examples/messaging/spout.cpp
index 4819c6bc00..4b67945317 100644
--- a/qpid/cpp/examples/messaging/spout.cpp
+++ b/qpid/cpp/examples/messaging/spout.cpp
@@ -25,7 +25,7 @@
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Session.h>
-#include <qpid/messaging/Variant.h>
+#include <qpid/types/Variant.h>
#include <qpid/Exception.h>
#include <qpid/Options.h>
#include <qpid/log/Logger.h>
@@ -38,6 +38,7 @@
#include <boost/format.hpp>
using namespace qpid::messaging;
+using namespace qpid::types;
using qpid::sys::AbsTime;
using qpid::sys::now;
using qpid::sys::TIME_INFINITE;
@@ -124,9 +125,9 @@ struct Options : public qpid::Options
std::string name;
std::string value;
if (nameval(property, name, value)) {
- message.getHeaders()[name] = value;
+ message.getProperties()[name] = value;
} else {
- message.getHeaders()[name] = Variant();
+ message.getProperties()[name] = Variant();
}
}
@@ -176,7 +177,7 @@ int main(int argc, char** argv)
for (uint count = 0; (count < options.count || options.count == 0) && end > now(); count++) {
if (!options.replyto.empty()) message.setReplyTo(Address(options.replyto));
std::string id = options.id.empty() ? Uuid(true).str() : options.id;
- message.getHeaders()["spout-id"] = (boost::format("%1%:%2%") % id % count).str();
+ message.getProperties()["spout-id"] = (boost::format("%1%:%2%") % id % count).str();
sender.send(message);
}
connection.close();
diff --git a/qpid/cpp/examples/messaging/topic_receiver.cpp b/qpid/cpp/examples/messaging/topic_receiver.cpp
index 9e0264a4c3..54a7e82dfc 100644
--- a/qpid/cpp/examples/messaging/topic_receiver.cpp
+++ b/qpid/cpp/examples/messaging/topic_receiver.cpp
@@ -23,7 +23,6 @@
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Session.h>
-#include <qpid/messaging/Variant.h>
#include <cstdlib>
#include <iostream>
diff --git a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h
index 5ef0b9fffe..097cf5877f 100644
--- a/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h
+++ b/qpid/cpp/include/qpid/client/amqp0_10/Codecs.h
@@ -35,8 +35,8 @@ namespace amqp0_10 {
class MapCodec : public qpid::messaging::Codec
{
public:
- void encode(const qpid::messaging::Variant&, std::string&);
- void decode(const std::string&, qpid::messaging::Variant&);
+ void encode(const qpid::types::Variant&, std::string&);
+ void decode(const std::string&, qpid::types::Variant&);
static const std::string contentType;
private:
@@ -49,8 +49,8 @@ class MapCodec : public qpid::messaging::Codec
class ListCodec : public qpid::messaging::Codec
{
public:
- void encode(const qpid::messaging::Variant&, std::string&);
- void decode(const std::string&, qpid::messaging::Variant&);
+ void encode(const qpid::types::Variant&, std::string&);
+ void decode(const std::string&, qpid::types::Variant&);
static const std::string contentType;
private:
diff --git a/qpid/cpp/include/qpid/management/ManagementEvent.h b/qpid/cpp/include/qpid/management/ManagementEvent.h
index b809001b1b..8aa88ba57a 100644
--- a/qpid/cpp/include/qpid/management/ManagementEvent.h
+++ b/qpid/cpp/include/qpid/management/ManagementEvent.h
@@ -46,7 +46,7 @@ class ManagementEvent : public ManagementItem {
virtual uint8_t* getMd5Sum() const = 0;
virtual uint8_t getSeverity() const = 0;
virtual void encode(std::string&) const = 0;
- virtual void mapEncode(qpid::messaging::VariantMap&) const = 0;
+ virtual void mapEncode(qpid::types::VariantMap&) const = 0;
};
}}
diff --git a/qpid/cpp/include/qpid/management/ManagementObject.h b/qpid/cpp/include/qpid/management/ManagementObject.h
index 07d039b6e3..3cfa0d4a19 100644
--- a/qpid/cpp/include/qpid/management/ManagementObject.h
+++ b/qpid/cpp/include/qpid/management/ManagementObject.h
@@ -25,6 +25,7 @@
#include "qpid/sys/Time.h"
#include "qpid/sys/Mutex.h"
#include "qpid/CommonImportExport.h"
+#include "qpid/types/Variant.h"
#include "qpid/messaging/MapContent.h"
#include "qpid/messaging/MapView.h"
#include <map>
@@ -60,7 +61,7 @@ protected:
void fromString(const std::string&);
public:
QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {}
- QPID_COMMON_EXTERN ObjectId(const messaging::Variant& map) :
+ QPID_COMMON_EXTERN ObjectId(const types::Variant& map) :
agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); }
QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker);
QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq);
@@ -70,9 +71,9 @@ public:
QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker, uint64_t object);
QPID_COMMON_EXTERN bool operator==(const ObjectId &other) const;
QPID_COMMON_EXTERN bool operator<(const ObjectId &other) const;
- QPID_COMMON_EXTERN void mapEncode(messaging::VariantMap& map) const;
- QPID_COMMON_EXTERN void mapDecode(const messaging::VariantMap& map);
- QPID_COMMON_EXTERN operator messaging::VariantMap() const;
+ QPID_COMMON_EXTERN void mapEncode(types::VariantMap& map) const;
+ QPID_COMMON_EXTERN void mapDecode(const types::VariantMap& map);
+ QPID_COMMON_EXTERN operator types::VariantMap() const;
QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; };
QPID_COMMON_EXTERN void encode(std::string& buffer) const;
QPID_COMMON_EXTERN void decode(const std::string& buffer);
@@ -148,9 +149,9 @@ protected:
QPID_COMMON_EXTERN int getThreadIndex();
QPID_COMMON_EXTERN void writeTimestamps(std::string& buf) const;
- QPID_COMMON_EXTERN void writeTimestamps(messaging::VariantMap& map) const;
+ QPID_COMMON_EXTERN void writeTimestamps(types::VariantMap& map) const;
QPID_COMMON_EXTERN void readTimestamps(const std::string& buf);
- QPID_COMMON_EXTERN void readTimestamps(const messaging::VariantMap& buf);
+ QPID_COMMON_EXTERN void readTimestamps(const types::VariantMap& buf);
QPID_COMMON_EXTERN uint32_t writeTimestampsSize() const;
public:
@@ -171,13 +172,13 @@ protected:
// Encode & Decode the property and statistics values
// for this object.
- virtual void mapEncodeValues(messaging::VariantMap& map,
+ virtual void mapEncodeValues(types::VariantMap& map,
bool includeProperties,
bool includeStatistics) = 0;
- virtual void mapDecodeValues(const messaging::VariantMap& map) = 0;
+ virtual void mapDecodeValues(const types::VariantMap& map) = 0;
virtual void doMethod(std::string& methodName,
- const messaging::VariantMap& inMap,
- messaging::VariantMap& outMap) = 0;
+ const types::VariantMap& inMap,
+ types::VariantMap& outMap) = 0;
/**
* The following five methods are not pure-virtual because they will only
@@ -224,11 +225,11 @@ protected:
//QPID_COMMON_EXTERN uint32_t encodedSize() const { return writePropertiesSize(); }
// Encode/Decode the entire object as a map
- QPID_COMMON_EXTERN void mapEncode(messaging::VariantMap& map,
+ QPID_COMMON_EXTERN void mapEncode(types::VariantMap& map,
bool includeProperties=true,
bool includeStatistics=true);
- QPID_COMMON_EXTERN void mapDecode(const messaging::VariantMap& map);
+ QPID_COMMON_EXTERN void mapDecode(const types::VariantMap& map);
};
typedef std::map<ObjectId, ManagementObject*> ManagementObjectMap;
diff --git a/qpid/cpp/include/qpid/messaging/Address.h b/qpid/cpp/include/qpid/messaging/Address.h
index fd790a613c..307e0cfa8d 100644
--- a/qpid/cpp/include/qpid/messaging/Address.h
+++ b/qpid/cpp/include/qpid/messaging/Address.h
@@ -23,7 +23,7 @@
*/
#include <string>
#include "qpid/Exception.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/messaging/ImportExport.h"
#include <ostream>
@@ -124,7 +124,7 @@ class Address
QPID_CLIENT_EXTERN Address();
QPID_CLIENT_EXTERN Address(const std::string& address);
QPID_CLIENT_EXTERN Address(const std::string& name, const std::string& subject,
- const Variant::Map& options, const std::string& type = "");
+ const qpid::types::Variant::Map& options, const std::string& type = "");
QPID_CLIENT_EXTERN Address(const Address& address);
QPID_CLIENT_EXTERN ~Address();
QPID_CLIENT_EXTERN Address& operator=(const Address&);
@@ -133,14 +133,14 @@ class Address
QPID_CLIENT_EXTERN const std::string& getSubject() const;
QPID_CLIENT_EXTERN void setSubject(const std::string&);
QPID_CLIENT_EXTERN bool hasSubject() const;
- QPID_CLIENT_EXTERN const Variant::Map& getOptions() const;
- QPID_CLIENT_EXTERN Variant::Map& getOptions();
- QPID_CLIENT_EXTERN void setOptions(const Variant::Map&);
+ QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getOptions() const;
+ QPID_CLIENT_EXTERN qpid::types::Variant::Map& getOptions();
+ QPID_CLIENT_EXTERN void setOptions(const qpid::types::Variant::Map&);
QPID_CLIENT_EXTERN std::string getType() const;
QPID_CLIENT_EXTERN void setType(const std::string&);
- QPID_CLIENT_EXTERN const Variant& getOption(const std::string& key) const;
+ QPID_CLIENT_EXTERN const qpid::types::Variant& getOption(const std::string& key) const;
QPID_CLIENT_EXTERN std::string toStr() const;
QPID_CLIENT_EXTERN operator bool() const;
diff --git a/qpid/cpp/include/qpid/messaging/Codec.h b/qpid/cpp/include/qpid/messaging/Codec.h
index b9b1cc862a..a69baa5af1 100644
--- a/qpid/cpp/include/qpid/messaging/Codec.h
+++ b/qpid/cpp/include/qpid/messaging/Codec.h
@@ -25,9 +25,11 @@
#include "qpid/messaging/ImportExport.h"
namespace qpid {
+namespace types{
+class Variant;
+}
namespace messaging {
-class Variant;
/**
*
*/
@@ -35,8 +37,8 @@ class Codec
{
public:
QPID_CLIENT_EXTERN virtual ~Codec() {}
- virtual void encode(const Variant&, std::string&) = 0;
- virtual void decode(const std::string&, Variant&) = 0;
+ virtual void encode(const qpid::types::Variant&, std::string&) = 0;
+ virtual void decode(const std::string&, qpid::types::Variant&) = 0;
private:
};
}} // namespace qpid::messaging
diff --git a/qpid/cpp/include/qpid/messaging/Connection.h b/qpid/cpp/include/qpid/messaging/Connection.h
index b5eeeb2980..24fb9650d8 100644
--- a/qpid/cpp/include/qpid/messaging/Connection.h
+++ b/qpid/cpp/include/qpid/messaging/Connection.h
@@ -24,7 +24,7 @@
#include <string>
#include "qpid/messaging/ImportExport.h"
#include "qpid/messaging/Handle.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
namespace qpid {
namespace messaging {
@@ -74,11 +74,11 @@ class Connection : public qpid::messaging::Handle<ConnectionImpl>
* doubled every failure until the value of max-retry-interval
* is reached.
*/
- QPID_CLIENT_EXTERN Connection(const Variant::Map& options = Variant::Map());
+ QPID_CLIENT_EXTERN Connection(const qpid::types::Variant::Map& options = qpid::types::Variant::Map());
QPID_CLIENT_EXTERN Connection(const std::string& options);
QPID_CLIENT_EXTERN ~Connection();
QPID_CLIENT_EXTERN Connection& operator=(const Connection&);
- QPID_CLIENT_EXTERN void setOption(const std::string& name, const Variant& value);
+ QPID_CLIENT_EXTERN void setOption(const std::string& name, const qpid::types::Variant& value);
QPID_CLIENT_EXTERN void open(const std::string& url);
/**
* Closes a connection and all sessions associated with it. An
diff --git a/qpid/cpp/include/qpid/messaging/Duration.h b/qpid/cpp/include/qpid/messaging/Duration.h
index 5f95acf04d..fdd1cf4a50 100644
--- a/qpid/cpp/include/qpid/messaging/Duration.h
+++ b/qpid/cpp/include/qpid/messaging/Duration.h
@@ -21,8 +21,9 @@
* under the License.
*
*/
+
+#include "qpid/client/ClientImportExport.h"
#include "qpid/sys/IntegerTypes.h"
-#include <limits>
namespace qpid {
namespace messaging {
@@ -30,9 +31,23 @@ namespace messaging {
/**
* A duration is a time in milliseconds.
*/
-typedef uint64_t Duration;
-const Duration INFINITE_DURATION = std::numeric_limits<uint64_t>::max();
-const Duration DURATION_SEC = 1000;
+class Duration
+{
+ public:
+ QPID_CLIENT_EXTERN explicit Duration(uint64_t milliseconds);
+ QPID_CLIENT_EXTERN uint64_t getMilliseconds() const;
+ QPID_CLIENT_EXTERN static const Duration FOREVER;
+ QPID_CLIENT_EXTERN static const Duration IMMEDIATE;
+ QPID_CLIENT_EXTERN static const Duration SECOND;
+ QPID_CLIENT_EXTERN static const Duration MINUTE;
+ private:
+ uint64_t milliseconds;
+};
+
+QPID_CLIENT_EXTERN Duration operator*(const Duration& duration,
+ uint64_t multiplier);
+QPID_CLIENT_EXTERN Duration operator*(uint64_t multiplier,
+ const Duration& duration);
}} // namespace qpid::messaging
diff --git a/qpid/cpp/include/qpid/messaging/ListContent.h b/qpid/cpp/include/qpid/messaging/ListContent.h
index 3db8a8eac6..1e7d34af54 100644
--- a/qpid/cpp/include/qpid/messaging/ListContent.h
+++ b/qpid/cpp/include/qpid/messaging/ListContent.h
@@ -22,7 +22,7 @@
*
*/
#include "qpid/messaging/ImportExport.h"
-#include "Variant.h"
+#include "qpid/types/Variant.h"
namespace qpid {
namespace messaging {
@@ -36,13 +36,13 @@ class Message;
class ListContent
{
public:
- typedef Variant::List::iterator iterator;
- typedef Variant::List::reverse_iterator reverse_iterator;
- typedef Variant::List::const_iterator const_iterator;
- typedef Variant::List::const_reverse_iterator const_reverse_iterator;
+ typedef qpid::types::Variant::List::iterator iterator;
+ typedef qpid::types::Variant::List::reverse_iterator reverse_iterator;
+ typedef qpid::types::Variant::List::const_iterator const_iterator;
+ typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator;
QPID_CLIENT_EXTERN ListContent(Message&);
- QPID_CLIENT_EXTERN ListContent(Message&, const Variant::List&);
+ QPID_CLIENT_EXTERN ListContent(Message&, const qpid::types::Variant::List&);
QPID_CLIENT_EXTERN ~ListContent();
QPID_CLIENT_EXTERN const_iterator begin() const;
@@ -57,27 +57,27 @@ class ListContent
QPID_CLIENT_EXTERN bool empty() const;
QPID_CLIENT_EXTERN size_t size() const;
- QPID_CLIENT_EXTERN const Variant& front() const;
- QPID_CLIENT_EXTERN Variant& front();
- QPID_CLIENT_EXTERN const Variant& back() const;
- QPID_CLIENT_EXTERN Variant& back();
+ QPID_CLIENT_EXTERN const qpid::types::Variant& front() const;
+ QPID_CLIENT_EXTERN qpid::types::Variant& front();
+ QPID_CLIENT_EXTERN const qpid::types::Variant& back() const;
+ QPID_CLIENT_EXTERN qpid::types::Variant& back();
- QPID_CLIENT_EXTERN void push_front(const Variant&);
- QPID_CLIENT_EXTERN void push_back(const Variant&);
+ QPID_CLIENT_EXTERN void push_front(const qpid::types::Variant&);
+ QPID_CLIENT_EXTERN void push_back(const qpid::types::Variant&);
QPID_CLIENT_EXTERN void pop_front();
QPID_CLIENT_EXTERN void pop_back();
- QPID_CLIENT_EXTERN iterator insert(iterator position, const Variant&);
- QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const Variant&);
+ QPID_CLIENT_EXTERN iterator insert(iterator position, const qpid::types::Variant&);
+ QPID_CLIENT_EXTERN void insert(iterator position, size_t n, const qpid::types::Variant&);
QPID_CLIENT_EXTERN iterator erase(iterator position);
QPID_CLIENT_EXTERN iterator erase(iterator first, iterator last);
QPID_CLIENT_EXTERN void clear();
QPID_CLIENT_EXTERN void encode();
- QPID_CLIENT_EXTERN const Variant::List& asList() const;
- QPID_CLIENT_EXTERN Variant::List& asList();
+ QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const;
+ QPID_CLIENT_EXTERN qpid::types::Variant::List& asList();
private:
ListContentImpl* impl;
diff --git a/qpid/cpp/include/qpid/messaging/ListView.h b/qpid/cpp/include/qpid/messaging/ListView.h
index d7c3536a9c..dce82a657c 100644
--- a/qpid/cpp/include/qpid/messaging/ListView.h
+++ b/qpid/cpp/include/qpid/messaging/ListView.h
@@ -23,7 +23,7 @@
*/
#include "qpid/messaging/ImportExport.h"
-#include "Variant.h"
+#include "qpid/types/Variant.h"
namespace qpid {
namespace messaging {
@@ -37,8 +37,8 @@ class Message;
class ListView
{
public:
- typedef Variant::List::const_iterator const_iterator;
- typedef Variant::List::const_reverse_iterator const_reverse_iterator;
+ typedef qpid::types::Variant::List::const_iterator const_iterator;
+ typedef qpid::types::Variant::List::const_reverse_iterator const_reverse_iterator;
QPID_CLIENT_EXTERN ListView(const Message&);
QPID_CLIENT_EXTERN ~ListView();
@@ -52,10 +52,10 @@ class ListView
QPID_CLIENT_EXTERN bool empty() const;
QPID_CLIENT_EXTERN size_t size() const;
- QPID_CLIENT_EXTERN const Variant& front() const;
- QPID_CLIENT_EXTERN const Variant& back() const;
+ QPID_CLIENT_EXTERN const qpid::types::Variant& front() const;
+ QPID_CLIENT_EXTERN const qpid::types::Variant& back() const;
- QPID_CLIENT_EXTERN const Variant::List& asList() const;
+ QPID_CLIENT_EXTERN const qpid::types::Variant::List& asList() const;
private:
ListViewImpl* impl;
};
diff --git a/qpid/cpp/include/qpid/messaging/MapContent.h b/qpid/cpp/include/qpid/messaging/MapContent.h
index 78ef51e593..863eaed786 100644
--- a/qpid/cpp/include/qpid/messaging/MapContent.h
+++ b/qpid/cpp/include/qpid/messaging/MapContent.h
@@ -23,7 +23,7 @@
*/
#include "qpid/messaging/ImportExport.h"
-#include "Variant.h"
+#include "qpid/types/Variant.h"
#include <map>
#include <string>
@@ -40,14 +40,14 @@ class MapContent
{
public:
typedef std::string key_type;
- typedef std::pair<std::string, Variant> value_type;
- typedef std::map<key_type, Variant>::const_iterator const_iterator;
- typedef std::map<key_type, Variant>::iterator iterator;
- typedef std::map<key_type, Variant>::const_reverse_iterator const_reverse_iterator;
- typedef std::map<key_type, Variant>::reverse_iterator reverse_iterator;
+ typedef std::pair<std::string, qpid::types::Variant> value_type;
+ typedef std::map<key_type, qpid::types::Variant>::const_iterator const_iterator;
+ typedef std::map<key_type, qpid::types::Variant>::iterator iterator;
+ typedef std::map<key_type, qpid::types::Variant>::const_reverse_iterator const_reverse_iterator;
+ typedef std::map<key_type, qpid::types::Variant>::reverse_iterator reverse_iterator;
QPID_CLIENT_EXTERN MapContent(Message&);
- QPID_CLIENT_EXTERN MapContent(Message&, const Variant::Map&);
+ QPID_CLIENT_EXTERN MapContent(Message&, const qpid::types::Variant::Map&);
QPID_CLIENT_EXTERN ~MapContent();
QPID_CLIENT_EXTERN const_iterator begin() const;
@@ -64,8 +64,8 @@ class MapContent
QPID_CLIENT_EXTERN const_iterator find(const key_type&) const;
QPID_CLIENT_EXTERN iterator find(const key_type&);
- QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const;
- QPID_CLIENT_EXTERN Variant& operator[](const key_type&);
+ QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const;
+ QPID_CLIENT_EXTERN qpid::types::Variant& operator[](const key_type&);
QPID_CLIENT_EXTERN std::pair<iterator,bool> insert(const value_type&);
QPID_CLIENT_EXTERN iterator insert(iterator position, const value_type&);
@@ -76,8 +76,8 @@ class MapContent
QPID_CLIENT_EXTERN void encode();
- QPID_CLIENT_EXTERN const std::map<key_type, Variant>& asMap() const;
- QPID_CLIENT_EXTERN std::map<key_type, Variant>& asMap();
+ QPID_CLIENT_EXTERN const std::map<key_type, qpid::types::Variant>& asMap() const;
+ QPID_CLIENT_EXTERN std::map<key_type, qpid::types::Variant>& asMap();
private:
MapContentImpl* impl;
diff --git a/qpid/cpp/include/qpid/messaging/MapView.h b/qpid/cpp/include/qpid/messaging/MapView.h
index baa999b4ad..e359a9d929 100644
--- a/qpid/cpp/include/qpid/messaging/MapView.h
+++ b/qpid/cpp/include/qpid/messaging/MapView.h
@@ -22,7 +22,7 @@
*
*/
#include "qpid/messaging/ImportExport.h"
-#include "Variant.h"
+#include "qpid/types/Variant.h"
#include <map>
#include <string>
@@ -39,9 +39,9 @@ class MapView
{
public:
typedef std::string key_type;
- typedef std::pair<key_type, Variant> value_type;
- typedef std::map<key_type, Variant>::const_iterator const_iterator;
- typedef std::map<key_type, Variant>::const_reverse_iterator const_reverse_iterator;
+ typedef std::pair<key_type, qpid::types::Variant> value_type;
+ typedef std::map<key_type, qpid::types::Variant>::const_iterator const_iterator;
+ typedef std::map<key_type, qpid::types::Variant>::const_reverse_iterator const_reverse_iterator;
QPID_CLIENT_EXTERN MapView(const Message&);
QPID_CLIENT_EXTERN ~MapView();
@@ -56,9 +56,9 @@ class MapView
QPID_CLIENT_EXTERN size_t size() const;
QPID_CLIENT_EXTERN const_iterator find(const key_type&) const;
- QPID_CLIENT_EXTERN const Variant& operator[](const key_type&) const;
+ QPID_CLIENT_EXTERN const qpid::types::Variant& operator[](const key_type&) const;
- QPID_CLIENT_EXTERN const std::map<key_type, Variant>& asMap() const;
+ QPID_CLIENT_EXTERN const std::map<key_type, qpid::types::Variant>& asMap() const;
private:
MapViewImpl* impl;
};
diff --git a/qpid/cpp/include/qpid/messaging/Message.h b/qpid/cpp/include/qpid/messaging/Message.h
index 21404d482b..d7b2622d08 100644
--- a/qpid/cpp/include/qpid/messaging/Message.h
+++ b/qpid/cpp/include/qpid/messaging/Message.h
@@ -24,7 +24,7 @@
#include <string>
#include "qpid/messaging/Duration.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/messaging/ImportExport.h"
namespace qpid {
@@ -65,6 +65,9 @@ class Message
QPID_CLIENT_EXTERN void setCorrelationId(const std::string&);
QPID_CLIENT_EXTERN const std::string& getCorrelationId() const;
+ QPID_CLIENT_EXTERN void setPriority(uint8_t);
+ QPID_CLIENT_EXTERN uint8_t getPriority() const;
+
/**
* Set the time to live for this message in milliseconds.
*/
@@ -77,10 +80,11 @@ class Message
QPID_CLIENT_EXTERN void setDurable(bool durable);
QPID_CLIENT_EXTERN bool getDurable() const;
- QPID_CLIENT_EXTERN bool isRedelivered() const;
+ QPID_CLIENT_EXTERN bool getRedelivered() const;
+ QPID_CLIENT_EXTERN void setRedelivered(bool);
- QPID_CLIENT_EXTERN const Variant::Map& getHeaders() const;
- QPID_CLIENT_EXTERN Variant::Map& getHeaders();
+ QPID_CLIENT_EXTERN const qpid::types::Variant::Map& getProperties() const;
+ QPID_CLIENT_EXTERN qpid::types::Variant::Map& getProperties();
QPID_CLIENT_EXTERN const std::string& getContent() const;
QPID_CLIENT_EXTERN std::string& getContent();
diff --git a/qpid/cpp/include/qpid/messaging/Receiver.h b/qpid/cpp/include/qpid/messaging/Receiver.h
index 80b58106d7..48b0b78754 100644
--- a/qpid/cpp/include/qpid/messaging/Receiver.h
+++ b/qpid/cpp/include/qpid/messaging/Receiver.h
@@ -53,7 +53,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl>
* available. Returns false if there is no message to give after
* waiting for the specified timeout.
*/
- QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::FOREVER);
/**
* Retrieves a message from this receivers local queue, or waits
* for up to the specified timeout for a message to become
@@ -62,7 +62,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl>
*@exception NoMessageAvailable if there is no message to give
* after waiting for the specified timeout.
*/
- QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::FOREVER);
/**
* Retrieves a message for this receivers subscription or waits
* for up to the specified timeout for one to become
@@ -70,7 +70,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl>
* that there is no message for the subscription this receiver is
* serving before returning false.
*/
- QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::FOREVER);
/**
* Retrieves a message for this receivers subscription or waits
* for up to the specified timeout for one to become
@@ -81,7 +81,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl>
*@exception NoMessageAvailable if there is no message to give
* after waiting for the specified timeout.
*/
- QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::FOREVER);
/**
* Sets the capacity for the receiver. The capacity determines how
* many incoming messages can be held in the receiver before being
diff --git a/qpid/cpp/include/qpid/messaging/Session.h b/qpid/cpp/include/qpid/messaging/Session.h
index 032b678c5c..eaecb69260 100644
--- a/qpid/cpp/include/qpid/messaging/Session.h
+++ b/qpid/cpp/include/qpid/messaging/Session.h
@@ -102,7 +102,7 @@ class Session : public qpid::messaging::Handle<SessionImpl>
* which case the passed in receiver reference will be set to the
* receiver for that message or false if no message was available.
*/
- QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::FOREVER);
/**
* Returns the receiver for the next available message. If there
* are no available messages at present the call will block for up
@@ -111,7 +111,7 @@ class Session : public qpid::messaging::Handle<SessionImpl>
*@exception Receiver::NoMessageAvailable if no message became available in
* time.
*/
- QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION);
+ QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::FOREVER);
/**
* Create a new sender through which messages can be sent to the
diff --git a/qpid/cpp/include/qpid/messaging/Uuid.h b/qpid/cpp/include/qpid/messaging/Uuid.h
deleted file mode 100644
index d83f8495b7..0000000000
--- a/qpid/cpp/include/qpid/messaging/Uuid.h
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef QPID_MESSAGING_UUID_H
-#define QPID_MESSAGING_UUID_H
-
-/*
- *
- * 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.
- *
- */
-
-#include "qpid/messaging/ImportExport.h"
-#include <iosfwd>
-#include <string>
-
-namespace qpid {
-namespace messaging {
-
-class Uuid
-{
- public:
- static const size_t SIZE;
- /**
- * If unique is true, this will generate a new unique uuid, if not
- * it will construct a null uuid.
- */
- QPID_CLIENT_EXTERN Uuid(bool unique=false);
- QPID_CLIENT_EXTERN Uuid(const Uuid&);
- QPID_CLIENT_EXTERN Uuid& operator=(const Uuid&);
- /** Copy the UUID from data16, which must point to a 16-byte UUID */
- QPID_CLIENT_EXTERN Uuid(const unsigned char* data16);
-
- /** Set to a new unique identifier. */
- QPID_CLIENT_EXTERN void generate();
-
- /** Set to all zeros. */
- QPID_CLIENT_EXTERN void clear();
-
- /** Test for null (all zeros). */
- QPID_CLIENT_EXTERN bool isNull() const;
- QPID_CLIENT_EXTERN operator bool() const;
- QPID_CLIENT_EXTERN bool operator!() const;
-
- /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
- QPID_CLIENT_EXTERN std::string str() const;
-
- QPID_CLIENT_EXTERN size_t size() const;
- QPID_CLIENT_EXTERN const unsigned char* data() const;
-
- friend QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&);
- friend QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
- friend QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&);
-
- private:
- unsigned char bytes[16];
-};
-
-/** Returns true if the uuids are equal, false otherwise. **/
-QPID_CLIENT_EXTERN bool operator==(const Uuid&, const Uuid&);
-/** Returns true if the uuids are NOT equal, false if they are. **/
-QPID_CLIENT_EXTERN bool operator!=(const Uuid&, const Uuid&);
-
-QPID_CLIENT_EXTERN bool operator<(const Uuid&, const Uuid&);
-QPID_CLIENT_EXTERN bool operator>(const Uuid&, const Uuid&);
-QPID_CLIENT_EXTERN bool operator<=(const Uuid&, const Uuid&);
-QPID_CLIENT_EXTERN bool operator>=(const Uuid&, const Uuid&);
-
-/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
-QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
-
-/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
-QPID_CLIENT_EXTERN std::istream& operator>>(std::istream&, Uuid&);
-
-}} // namespace qpid::messaging
-
-#endif /*!QPID_MESSAGING_UUID_H*/
diff --git a/qpid/cpp/include/qpid/messaging/Variant.h b/qpid/cpp/include/qpid/messaging/Variant.h
deleted file mode 100644
index 51c6bd98fe..0000000000
--- a/qpid/cpp/include/qpid/messaging/Variant.h
+++ /dev/null
@@ -1,174 +0,0 @@
-#ifndef QPID_MESSAGING_VARIANT_H
-#define QPID_MESSAGING_VARIANT_H
-
-/*
- *
- * 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.
- *
- */
-#include <list>
-#include <map>
-#include <ostream>
-#include <string>
-#include "Uuid.h"
-#include "qpid/Exception.h"
-#include "qpid/sys/IntegerTypes.h"
-#include "qpid/messaging/ImportExport.h"
-
-namespace qpid {
-namespace messaging {
-
-/**
- * Thrown when an illegal conversion of a variant is attempted.
- */
-struct InvalidConversion : public qpid::Exception
-{
- InvalidConversion(const std::string& msg);
-};
-
-enum VariantType {
- VAR_VOID = 0,
- VAR_BOOL,
- VAR_UINT8,
- VAR_UINT16,
- VAR_UINT32,
- VAR_UINT64,
- VAR_INT8,
- VAR_INT16,
- VAR_INT32,
- VAR_INT64,
- VAR_FLOAT,
- VAR_DOUBLE,
- VAR_STRING,
- VAR_MAP,
- VAR_LIST,
- VAR_UUID
-};
-
-class VariantImpl;
-
-/**
- * Represents a value of variable type.
- */
-class Variant
-{
- public:
- typedef std::map<std::string, Variant> Map;
- typedef std::list<Variant> List;
-
- QPID_CLIENT_EXTERN Variant();
- QPID_CLIENT_EXTERN Variant(bool);
- QPID_CLIENT_EXTERN Variant(uint8_t);
- QPID_CLIENT_EXTERN Variant(uint16_t);
- QPID_CLIENT_EXTERN Variant(uint32_t);
- QPID_CLIENT_EXTERN Variant(uint64_t);
- QPID_CLIENT_EXTERN Variant(int8_t);
- QPID_CLIENT_EXTERN Variant(int16_t);
- QPID_CLIENT_EXTERN Variant(int32_t);
- QPID_CLIENT_EXTERN Variant(int64_t);
- QPID_CLIENT_EXTERN Variant(float);
- QPID_CLIENT_EXTERN Variant(double);
- QPID_CLIENT_EXTERN Variant(const std::string&);
- QPID_CLIENT_EXTERN Variant(const char*);
- QPID_CLIENT_EXTERN Variant(const Map&);
- QPID_CLIENT_EXTERN Variant(const List&);
- QPID_CLIENT_EXTERN Variant(const Variant&);
- QPID_CLIENT_EXTERN Variant(const Uuid&);
-
- QPID_CLIENT_EXTERN ~Variant();
-
- QPID_CLIENT_EXTERN VariantType getType() const;
- QPID_CLIENT_EXTERN bool isVoid() const;
-
- QPID_CLIENT_EXTERN Variant& operator=(bool);
- QPID_CLIENT_EXTERN Variant& operator=(uint8_t);
- QPID_CLIENT_EXTERN Variant& operator=(uint16_t);
- QPID_CLIENT_EXTERN Variant& operator=(uint32_t);
- QPID_CLIENT_EXTERN Variant& operator=(uint64_t);
- QPID_CLIENT_EXTERN Variant& operator=(int8_t);
- QPID_CLIENT_EXTERN Variant& operator=(int16_t);
- QPID_CLIENT_EXTERN Variant& operator=(int32_t);
- QPID_CLIENT_EXTERN Variant& operator=(int64_t);
- QPID_CLIENT_EXTERN Variant& operator=(float);
- QPID_CLIENT_EXTERN Variant& operator=(double);
- QPID_CLIENT_EXTERN Variant& operator=(const std::string&);
- QPID_CLIENT_EXTERN Variant& operator=(const char*);
- QPID_CLIENT_EXTERN Variant& operator=(const Map&);
- QPID_CLIENT_EXTERN Variant& operator=(const List&);
- QPID_CLIENT_EXTERN Variant& operator=(const Variant&);
- QPID_CLIENT_EXTERN Variant& operator=(const Uuid&);
-
- QPID_CLIENT_EXTERN bool asBool() const;
- QPID_CLIENT_EXTERN uint8_t asUint8() const;
- QPID_CLIENT_EXTERN uint16_t asUint16() const;
- QPID_CLIENT_EXTERN uint32_t asUint32() const;
- QPID_CLIENT_EXTERN uint64_t asUint64() const;
- QPID_CLIENT_EXTERN int8_t asInt8() const;
- QPID_CLIENT_EXTERN int16_t asInt16() const;
- QPID_CLIENT_EXTERN int32_t asInt32() const;
- QPID_CLIENT_EXTERN int64_t asInt64() const;
- QPID_CLIENT_EXTERN float asFloat() const;
- QPID_CLIENT_EXTERN double asDouble() const;
- QPID_CLIENT_EXTERN std::string asString() const;
- QPID_CLIENT_EXTERN Uuid asUuid() const;
-
- QPID_CLIENT_EXTERN operator bool() const;
- QPID_CLIENT_EXTERN operator uint8_t() const;
- QPID_CLIENT_EXTERN operator uint16_t() const;
- QPID_CLIENT_EXTERN operator uint32_t() const;
- QPID_CLIENT_EXTERN operator uint64_t() const;
- QPID_CLIENT_EXTERN operator int8_t() const;
- QPID_CLIENT_EXTERN operator int16_t() const;
- QPID_CLIENT_EXTERN operator int32_t() const;
- QPID_CLIENT_EXTERN operator int64_t() const;
- QPID_CLIENT_EXTERN operator float() const;
- QPID_CLIENT_EXTERN operator double() const;
- QPID_CLIENT_EXTERN operator const char*() const;
- QPID_CLIENT_EXTERN operator Uuid() const;
-
- QPID_CLIENT_EXTERN const Map& asMap() const;
- QPID_CLIENT_EXTERN Map& asMap();
- QPID_CLIENT_EXTERN const List& asList() const;
- QPID_CLIENT_EXTERN List& asList();
- /**
- * Unlike asString(), getString() will not do any conversions and
- * will throw InvalidConversion if the type is not STRING.
- */
- QPID_CLIENT_EXTERN const std::string& getString() const;
- QPID_CLIENT_EXTERN std::string& getString();
-
- QPID_CLIENT_EXTERN void setEncoding(const std::string&);
- QPID_CLIENT_EXTERN const std::string& getEncoding() const;
-
- QPID_CLIENT_EXTERN bool isEqualTo(const Variant& a) const;
-
- QPID_CLIENT_EXTERN void reset();
- private:
- VariantImpl* impl;
-};
-
-QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value);
-QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map);
-QPID_CLIENT_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list);
-QPID_CLIENT_EXTERN bool operator==(const Variant& a, const Variant& b);
-
-typedef Variant::Map VariantMap;
-
-}} // namespace qpid::messaging
-
-#endif /*!QPID_MESSAGING_VARIANT_H*/
diff --git a/qpid/cpp/include/qpid/types/Uuid.h b/qpid/cpp/include/qpid/types/Uuid.h
new file mode 100644
index 0000000000..41042a0731
--- /dev/null
+++ b/qpid/cpp/include/qpid/types/Uuid.h
@@ -0,0 +1,94 @@
+#ifndef QPID_TYPES_UUID_H
+#define QPID_TYPES_UUID_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "qpid/CommonImportExport.h"
+#include <iosfwd>
+#include <string>
+
+namespace qpid {
+namespace types {
+
+class Uuid
+{
+ public:
+ static const size_t SIZE;
+ /**
+ * If unique is true, this will generate a new unique uuid, if not
+ * it will construct a null uuid.
+ */
+ QPID_COMMON_EXTERN Uuid(bool unique=false);
+ QPID_COMMON_EXTERN Uuid(const Uuid&);
+ QPID_COMMON_EXTERN Uuid& operator=(const Uuid&);
+ /** Copy the UUID from data16, which must point to a 16-byte UUID */
+ QPID_COMMON_EXTERN Uuid(const unsigned char* data16);
+
+ /** Set to a new unique identifier. */
+ QPID_COMMON_EXTERN void generate();
+
+ /** Set to all zeros. */
+ QPID_COMMON_EXTERN void clear();
+
+ /** Test for null (all zeros). */
+ QPID_COMMON_EXTERN bool isNull() const;
+ QPID_COMMON_EXTERN operator bool() const;
+ QPID_COMMON_EXTERN bool operator!() const;
+
+ /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
+ QPID_COMMON_EXTERN std::string str() const;
+
+ QPID_COMMON_EXTERN size_t size() const;
+ QPID_COMMON_EXTERN const unsigned char* data() const;
+
+ friend QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&);
+ friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
+ friend QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&);
+
+ private:
+ unsigned char bytes[16];
+};
+
+/** Returns true if the uuids are equal, false otherwise. **/
+QPID_COMMON_EXTERN bool operator==(const Uuid&, const Uuid&);
+/** Returns true if the uuids are NOT equal, false if they are. **/
+QPID_COMMON_EXTERN bool operator!=(const Uuid&, const Uuid&);
+
+QPID_COMMON_EXTERN bool operator<(const Uuid&, const Uuid&);
+QPID_COMMON_EXTERN bool operator>(const Uuid&, const Uuid&);
+QPID_COMMON_EXTERN bool operator<=(const Uuid&, const Uuid&);
+QPID_COMMON_EXTERN bool operator>=(const Uuid&, const Uuid&);
+
+/** Print in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
+QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, Uuid);
+
+/** Read from format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */
+QPID_COMMON_EXTERN std::istream& operator>>(std::istream&, Uuid&);
+
+}} // namespace qpid::types
+
+#endif /*!QPID_TYPES_UUID_H*/
diff --git a/qpid/cpp/include/qpid/types/Variant.h b/qpid/cpp/include/qpid/types/Variant.h
new file mode 100644
index 0000000000..f57adcd31e
--- /dev/null
+++ b/qpid/cpp/include/qpid/types/Variant.h
@@ -0,0 +1,174 @@
+#ifndef QPID_TYPES_VARIANT_H
+#define QPID_TYPES_VARIANT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include <list>
+#include <map>
+#include <ostream>
+#include <string>
+#include "Uuid.h"
+#include "qpid/Exception.h"
+#include "qpid/sys/IntegerTypes.h"
+#include "qpid/CommonImportExport.h"
+
+namespace qpid {
+namespace types {
+
+/**
+ * Thrown when an illegal conversion of a variant is attempted.
+ */
+struct InvalidConversion : public qpid::Exception
+{
+ InvalidConversion(const std::string& msg);
+};
+
+enum VariantType {
+ VAR_VOID = 0,
+ VAR_BOOL,
+ VAR_UINT8,
+ VAR_UINT16,
+ VAR_UINT32,
+ VAR_UINT64,
+ VAR_INT8,
+ VAR_INT16,
+ VAR_INT32,
+ VAR_INT64,
+ VAR_FLOAT,
+ VAR_DOUBLE,
+ VAR_STRING,
+ VAR_MAP,
+ VAR_LIST,
+ VAR_UUID
+};
+
+class VariantImpl;
+
+/**
+ * Represents a value of variable type.
+ */
+class Variant
+{
+ public:
+ typedef std::map<std::string, Variant> Map;
+ typedef std::list<Variant> List;
+
+ QPID_COMMON_EXTERN Variant();
+ QPID_COMMON_EXTERN Variant(bool);
+ QPID_COMMON_EXTERN Variant(uint8_t);
+ QPID_COMMON_EXTERN Variant(uint16_t);
+ QPID_COMMON_EXTERN Variant(uint32_t);
+ QPID_COMMON_EXTERN Variant(uint64_t);
+ QPID_COMMON_EXTERN Variant(int8_t);
+ QPID_COMMON_EXTERN Variant(int16_t);
+ QPID_COMMON_EXTERN Variant(int32_t);
+ QPID_COMMON_EXTERN Variant(int64_t);
+ QPID_COMMON_EXTERN Variant(float);
+ QPID_COMMON_EXTERN Variant(double);
+ QPID_COMMON_EXTERN Variant(const std::string&);
+ QPID_COMMON_EXTERN Variant(const char*);
+ QPID_COMMON_EXTERN Variant(const Map&);
+ QPID_COMMON_EXTERN Variant(const List&);
+ QPID_COMMON_EXTERN Variant(const Variant&);
+ QPID_COMMON_EXTERN Variant(const Uuid&);
+
+ QPID_COMMON_EXTERN ~Variant();
+
+ QPID_COMMON_EXTERN VariantType getType() const;
+ QPID_COMMON_EXTERN bool isVoid() const;
+
+ QPID_COMMON_EXTERN Variant& operator=(bool);
+ QPID_COMMON_EXTERN Variant& operator=(uint8_t);
+ QPID_COMMON_EXTERN Variant& operator=(uint16_t);
+ QPID_COMMON_EXTERN Variant& operator=(uint32_t);
+ QPID_COMMON_EXTERN Variant& operator=(uint64_t);
+ QPID_COMMON_EXTERN Variant& operator=(int8_t);
+ QPID_COMMON_EXTERN Variant& operator=(int16_t);
+ QPID_COMMON_EXTERN Variant& operator=(int32_t);
+ QPID_COMMON_EXTERN Variant& operator=(int64_t);
+ QPID_COMMON_EXTERN Variant& operator=(float);
+ QPID_COMMON_EXTERN Variant& operator=(double);
+ QPID_COMMON_EXTERN Variant& operator=(const std::string&);
+ QPID_COMMON_EXTERN Variant& operator=(const char*);
+ QPID_COMMON_EXTERN Variant& operator=(const Map&);
+ QPID_COMMON_EXTERN Variant& operator=(const List&);
+ QPID_COMMON_EXTERN Variant& operator=(const Variant&);
+ QPID_COMMON_EXTERN Variant& operator=(const Uuid&);
+
+ QPID_COMMON_EXTERN bool asBool() const;
+ QPID_COMMON_EXTERN uint8_t asUint8() const;
+ QPID_COMMON_EXTERN uint16_t asUint16() const;
+ QPID_COMMON_EXTERN uint32_t asUint32() const;
+ QPID_COMMON_EXTERN uint64_t asUint64() const;
+ QPID_COMMON_EXTERN int8_t asInt8() const;
+ QPID_COMMON_EXTERN int16_t asInt16() const;
+ QPID_COMMON_EXTERN int32_t asInt32() const;
+ QPID_COMMON_EXTERN int64_t asInt64() const;
+ QPID_COMMON_EXTERN float asFloat() const;
+ QPID_COMMON_EXTERN double asDouble() const;
+ QPID_COMMON_EXTERN std::string asString() const;
+ QPID_COMMON_EXTERN Uuid asUuid() const;
+
+ QPID_COMMON_EXTERN operator bool() const;
+ QPID_COMMON_EXTERN operator uint8_t() const;
+ QPID_COMMON_EXTERN operator uint16_t() const;
+ QPID_COMMON_EXTERN operator uint32_t() const;
+ QPID_COMMON_EXTERN operator uint64_t() const;
+ QPID_COMMON_EXTERN operator int8_t() const;
+ QPID_COMMON_EXTERN operator int16_t() const;
+ QPID_COMMON_EXTERN operator int32_t() const;
+ QPID_COMMON_EXTERN operator int64_t() const;
+ QPID_COMMON_EXTERN operator float() const;
+ QPID_COMMON_EXTERN operator double() const;
+ QPID_COMMON_EXTERN operator const char*() const;
+ QPID_COMMON_EXTERN operator Uuid() const;
+
+ QPID_COMMON_EXTERN const Map& asMap() const;
+ QPID_COMMON_EXTERN Map& asMap();
+ QPID_COMMON_EXTERN const List& asList() const;
+ QPID_COMMON_EXTERN List& asList();
+ /**
+ * Unlike asString(), getString() will not do any conversions and
+ * will throw InvalidConversion if the type is not STRING.
+ */
+ QPID_COMMON_EXTERN const std::string& getString() const;
+ QPID_COMMON_EXTERN std::string& getString();
+
+ QPID_COMMON_EXTERN void setEncoding(const std::string&);
+ QPID_COMMON_EXTERN const std::string& getEncoding() const;
+
+ QPID_COMMON_EXTERN bool isEqualTo(const Variant& a) const;
+
+ QPID_COMMON_EXTERN void reset();
+ private:
+ VariantImpl* impl;
+};
+
+QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant& value);
+QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::Map& map);
+QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Variant::List& list);
+QPID_COMMON_EXTERN bool operator==(const Variant& a, const Variant& b);
+
+typedef Variant::Map VariantMap;
+
+}} // namespace qpid::types
+
+#endif /*!QPID_TYPES_VARIANT_H*/
diff --git a/qpid/cpp/managementgen/qmfgen/management-types.xml b/qpid/cpp/managementgen/qmfgen/management-types.xml
index 865492c47c..226dfb5849 100644
--- a/qpid/cpp/managementgen/qmfgen/management-types.xml
+++ b/qpid/cpp/managementgen/qmfgen/management-types.xml
@@ -42,19 +42,19 @@ stream="#.getV2Key()" size="16" accessor="direct" init="::qpid::management::Obje
<type name="deltaTime" base="DELTATIME" cpp="uint64_t" encode="@.putLongLong(#)" decode="# = @.getLongLong()" stream="#" size="8" accessor="direct" init="0"/>
<type name="float" base="FLOAT" cpp="float" encode="@.putFloat(#)" decode="# = @.getFloat()" stream="#" size="4" accessor="direct" init="0."/>
<type name="double" base="DOUBLE" cpp="double" encode="@.putDouble(#)" decode="# = @.getDouble()" stream="#" size="8" accessor="direct" init="0."/>
-<type name="uuid" base="UUID" cpp="::qpid::messaging::Uuid"
+<type name="uuid" base="UUID" cpp="::qpid::types::Uuid"
encode="{::qpid::framing::Uuid _u(#.data()); _u.encode(@); }"
- decode="{::qpid::framing::Uuid _u; _u.decode(@); # = ::qpid::messaging::Uuid(_u.data());}"
- stream="#" size="16" accessor="direct" init="::qpid::messaging::Uuid()" byRef="y" unmap="(#).asUuid().data()" map="::qpid::messaging::Uuid((#).data())" />
-<type name="map" base="FTABLE" cpp="::qpid::messaging::VariantMap"
+ decode="{::qpid::framing::Uuid _u; _u.decode(@); # = ::qpid::types::Uuid(_u.data());}"
+ stream="#" size="16" accessor="direct" init="::qpid::types::Uuid()" byRef="y" unmap="(#).asUuid().data()" map="::qpid::types::Uuid((#).data())" />
+<type name="map" base="FTABLE" cpp="::qpid::types::VariantMap"
encode="{::qpid::framing::FieldTable _f = ManagementAgent::fromMap(#); _f.encode(@);}"
decode="{::qpid::framing::FieldTable _f; _f.decode(@); # = ManagementAgent::toMap(_f);}"
size="::qpid::framing::FieldTable(ManagementAgent::fromMap(#)).encodedSize()"
-stream="#" accessor="direct" init="::qpid::messaging::VariantMap()" byRef="y" unmap="::qpid::messaging::VariantMap(); assert(false); /*TBD*/"/>
-<type name="list" base="LIST" cpp="::qpid::messaging::Variant::List"
+stream="#" accessor="direct" init="::qpid::types::VariantMap()" byRef="y" unmap="::qpid::types::VariantMap(); assert(false); /*TBD*/"/>
+<type name="list" base="LIST" cpp="::qpid::types::Variant::List"
encode="{::qpid::framing::List _l = ManagementAgent::fromList(#); _l.encode(@);}"
decode="{::qpid::framing::List _l; _l.decode(@); # = ManagementAgent::toList(_l);}"
-stream="#" size="#.encodedSize()" accessor="direct" init="::qpid::messaging::Variant::List()" byRef="y" unmap="::qpid::messaging::Variant::List(); assert(false); /*TBD*/"/>
+stream="#" size="#.encodedSize()" accessor="direct" init="::qpid::types::Variant::List()" byRef="y" unmap="::qpid::types::Variant::List(); assert(false); /*TBD*/"/>
<type name="hilo8" base="U8" cpp="uint8_t" encode="@.putOctet(#)" decode="# = @.getOctet()" style="wm" stream="#" size="1" accessor="counter" init="0"/>
<type name="hilo16" base="U16" cpp="uint16_t" encode="@.putShort(#)" decode="# = @.getShort()" style="wm" stream="#" size="2" accessor="counter" init="0"/>
diff --git a/qpid/cpp/managementgen/qmfgen/schema.py b/qpid/cpp/managementgen/qmfgen/schema.py
index 27216db8e1..3ec9fe3adc 100755
--- a/qpid/cpp/managementgen/qmfgen/schema.py
+++ b/qpid/cpp/managementgen/qmfgen/schema.py
@@ -260,26 +260,26 @@ class SchemaType:
key = varName
if self.style != "mma":
var_cast = self.map.replace("#", varName)
- stream.write(indent + mapName + "[\"" + key + "\"] = Variant(" + var_cast + ");\n")
+ stream.write(indent + mapName + "[\"" + key + "\"] = ::qpid::types::Variant(" + var_cast + ");\n")
if self.style == "wm":
var_cast_hi = self.map.replace("#", varName + "High")
var_cast_lo = self.map.replace("#", varName + "Low")
stream.write(indent + mapName + "[\"" + key + "High\"] = " +
- "Variant(" + var_cast_hi + ");\n")
+ "::qpid::types::Variant(" + var_cast_hi + ");\n")
stream.write(indent + mapName + "[\"" + key + "Low\"] = " +
- "Variant(" + var_cast_lo + ");\n")
+ "::qpid::types::Variant(" + var_cast_lo + ");\n")
if self.style == "mma":
var_cast = self.map.replace("#", varName + "Count")
- stream.write(indent + mapName + "[\"" + key + "Count\"] = " + "Variant(" + var_cast + ");\n")
+ stream.write(indent + mapName + "[\"" + key + "Count\"] = " + "::qpid::types::Variant(" + var_cast + ");\n")
var_cast = self.map.replace("#", varName + "Min")
stream.write(indent + mapName + "[\"" + key + "Min\"] = " +
- "(" + varName + "Count ? Variant(" + var_cast + ") : Variant(0));\n")
+ "(" + varName + "Count ? ::qpid::types::Variant(" + var_cast + ") : ::qpid::types::Variant(0));\n")
var_cast = self.map.replace("#", varName + "Max")
- stream.write(indent + mapName + "[\"" + key + "Max\"] = " + "Variant(" + var_cast + ");\n")
+ stream.write(indent + mapName + "[\"" + key + "Max\"] = " + "::qpid::types::Variant(" + var_cast + ");\n")
var_cast = self.map.replace("#", "(" + varName + "Total / " + varName + "Count)")
stream.write(indent + mapName + "[\"" + key + "Avg\"] = " +
- "(" + varName + "Count ? Variant(" + var_cast + ") : Variant(0));\n")
+ "(" + varName + "Count ? ::qpid::types::Variant(" + var_cast + ") : ::qpid::types::Variant(0));\n")
def getReadCode (self, varName, bufName):
result = self.decode.replace ("@", bufName).replace ("#", varName)
@@ -445,7 +445,7 @@ class SchemaProperty:
def genSchemaMap(self, stream):
stream.write (" {\n")
- stream.write (" ::qpid::messaging::VariantMap _value;\n")
+ stream.write (" ::qpid::types::VariantMap _value;\n")
stream.write (" _value[TYPE] = TYPE_" + self.type.type.base +";\n")
stream.write (" _value[ACCESS] = ACCESS_" + self.access + ";\n")
stream.write (" _value[IS_INDEX] = " + str (self.isIndex) + ";\n")
@@ -604,7 +604,7 @@ class SchemaStatistic:
def genSchemaTextMap(self, stream, name, desc):
stream.write (" {\n")
- stream.write (" ::qpid::messaging::VariantMap _value;\n")
+ stream.write (" ::qpid::types::VariantMap _value;\n")
stream.write (" _value[TYPE] = TYPE_" + self.type.type.base +";\n")
if self.unit != None:
stream.write (" _value[UNIT] = \"" + self.unit + "\";\n")
@@ -803,7 +803,7 @@ class SchemaArg:
def genSchemaMap (self, stream, event=False):
stream.write (" {\n")
- stream.write (" ::qpid::messaging::VariantMap _avalue;\n")
+ stream.write (" ::qpid::types::VariantMap _avalue;\n")
stream.write (" _avalue[TYPE] = TYPE_" + self.type.type.base +";\n")
if (not event):
stream.write (" _avalue[DIR] = \"" + self.dir + "\";\n")
@@ -906,8 +906,8 @@ class SchemaMethod:
def genSchemaMap (self, stream, variables):
stream.write (" {\n")
- stream.write (" ::qpid::messaging::VariantMap _value;\n")
- stream.write (" ::qpid::messaging::VariantMap _args;\n")
+ stream.write (" ::qpid::types::VariantMap _value;\n")
+ stream.write (" ::qpid::types::VariantMap _args;\n")
stream.write (" _value[ARGCOUNT] = " + str(len(self.args)) + ";\n")
if self.desc != None:
stream.write (" _value[DESC] = \"" + self.desc + "\";\n")
@@ -1247,17 +1247,17 @@ class SchemaClass:
if methodCount == 0:
stream.write ("string&," +
- " const ::qpid::messaging::VariantMap&," +
- " ::qpid::messaging::VariantMap& outMap")
+ " const ::qpid::types::VariantMap&," +
+ " ::qpid::types::VariantMap& outMap")
else:
if inArgCount == 0:
stream.write ("string& methodName," +
- " const ::qpid::messaging::VariantMap&," +
- " ::qpid::messaging::VariantMap& outMap")
+ " const ::qpid::types::VariantMap&," +
+ " ::qpid::types::VariantMap& outMap")
else:
stream.write ("string& methodName," +
- " const ::qpid::messaging::VariantMap& inMap," +
- " ::qpid::messaging::VariantMap& outMap")
+ " const ::qpid::types::VariantMap& inMap," +
+ " ::qpid::types::VariantMap& outMap")
def genHiLoStatResets (self, stream, variables):
for inst in self.statistics:
@@ -1389,7 +1389,7 @@ class SchemaClass:
stream.write (" ::qpid::management::ArgsNone ioArgs;\n")
else:
stream.write (" Args" + method.getFullName () + " ioArgs;\n")
- stream.write (" ::qpid::messaging::VariantMap::const_iterator _i;\n")
+ stream.write (" ::qpid::types::VariantMap::const_iterator _i;\n")
# decode each input argument from the input map
for arg in method.args:
diff --git a/qpid/cpp/managementgen/qmfgen/templates/Class.cpp b/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
index 62b10446dd..4ba902072a 100644
--- a/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
+++ b/qpid/cpp/managementgen/qmfgen/templates/Class.cpp
@@ -30,7 +30,6 @@
#include <iostream>
using namespace qmf::/*MGEN:Class.Namespace*/;
-using namespace qpid::messaging;
using qpid::management::ManagementAgent;
using qpid::management::Manageable;
using qpid::management::ManagementObject;
@@ -274,11 +273,11 @@ std::string /*MGEN:Class.NameCap*/::getKey() const
-void /*MGEN:Class.NameCap*/::mapEncodeValues (::qpid::messaging::VariantMap& _map,
+void /*MGEN:Class.NameCap*/::mapEncodeValues (::qpid::types::VariantMap& _map,
bool includeProperties,
bool includeStatistics)
{
- using namespace ::qpid::messaging;
+ using namespace ::qpid::types;
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
if (includeProperties) {
@@ -317,9 +316,9 @@ void /*MGEN:Class.NameCap*/::mapEncodeValues (::qpid::messaging::VariantMap& _ma
}
}
-void /*MGEN:Class.NameCap*/::mapDecodeValues (const ::qpid::messaging::VariantMap& _map)
+void /*MGEN:Class.NameCap*/::mapDecodeValues (const ::qpid::types::VariantMap& _map)
{
- ::qpid::messaging::VariantMap::const_iterator _i;
+ ::qpid::types::VariantMap::const_iterator _i;
::qpid::sys::Mutex::ScopedLock mutex(accessLock);
/*MGEN:IF(Class.ExistOptionals)*/
bool _found;
diff --git a/qpid/cpp/managementgen/qmfgen/templates/Class.h b/qpid/cpp/managementgen/qmfgen/templates/Class.h
index 81e33a01f9..5f9cf72e6b 100644
--- a/qpid/cpp/managementgen/qmfgen/templates/Class.h
+++ b/qpid/cpp/managementgen/qmfgen/templates/Class.h
@@ -75,13 +75,13 @@ class /*MGEN:Class.NameCap*/ : public ::qpid::management::ManagementObject
/*MGEN:ENDIF*/
public:
static void writeSchema(std::string& schema);
- void mapEncodeValues(::qpid::messaging::VariantMap& map,
+ void mapEncodeValues(::qpid::types::VariantMap& map,
bool includeProperties=true,
bool includeStatistics=true);
- void mapDecodeValues(const ::qpid::messaging::VariantMap& map);
+ void mapDecodeValues(const ::qpid::types::VariantMap& map);
void doMethod(std::string& methodName,
- const ::qpid::messaging::VariantMap& inMap,
- ::qpid::messaging::VariantMap& outMap);
+ const ::qpid::types::VariantMap& inMap,
+ ::qpid::types::VariantMap& outMap);
std::string getKey() const;
/*MGEN:IF(Root.GenQMFv1)*/
uint32_t writePropertiesSize() const;
diff --git a/qpid/cpp/managementgen/qmfgen/templates/Event.cpp b/qpid/cpp/managementgen/qmfgen/templates/Event.cpp
index dea02fd545..84ff5575b2 100644
--- a/qpid/cpp/managementgen/qmfgen/templates/Event.cpp
+++ b/qpid/cpp/managementgen/qmfgen/templates/Event.cpp
@@ -68,7 +68,6 @@ void Event/*MGEN:Event.NameCap*/::writeSchema (std::string& schema)
buf.putShortString (packageName); // Package Name
buf.putShortString (eventName); // Event Name
buf.putBin128 (md5Sum); // Schema Hash
- buf.putOctet (0); // No Superclass
buf.putShort (/*MGEN:Event.ArgCount*/); // Argument Count
// Arguments
@@ -94,8 +93,8 @@ void Event/*MGEN:Event.NameCap*/::encode(std::string& _sBuf) const
buf.getRawData(_sBuf, _bufLen);
}
-void Event/*MGEN:Event.NameCap*/::mapEncode(::qpid::messaging::VariantMap& map) const
+void Event/*MGEN:Event.NameCap*/::mapEncode(::qpid::types::VariantMap& map) const
{
- using namespace ::qpid::messaging;
+ using namespace ::qpid::types;
/*MGEN:Event.ArgMap*/
}
diff --git a/qpid/cpp/managementgen/qmfgen/templates/Event.h b/qpid/cpp/managementgen/qmfgen/templates/Event.h
index ab783c1698..e7218fb2c9 100644
--- a/qpid/cpp/managementgen/qmfgen/templates/Event.h
+++ b/qpid/cpp/managementgen/qmfgen/templates/Event.h
@@ -52,7 +52,7 @@ class Event/*MGEN:Event.NameCap*/ : public ::qpid::management::ManagementEvent
uint8_t* getMd5Sum() const { return md5Sum; }
uint8_t getSeverity() const { return /*MGEN:Event.Severity*/; }
void encode(std::string& buffer) const;
- void mapEncode(::qpid::messaging::VariantMap& map) const;
+ void mapEncode(::qpid::types::VariantMap& map) const;
};
}/*MGEN:Event.CloseNamespaces*/
diff --git a/qpid/cpp/src/CMakeLists.txt b/qpid/cpp/src/CMakeLists.txt
index 733b4848f9..1695c6fa17 100644
--- a/qpid/cpp/src/CMakeLists.txt
+++ b/qpid/cpp/src/CMakeLists.txt
@@ -567,6 +567,8 @@ set (qpidcommon_SOURCES
qpid/SessionId.cpp
qpid/StringUtils.cpp
qpid/Url.cpp
+ qpid/types/Uuid.cpp
+ qpid/types/Variant.cpp
qpid/amqp_0_10/SessionHandler.cpp
qpid/framing/AccumulatedAck.cpp
qpid/framing/AMQBody.cpp
@@ -677,6 +679,7 @@ set (qpidclient_SOURCES
qpid/messaging/AddressParser.cpp
qpid/messaging/Connection.cpp
qpid/messaging/ConnectionImpl.h
+ qpid/messaging/Duration.cpp
qpid/messaging/ListContent.cpp
qpid/messaging/ListView.cpp
qpid/messaging/MapContent.cpp
@@ -690,8 +693,6 @@ set (qpidclient_SOURCES
qpid/messaging/SessionImpl.h
qpid/messaging/Sender.cpp
qpid/messaging/SenderImpl.h
- qpid/messaging/Uuid.cpp
- qpid/messaging/Variant.cpp
qpid/client/amqp0_10/AcceptTracker.h
qpid/client/amqp0_10/AcceptTracker.cpp
qpid/client/amqp0_10/AddressResolution.h
diff --git a/qpid/cpp/src/Makefile.am b/qpid/cpp/src/Makefile.am
index c66263b42a..45b99ce327 100644
--- a/qpid/cpp/src/Makefile.am
+++ b/qpid/cpp/src/Makefile.am
@@ -427,6 +427,8 @@ libqpidcommon_la_SOURCES += \
qpid/memory.h \
qpid/pointer_to_other.h \
qpid/ptr_map.h \
+ qpid/types/Uuid.cpp \
+ qpid/types/Variant.cpp \
qpid/sys/AggregateOutput.cpp \
qpid/sys/AggregateOutput.h \
qpid/sys/AsynchIO.h \
@@ -707,6 +709,7 @@ libqpidclient_la_SOURCES = \
qpid/messaging/AddressParser.h \
qpid/messaging/AddressParser.cpp \
qpid/messaging/Connection.cpp \
+ qpid/messaging/Duration.cpp \
qpid/messaging/ListContent.cpp \
qpid/messaging/ListView.cpp \
qpid/messaging/MapContent.cpp \
@@ -718,8 +721,6 @@ libqpidclient_la_SOURCES = \
qpid/messaging/Sender.cpp \
qpid/messaging/Receiver.cpp \
qpid/messaging/Session.cpp \
- qpid/messaging/Uuid.cpp \
- qpid/messaging/Variant.cpp \
qpid/messaging/ConnectionImpl.h \
qpid/messaging/SenderImpl.h \
qpid/messaging/ReceiverImpl.h \
@@ -832,8 +833,8 @@ nobase_include_HEADERS += \
../include/qpid/messaging/Receiver.h \
../include/qpid/messaging/Sender.h \
../include/qpid/messaging/Session.h \
- ../include/qpid/messaging/Uuid.h \
- ../include/qpid/messaging/Variant.h \
+ ../include/qpid/types/Uuid.h \
+ ../include/qpid/types/Variant.h \
../include/qpid/client/amqp0_10/Codecs.h \
../include/qpid/client/amqp0_10/FailoverUpdates.h
diff --git a/qpid/cpp/src/qmf/engine/ValueImpl.cpp b/qpid/cpp/src/qmf/engine/ValueImpl.cpp
index b1c027520f..72c68c420b 100644
--- a/qpid/cpp/src/qmf/engine/ValueImpl.cpp
+++ b/qpid/cpp/src/qmf/engine/ValueImpl.cpp
@@ -18,20 +18,23 @@
*/
#include "qmf/engine/ValueImpl.h"
-#include <qpid/framing/FieldTable.h>
#include <qpid/framing/FieldValue.h>
+#include <qpid/framing/FieldTable.h>
+#include <qpid/framing/List.h>
using namespace std;
using namespace qmf::engine;
-using qpid::framing::Buffer;
-using qpid::framing::FieldTable;
-using qpid::framing::FieldValue;
+//using qpid::framing::Buffer;
+//using qpid::framing::FieldTable;
+//using qpid::framing::FieldValue;
+using namespace qpid::framing;
ValueImpl::ValueImpl(Typecode t, Buffer& buf) : typecode(t)
{
uint64_t first;
uint64_t second;
FieldTable ft;
+ List fl;
switch (typecode) {
case TYPE_UINT8 : value.u32 = (uint32_t) buf.getOctet(); break;
@@ -62,6 +65,10 @@ ValueImpl::ValueImpl(Typecode t, Buffer& buf) : typecode(t)
break;
case TYPE_LIST:
+ fl.decode(buf);
+ initList(fl);
+ break;
+
case TYPE_ARRAY:
case TYPE_OBJECT:
default:
@@ -126,7 +133,7 @@ void ValueImpl::initMap(const FieldTable& ft)
Value* subval(new Value(TYPE_DOUBLE));
subval->setDouble(fvalue.get<double>());
insert(name.c_str(), subval);
- } else {
+ } else if (amqType == 0xa8) {
FieldTable subFt;
bool valid = qpid::framing::getEncodedValue<FieldTable>(iter->second, subFt);
if (valid) {
@@ -134,6 +141,14 @@ void ValueImpl::initMap(const FieldTable& ft)
subval->impl->initMap(subFt);
insert(name.c_str(), subval);
}
+ } else if (amqType == 0xa9) {
+ List subList;
+ bool valid = qpid::framing::getEncodedValue<List>(iter->second, subList);
+ if (valid) {
+ Value* subval(new Value(TYPE_LIST));
+ subval->impl->initList(subList);
+ insert(name.c_str(), subval);
+ }
}
}
}
@@ -185,6 +200,14 @@ void ValueImpl::mapToFieldTable(FieldTable& ft) const
ft.setTable(name, subFt);
break;
case TYPE_LIST:
+ {
+ List subList;
+ subval.impl->listToFramingList(subList);
+ ft.set(name,
+ ::qpid::framing::FieldTable::ValuePtr(
+ new ListValue(
+ subList)));
+ } break;
case TYPE_ARRAY:
case TYPE_OBJECT:
case TYPE_UUID:
@@ -195,9 +218,126 @@ void ValueImpl::mapToFieldTable(FieldTable& ft) const
}
}
+
+void ValueImpl::initList(const List& fl)
+{
+ for (List::const_iterator iter = fl.begin();
+ iter != fl.end(); iter++) {
+ const FieldValue& fvalue(*iter->get());
+ uint8_t amqType = fvalue.getType();
+
+ if (amqType == 0x32) {
+ Value* subval(new Value(TYPE_UINT64));
+ subval->setUint64(fvalue.get<int64_t>());
+ appendToList(subval);
+ } else if ((amqType & 0xCF) == 0x02) {
+ Value* subval(new Value(TYPE_UINT32));
+ switch (amqType) {
+ case 0x02 : subval->setUint(fvalue.get<int>()); break;
+ case 0x12 : subval->setUint(fvalue.get<int>()); break;
+ case 0x22 : subval->setUint(fvalue.get<int>()); break;
+ }
+ appendToList(subval);
+ } else if ((amqType & 0xCF) == 0x01) {
+ Value* subval(new Value(TYPE_INT64));
+ subval->setInt64(fvalue.get<int64_t>());
+ appendToList(subval);
+ } else if (amqType == 0x85 || amqType == 0x95) {
+ Value* subval(new Value(TYPE_LSTR));
+ subval->setString(fvalue.get<string>().c_str());
+ appendToList(subval);
+ } else if (amqType == 0x23 || amqType == 0x33) {
+ Value* subval(new Value(TYPE_DOUBLE));
+ subval->setDouble(fvalue.get<double>());
+ appendToList(subval);
+ } else if (amqType == 0xa8) {
+ FieldTable subFt;
+ bool valid = qpid::framing::getEncodedValue<FieldTable>(*iter, subFt);
+ if (valid) {
+ Value* subval(new Value(TYPE_MAP));
+ subval->impl->initMap(subFt);
+ appendToList(subval);
+ }
+ } else if (amqType == 0xa9) {
+ List subList;
+ bool valid = qpid::framing::getEncodedValue<List>(*iter, subList);
+ if (valid) {
+ Value *subVal(new Value(TYPE_LIST));
+ subVal->impl->initList(subList);
+ appendToList(subVal);
+ }
+ }
+ }
+}
+
+void ValueImpl::listToFramingList(List& fl) const
+{
+ for (vector<Value>::const_iterator iter = vectorVal.begin();
+ iter != vectorVal.end(); iter++) {
+ const Value& subval(*iter);
+
+ switch (subval.getType()) {
+ case TYPE_UINT8:
+ case TYPE_UINT16:
+ case TYPE_UINT32:
+ fl.push_back(List::ValuePtr(new Unsigned64Value((uint64_t) subval.asUint())));
+ break;
+ case TYPE_UINT64:
+ case TYPE_DELTATIME:
+ fl.push_back(List::ValuePtr(new Unsigned64Value(subval.asUint64())));
+ break;
+ case TYPE_SSTR:
+ case TYPE_LSTR:
+ fl.push_back(List::ValuePtr(new Str16Value(subval.asString())));
+ break;
+ case TYPE_INT64:
+ case TYPE_ABSTIME:
+ fl.push_back(List::ValuePtr(new Integer64Value(subval.asInt64())));
+ break;
+ case TYPE_BOOL:
+ fl.push_back(List::ValuePtr(new IntegerValue(subval.asBool() ? 1 : 0)));
+ break;
+ case TYPE_FLOAT:
+ fl.push_back(List::ValuePtr(new FloatValue(subval.asFloat())));
+ break;
+ case TYPE_DOUBLE:
+ fl.push_back(List::ValuePtr(new DoubleValue(subval.asDouble())));
+ break;
+ case TYPE_INT8:
+ case TYPE_INT16:
+ case TYPE_INT32:
+ fl.push_back(List::ValuePtr(new IntegerValue(subval.asInt())));
+ break;
+ case TYPE_MAP:
+ {
+ FieldTable subFt;
+ subval.impl->mapToFieldTable(subFt);
+ fl.push_back(List::ValuePtr(new FieldTableValue(subFt)));
+
+ } break;
+ case TYPE_LIST:
+ {
+ List subList;
+ subval.impl->listToFramingList(subList);
+ fl.push_back(List::ValuePtr(new ListValue(subList)));
+ } break;
+
+ case TYPE_ARRAY:
+ case TYPE_OBJECT:
+ case TYPE_UUID:
+ case TYPE_REF:
+ default:
+ break;
+ }
+ }
+ }
+
+
+
void ValueImpl::encode(Buffer& buf) const
{
FieldTable ft;
+ List fl;
switch (typecode) {
case TYPE_UINT8 : buf.putOctet((uint8_t) value.u32); break;
@@ -222,6 +362,10 @@ void ValueImpl::encode(Buffer& buf) const
ft.encode(buf);
break;
case TYPE_LIST:
+ listToFramingList(fl);
+ fl.encode(buf);
+ break;
+
case TYPE_ARRAY:
case TYPE_OBJECT:
default:
@@ -280,19 +424,6 @@ const char* ValueImpl::key(uint32_t idx) const
return iter->first.c_str();
}
-Value* ValueImpl::listItem(uint32_t)
-{
- return 0;
-}
-
-void ValueImpl::appendToList(Value*)
-{
-}
-
-void ValueImpl::deleteListItem(uint32_t)
-{
-}
-
Value* ValueImpl::arrayItem(uint32_t)
{
return 0;
diff --git a/qpid/cpp/src/qmf/engine/ValueImpl.h b/qpid/cpp/src/qmf/engine/ValueImpl.h
index 84b0e768e6..3b535834fd 100644
--- a/qpid/cpp/src/qmf/engine/ValueImpl.h
+++ b/qpid/cpp/src/qmf/engine/ValueImpl.h
@@ -33,6 +33,7 @@
namespace qpid {
namespace framing {
class FieldTable;
+ class List;
}
}
@@ -138,13 +139,14 @@ namespace engine {
bool isList() const { return typecode == TYPE_LIST; }
uint32_t listItemCount() const { return vectorVal.size(); }
- Value* listItem(uint32_t idx);
- void appendToList(Value* val);
- void deleteListItem(uint32_t idx);
+ Value* listItem(uint32_t idx) { return idx < listItemCount() ? &vectorVal[idx] : 0; }
+ const Value* listItem(uint32_t idx) const { return idx < listItemCount() ? &vectorVal[idx] : 0; }
+ void appendToList(Value* val) { vectorVal.push_back(*val); }
+ void deleteListItem(uint32_t idx) { if (idx < listItemCount()) vectorVal.erase(vectorVal.begin()+idx); }
bool isArray() const { return typecode == TYPE_ARRAY; }
Typecode arrayType() const { return arrayTypecode; }
- uint32_t arrayItemCount() const { return vectorVal.size(); }
+ uint32_t arrayItemCount() const { return 0; }
Value* arrayItem(uint32_t idx);
void appendToArray(Value* val);
void deleteArrayItem(uint32_t idx);
@@ -152,6 +154,9 @@ namespace engine {
private:
void mapToFieldTable(qpid::framing::FieldTable& ft) const;
void initMap(const qpid::framing::FieldTable& ft);
+
+ void listToFramingList(qpid::framing::List& fl) const;
+ void initList(const qpid::framing::List& fl);
};
}
}
diff --git a/qpid/cpp/src/qpid/acl/Acl.cpp b/qpid/cpp/src/qpid/acl/Acl.cpp
index 32287a42af..e510920f6c 100644
--- a/qpid/cpp/src/qpid/acl/Acl.cpp
+++ b/qpid/cpp/src/qpid/acl/Acl.cpp
@@ -23,7 +23,7 @@
#include "qpid/Plugin.h"
#include "qpid/Options.h"
#include "qpid/log/Logger.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qmf/org/apache/qpid/acl/Package.h"
#include "qmf/org/apache/qpid/acl/EventAllow.h"
#include "qmf/org/apache/qpid/acl/EventDeny.h"
@@ -95,7 +95,7 @@ Acl::Acl (AclValues& av, Broker& b): aclValues(av), broker(&b), transferAcl(fals
" ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name );
agent->raiseEvent(_qmf::EventAllow(id, AclHelper::getActionStr(action),
AclHelper::getObjectTypeStr(objType),
- name, messaging::Variant::Map()));
+ name, types::Variant::Map()));
case ALLOW:
return true;
case DENY:
@@ -107,7 +107,7 @@ Acl::Acl (AclValues& av, Broker& b): aclValues(av), broker(&b), transferAcl(fals
QPID_LOG(info, "ACL Deny id:" << id << " action:" << AclHelper::getActionStr(action) << " ObjectType:" << AclHelper::getObjectTypeStr(objType) << " Name:" << name);
agent->raiseEvent(_qmf::EventDeny(id, AclHelper::getActionStr(action),
AclHelper::getObjectTypeStr(objType),
- name, messaging::Variant::Map()));
+ name, types::Variant::Map()));
return false;
}
return false;
diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
index 298a549651..bafa7edff2 100644
--- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
+++ b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
@@ -44,7 +44,7 @@ using std::ifstream;
using std::string;
using std::cout;
using std::endl;
-using qpid::messaging::Variant;
+using qpid::types::Variant;
namespace {
Mutex lock;
@@ -127,7 +127,7 @@ void ManagementAgentImpl::setName(const string& vendor, const string& product, c
attrMap["_product"] = product;
string inst;
if (instance.empty()) {
- inst = qpid::messaging::Uuid(true).str();
+ inst = qpid::types::Uuid(true).str();
} else
inst = instance;
@@ -366,8 +366,8 @@ void ManagementAgentImpl::sendHeartbeat()
messaging::Message msg;
messaging::MapContent content(msg);
- messaging::Variant::Map& map(content.asMap());
- messaging::Variant::Map headers;
+ types::Variant::Map& map(content.asMap());
+ types::Variant::Map headers;
headers["method"] = "indication";
headers["qmf.opcode"] = "_agent_heartbeat_indication";
@@ -389,9 +389,9 @@ void ManagementAgentImpl::sendException(const string& replyToKey, const string&
messaging::Message msg;
messaging::MapContent content(msg);
- messaging::Variant::Map& map(content.asMap());
- messaging::Variant::Map headers;
- messaging::Variant::Map values;
+ types::Variant::Map& map(content.asMap());
+ types::Variant::Map headers;
+ types::Variant::Map values;
headers["method"] = "indication";
headers["qmf.opcode"] = "_exception";
@@ -503,7 +503,7 @@ void ManagementAgentImpl::invokeMethodRequest(const string& body, const string&
failed = true;
}
- } catch(messaging::InvalidConversion& e) {
+ } catch(types::InvalidConversion& e) {
outMap.clear();
outMap["_values"] = Variant::Map();
(outMap["_values"].asMap())["_status_code"] = Manageable::STATUS_EXCEPTION;
@@ -560,7 +560,7 @@ void ManagementAgentImpl::handleGetQuery(const string& body, const string& cid,
return;
}
- if (i->second.getType() != qpid::messaging::VAR_STRING) {
+ if (i->second.getType() != qpid::types::VAR_STRING) {
sendException(replyTo, cid, "_what element is not a string");
return;
}
@@ -577,15 +577,15 @@ void ManagementAgentImpl::handleGetQuery(const string& body, const string& cid,
* Handle the _schema_id element, if supplied.
*/
i = inMap.find("_schema_id");
- if (i != inMap.end() && i->second.getType() == qpid::messaging::VAR_MAP) {
+ if (i != inMap.end() && i->second.getType() == qpid::types::VAR_MAP) {
const Variant::Map& schemaIdMap(i->second.asMap());
Variant::Map::const_iterator s_iter = schemaIdMap.find("_class_name");
- if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::messaging::VAR_STRING)
+ if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::types::VAR_STRING)
className = s_iter->second.asString();
s_iter = schemaIdMap.find("_package_name");
- if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::messaging::VAR_STRING)
+ if (s_iter != schemaIdMap.end() && s_iter->second.getType() == qpid::types::VAR_STRING)
packageName = s_iter->second.asString();
}
@@ -594,7 +594,7 @@ void ManagementAgentImpl::handleGetQuery(const string& body, const string& cid,
* object and return it. If it is not present, send a class-based result.
*/
i = inMap.find("_object_id");
- if (i != inMap.end() && i->second.getType() == qpid::messaging::VAR_MAP) {
+ if (i != inMap.end() && i->second.getType() == qpid::types::VAR_MAP) {
ObjectId objId(i->second.asMap());
ManagementObjectMap::iterator iter = managementObjects.find(objId);
@@ -666,8 +666,8 @@ void ManagementAgentImpl::handleLocateRequest(const string&, const string& cid,
messaging::Message msg;
messaging::MapContent content(msg);
- messaging::Variant::Map& map(content.asMap());
- messaging::Variant::Map headers;
+ types::Variant::Map& map(content.asMap());
+ types::Variant::Map headers;
headers["method"] = "indication";
headers["qmf.opcode"] = "_agent_locate_response";
@@ -770,7 +770,7 @@ Variant::Map ManagementAgentImpl::mapEncodeSchemaId(const string& pname,
map_["_package_name"] = pname;
map_["_class_name"] = cname;
- map_["_hash"] = messaging::Uuid(md5Sum);
+ map_["_hash"] = types::Uuid(md5Sum);
return map_;
}
diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
index 43b9f36c31..be1198a195 100644
--- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
+++ b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
@@ -145,7 +145,7 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen
void received (client::Message& msg);
- qpid::messaging::Variant::Map attrMap;
+ qpid::types::Variant::Map attrMap;
std::string name_address;
uint16_t interval;
bool extThread;
@@ -208,7 +208,7 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen
const std::string& routingKey);
void sendBuffer(const std::string& data,
const std::string& cid,
- const qpid::messaging::VariantMap headers,
+ const qpid::types::VariantMap headers,
const std::string& exchange,
const std::string& routingKey,
const std::string& contentType="amqp/map");
@@ -254,9 +254,9 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen
PackageMap::iterator pIter,
ClassMap::iterator cIter);
void encodeHeader (framing::Buffer& buf, uint8_t opcode, uint32_t seq = 0);
- qpid::messaging::Variant::Map mapEncodeSchemaId(const std::string& pname,
- const std::string& cname,
- const uint8_t *md5Sum);
+ qpid::types::Variant::Map mapEncodeSchemaId(const std::string& pname,
+ const std::string& cname,
+ const uint8_t *md5Sum);
bool checkHeader (framing::Buffer& buf, uint8_t *opcode, uint32_t *seq);
void sendHeartbeat();
void sendException(const std::string& replyToKey, const std::string& cid,
diff --git a/qpid/cpp/src/qpid/broker/System.cpp b/qpid/cpp/src/qpid/broker/System.cpp
index 4a30696f75..90c6b13cd3 100644
--- a/qpid/cpp/src/qpid/broker/System.cpp
+++ b/qpid/cpp/src/qpid/broker/System.cpp
@@ -22,7 +22,7 @@
#include "qpid/management/ManagementAgent.h"
#include "qpid/framing/Uuid.h"
#include "qpid/sys/SystemInfo.h"
-#include "qpid/messaging/Uuid.h"
+#include "qpid/types/Uuid.h"
#include <iostream>
#include <fstream>
@@ -65,7 +65,7 @@ System::System (string _dataDir, Broker* broker) : mgmtObject(0)
}
}
- mgmtObject = new _qmf::System(agent, this, messaging::Uuid(systemId.c_array()));
+ mgmtObject = new _qmf::System(agent, this, types::Uuid(systemId.c_array()));
std::string sysname, nodename, release, version, machine;
qpid::sys::SystemInfo::getSystemId (sysname,
nodename,
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
index 9f2d4eef78..990b2a19d8 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp
@@ -26,7 +26,7 @@
#include "qpid/client/amqp0_10/OutgoingMessage.h"
#include "qpid/messaging/Address.h"
#include "qpid/messaging/Message.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/Exception.h"
#include "qpid/log/Statement.h"
#include "qpid/framing/enum.h"
@@ -47,13 +47,13 @@ namespace amqp0_10 {
using qpid::Exception;
using qpid::messaging::Address;
using qpid::messaging::InvalidAddress;
-using qpid::messaging::Variant;
using qpid::framing::ExchangeBoundResult;
using qpid::framing::ExchangeQueryResult;
using qpid::framing::FieldTable;
using qpid::framing::QueueQueryResult;
using qpid::framing::ReplyTo;
using qpid::framing::Uuid;
+using namespace qpid::types;
using namespace qpid::framing::message;
using namespace boost::assign;
@@ -278,7 +278,7 @@ const Variant& getOption(const Variant::Map& options, const std::vector<std::str
if (j == options.end()) {
return EMPTY_VARIANT;
} else if (++index < path.size()) {
- if (j->second.getType() != qpid::messaging::VAR_MAP)
+ if (j->second.getType() != VAR_MAP)
throw InvalidAddress((boost::format("Expected %1% to be a map") % j->first).str());
return getOption(j->second.asMap(), path, index);
} else {
@@ -326,7 +326,7 @@ Opt& Opt::operator/(const std::string& name)
options = 0;
} else {
value = &(j->second);
- if (value->getType() == qpid::messaging::VAR_MAP) options = &(value->asMap());
+ if (value->getType() == VAR_MAP) options = &(value->asMap());
else options = 0;
}
}
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.h b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.h
index 5b81b06131..fc8f1a1d18 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/AddressResolution.h
@@ -21,7 +21,6 @@
* under the License.
*
*/
-#include "qpid/messaging/Variant.h"
#include "qpid/client/Session.h"
namespace qpid {
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/Codecs.cpp b/qpid/cpp/src/qpid/client/amqp0_10/Codecs.cpp
index 3e17fc968b..ce806572e5 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/Codecs.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/Codecs.cpp
@@ -19,7 +19,7 @@
*
*/
#include "qpid/client/amqp0_10/Codecs.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/framing/Array.h"
#include "qpid/framing/Buffer.h"
#include "qpid/framing/FieldTable.h"
@@ -32,6 +32,7 @@
using namespace qpid::framing;
using namespace qpid::messaging;
+using namespace qpid::types;
namespace qpid {
namespace client {
@@ -115,11 +116,11 @@ void setEncodingFor(Variant& out, uint8_t code)
}
}
-qpid::messaging::Uuid getUuid(FieldValue& value)
+qpid::types::Uuid getUuid(FieldValue& value)
{
unsigned char data[16];
value.getFixedWidthValue<16>(data);
- return qpid::messaging::Uuid(data);
+ return qpid::types::Uuid(data);
}
Variant toVariant(boost::shared_ptr<FieldValue> in)
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/CodecsInternal.h b/qpid/cpp/src/qpid/client/amqp0_10/CodecsInternal.h
index b5a561a9c3..a110d80b8a 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/CodecsInternal.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/CodecsInternal.h
@@ -21,7 +21,7 @@
* under the License.
*
*/
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/framing/FieldTable.h"
namespace qpid {
@@ -33,8 +33,8 @@ namespace amqp0_10 {
* Codecs.cpp but not exposed through API
*/
-void translate(const qpid::messaging::Variant::Map& from, qpid::framing::FieldTable& to);
-void translate(const qpid::framing::FieldTable& from, qpid::messaging::Variant::Map& to);
+void translate(const qpid::types::Variant::Map& from, qpid::framing::FieldTable& to);
+void translate(const qpid::framing::FieldTable& from, qpid::types::Variant::Map& to);
}}} // namespace qpid::client::amqp0_10
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
index ce4e1ecc2a..ee044aaf2b 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
@@ -32,7 +32,8 @@ namespace qpid {
namespace client {
namespace amqp0_10 {
-using qpid::messaging::Variant;
+using qpid::types::Variant;
+using qpid::types::VAR_LIST;
using qpid::framing::Uuid;
void convert(const Variant::List& from, std::vector<std::string>& to)
@@ -62,7 +63,7 @@ bool setIfFound< std::vector<std::string> >(const Variant::Map& map,
{
Variant::Map::const_iterator i = map.find(key);
if (i != map.end()) {
- if (i->second.getType() == qpid::messaging::VAR_LIST) {
+ if (i->second.getType() == VAR_LIST) {
convert(i->second.asList(), value);
} else {
value.push_back(i->second.asString());
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h
index 37a78b2373..2c59d8add8 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.h
@@ -22,7 +22,7 @@
*
*/
#include "qpid/messaging/ConnectionImpl.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/Url.h"
#include "qpid/client/Connection.h"
#include "qpid/client/ConnectionSettings.h"
@@ -39,14 +39,14 @@ class SessionImpl;
class ConnectionImpl : public qpid::messaging::ConnectionImpl
{
public:
- ConnectionImpl(const qpid::messaging::Variant::Map& options);
+ ConnectionImpl(const qpid::types::Variant::Map& options);
void open(const std::string& url);
void close();
qpid::messaging::Session newSession(bool transactional, const std::string& name);
qpid::messaging::Session getSession(const std::string& name) const;
void closed(SessionImpl&);
void connect();
- void setOption(const std::string& name, const qpid::messaging::Variant& value);
+ void setOption(const std::string& name, const qpid::types::Variant& value);
private:
typedef std::map<std::string, qpid::messaging::Session> Sessions;
@@ -63,7 +63,7 @@ class ConnectionImpl : public qpid::messaging::ConnectionImpl
int64_t maxReconnectInterval;
int32_t retries;
- void setOptions(const qpid::messaging::Variant::Map& options);
+ void setOptions(const qpid::types::Variant::Map& options);
void connect(const qpid::sys::AbsTime& started);
bool tryConnect();
bool tryConnect(const std::vector<std::string>& urls);
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/FailoverUpdates.cpp b/qpid/cpp/src/qpid/client/amqp0_10/FailoverUpdates.cpp
index 8ef62e4d41..5e526a2ffc 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/FailoverUpdates.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/FailoverUpdates.cpp
@@ -56,7 +56,7 @@ struct FailoverUpdatesImpl : qpid::sys::Runnable
try {
Message message;
while (!quit && receiver.fetch(message)) {
- connection.setOption("urls", message.getHeaders()["amq.failover"]);
+ connection.setOption("urls", message.getProperties()["amq.failover"]);
session.acknowledge();
}
} catch (const qpid::TransportFailure& e) {
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp b/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp
index 669ffd7e9a..345ebfb66d 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/IncomingMessages.cpp
@@ -26,9 +26,10 @@
#include "qpid/client/SessionBase_0_10Access.h"
#include "qpid/log/Statement.h"
#include "qpid/messaging/Address.h"
+#include "qpid/messaging/Duration.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/MessageImpl.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/framing/DeliveryProperties.h"
#include "qpid/framing/FrameSet.h"
#include "qpid/framing/MessageProperties.h"
@@ -44,7 +45,7 @@ using namespace qpid::framing::message;
using qpid::sys::AbsTime;
using qpid::sys::Duration;
using qpid::messaging::MessageImplAccess;
-using qpid::messaging::Variant;
+using qpid::types::Variant;
namespace {
const std::string EMPTY_STRING;
@@ -276,9 +277,10 @@ void populateHeaders(qpid::messaging::Message& message,
const MessageProperties* messageProperties)
{
if (deliveryProperties) {
- message.setTtl(deliveryProperties->getTtl());
+ message.setTtl(qpid::messaging::Duration(deliveryProperties->getTtl()));
message.setDurable(deliveryProperties->getDeliveryMode() == DELIVERY_MODE_PERSISTENT);
- MessageImplAccess::get(message).redelivered = deliveryProperties->getRedelivered();
+ message.setPriority(deliveryProperties->getPriority());
+ message.setRedelivered(deliveryProperties->getRedelivered());
}
if (messageProperties) {
message.setContentType(messageProperties->getContentType());
@@ -286,8 +288,8 @@ void populateHeaders(qpid::messaging::Message& message,
message.setReplyTo(AddressResolution::convert(messageProperties->getReplyTo()));
}
message.setSubject(messageProperties->getApplicationHeaders().getAsString(SUBJECT));
- message.getHeaders().clear();
- translate(messageProperties->getApplicationHeaders(), message.getHeaders());
+ message.getProperties().clear();
+ translate(messageProperties->getApplicationHeaders(), message.getProperties());
message.setCorrelationId(messageProperties->getCorrelationId());
message.setUserId(messageProperties->getUserId());
}
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp b/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp
index e75368cda7..b19b26f903 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/OutgoingMessage.cpp
@@ -46,12 +46,15 @@ void OutgoingMessage::convert(const qpid::messaging::Message& from)
if (address) {
message.getMessageProperties().setReplyTo(AddressResolution::convert(address));
}
- translate(from.getHeaders(), message.getMessageProperties().getApplicationHeaders());
- message.getDeliveryProperties().setTtl(from.getTtl());
+ translate(from.getProperties(), message.getMessageProperties().getApplicationHeaders());
+ message.getDeliveryProperties().setTtl(from.getTtl().getMilliseconds());
if (from.getDurable()) {
message.getDeliveryProperties().setDeliveryMode(DELIVERY_MODE_PERSISTENT);
}
-
+ if (from.getRedelivered()) {
+ message.getDeliveryProperties().setRedelivered(true);
+ }
+ if (from.getPriority()) message.getDeliveryProperties().setPriority(from.getPriority());
}
namespace {
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
index 2f52efbceb..c3367f8ab4 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
@@ -30,6 +30,7 @@ namespace client {
namespace amqp0_10 {
using qpid::messaging::Receiver;
+using qpid::messaging::Duration;
void ReceiverImpl::received(qpid::messaging::Message&)
{
@@ -163,7 +164,7 @@ bool ReceiverImpl::fetchImpl(qpid::messaging::Message& message, qpid::messaging:
} else {
sync(session).messageFlush(destination);
startFlow();//reallocate credit
- return getImpl(message, 0);
+ return getImpl(message, Duration::IMMEDIATE);
}
}
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
index 689a7f6f25..d509490688 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
@@ -24,7 +24,6 @@
#include "qpid/messaging/Address.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/ReceiverImpl.h"
-#include "qpid/messaging/Variant.h"
#include "qpid/client/AsyncSession.h"
#include "qpid/client/amqp0_10/SessionImpl.h"
#include "qpid/messaging/Duration.h"
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/SenderImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/SenderImpl.h
index 9e4181f42f..a99d4bd294 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/SenderImpl.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/SenderImpl.h
@@ -24,7 +24,6 @@
#include "qpid/messaging/Address.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/SenderImpl.h"
-#include "qpid/messaging/Variant.h"
#include "qpid/client/AsyncSession.h"
#include "qpid/client/amqp0_10/SessionImpl.h"
#include <memory>
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
index 65308dd0be..209ab93909 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
+++ b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
@@ -43,7 +43,6 @@ using qpid::messaging::KeyError;
using qpid::messaging::MessageImplAccess;
using qpid::messaging::Sender;
using qpid::messaging::Receiver;
-using qpid::messaging::VariantMap;
namespace qpid {
namespace client {
@@ -268,8 +267,9 @@ bool SessionImpl::accept(ReceiverImpl* receiver,
qpid::sys::Duration adjust(qpid::messaging::Duration timeout)
{
- if (timeout < (uint64_t) (qpid::sys::TIME_INFINITE/qpid::sys::TIME_MSEC)) {
- return timeout * qpid::sys::TIME_MSEC;
+ uint64_t ms = timeout.getMilliseconds();
+ if (ms < (uint64_t) (qpid::sys::TIME_INFINITE/qpid::sys::TIME_MSEC)) {
+ return ms * qpid::sys::TIME_MSEC;
} else {
return qpid::sys::TIME_INFINITE;
}
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.h b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.h
index a7eaae3cdd..a616db6239 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.h
+++ b/qpid/cpp/src/qpid/client/amqp0_10/SessionImpl.h
@@ -23,7 +23,6 @@
*/
#include "qpid/messaging/SessionImpl.h"
#include "qpid/messaging/Duration.h"
-#include "qpid/messaging/Variant.h"
#include "qpid/client/Session.h"
#include "qpid/client/SubscriptionManager.h"
#include "qpid/client/amqp0_10/AddressResolution.h"
diff --git a/qpid/cpp/src/qpid/cluster/Cluster.cpp b/qpid/cpp/src/qpid/cluster/Cluster.cpp
index f8a875a30c..6bb597d21f 100644
--- a/qpid/cpp/src/qpid/cluster/Cluster.cpp
+++ b/qpid/cpp/src/qpid/cluster/Cluster.cpp
@@ -668,7 +668,7 @@ void Cluster::configChange(const MemberId&, const std::string& configStr, Lock&
QPID_LOG(debug, "Config sequence " << map.getConfigSeq());
store.setConfigSeq(map.getConfigSeq());
- // Update initital status for new members joining.
+ // Update initital status for members joining or leaving.
initMap.configChange(config);
if (initMap.isResendNeeded()) {
mcast.mcastControl(
@@ -757,6 +757,8 @@ void Cluster::initialStatus(const MemberId& member, uint32_t version, bool activ
leave(l);
return;
}
+ QPID_LOG_IF(debug, state == PRE_INIT, *this
+ << " received initial status from " << member);
initMap.received(
member,
ClusterInitialStatusBody(ProtocolVersion(), version, active, id,
diff --git a/qpid/cpp/src/qpid/cluster/ClusterTimer.cpp b/qpid/cpp/src/qpid/cluster/ClusterTimer.cpp
index 4068a4783c..baeaafb478 100644
--- a/qpid/cpp/src/qpid/cluster/ClusterTimer.cpp
+++ b/qpid/cpp/src/qpid/cluster/ClusterTimer.cpp
@@ -38,6 +38,7 @@ ClusterTimer::ClusterTimer(Cluster& c) : cluster(c) {
// Allow more generous overrun threshold with cluster as we
// have to do a CPG round trip before executing the task.
overran = 10*sys::TIME_MSEC;
+ late = 100*sys::TIME_MSEC;
}
ClusterTimer::~ClusterTimer() {}
diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.cpp b/qpid/cpp/src/qpid/management/ManagementAgent.cpp
index 86fb765759..eb1df6d8e9 100644
--- a/qpid/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/qpid/cpp/src/qpid/management/ManagementAgent.cpp
@@ -29,8 +29,8 @@
#include "qpid/sys/Time.h"
#include "qpid/broker/ConnectionState.h"
#include "qpid/broker/AclModule.h"
-#include "qpid/messaging/Variant.h"
-#include "qpid/messaging/Uuid.h"
+#include "qpid/types/Variant.h"
+#include "qpid/types/Uuid.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/ListContent.h"
#include "qpid/messaging/ListView.h"
@@ -43,7 +43,8 @@
using boost::intrusive_ptr;
using qpid::framing::Uuid;
-using qpid::messaging::Variant;
+using qpid::types::Variant;
+using qpid::types::VariantMap;
using namespace qpid::framing;
using namespace qpid::management;
using namespace qpid::broker;
@@ -54,17 +55,17 @@ namespace _qmf = qmf::org::apache::qpid::broker;
-static qpid::messaging::Variant::Map mapEncodeSchemaId(const std::string& pname,
- const std::string& cname,
- const std::string& type,
- const uint8_t *md5Sum)
+static Variant::Map mapEncodeSchemaId(const std::string& pname,
+ const std::string& cname,
+ const std::string& type,
+ const uint8_t *md5Sum)
{
- qpid::messaging::Variant::Map map_;
+ Variant::Map map_;
map_["_package_name"] = pname;
map_["_class_name"] = cname;
map_["_type"] = type;
- map_["_hash"] = qpid::messaging::Uuid(md5Sum);
+ map_["_hash"] = qpid::types::Uuid(md5Sum);
return map_;
}
@@ -346,10 +347,10 @@ void ManagementAgent::raiseEvent(const ManagementEvent& event, severity_t severi
if (qmf2Support) {
::qpid::messaging::Message msg;
::qpid::messaging::MapContent content(msg);
- ::qpid::messaging::VariantMap &map_ = content.asMap();
- ::qpid::messaging::VariantMap schemaId;
- ::qpid::messaging::VariantMap values;
- ::qpid::messaging::VariantMap headers;
+ VariantMap &map_ = content.asMap();
+ VariantMap schemaId;
+ VariantMap values;
+ VariantMap headers;
map_["_schema_id"] = mapEncodeSchemaId(event.getPackageName(),
event.getEventName(),
@@ -483,11 +484,11 @@ void ManagementAgent::sendBuffer(Buffer& buf,
void ManagementAgent::sendBuffer(const std::string& data,
const std::string& cid,
- const qpid::messaging::VariantMap& headers,
+ const VariantMap& headers,
qpid::broker::Exchange::shared_ptr exchange,
const std::string& routingKey)
{
- qpid::messaging::VariantMap::const_iterator i;
+ VariantMap::const_iterator i;
if (suppressed) {
QPID_LOG(trace, "Suppressed management message to " << routingKey);
@@ -620,7 +621,7 @@ void ManagementAgent::periodicProcessing (void)
Buffer msgBuffer(msgChars, BUFSIZE);
::qpid::messaging::Message m;
::qpid::messaging::ListContent content(m);
- ::qpid::messaging::Variant::List &list_ = content.asList();
+ Variant::List &list_ = content.asList();
for (ManagementObjectMap::iterator iter = baseIter;
iter != managementObjects.end();
@@ -650,8 +651,8 @@ void ManagementAgent::periodicProcessing (void)
}
if ((send_stats || send_props) && qmf2Support) {
- ::qpid::messaging::Variant::Map map_;
- ::qpid::messaging::Variant::Map values;
+ Variant::Map map_;
+ Variant::Map values;
map_["_schema_id"] = mapEncodeSchemaId(object->getPackageName(),
object->getClassName(),
@@ -692,7 +693,7 @@ void ManagementAgent::periodicProcessing (void)
const std::string &body = m.getContent();
if (body.length()) {
stringstream key;
- ::qpid::messaging::Variant::Map headers;
+ Variant::Map headers;
key << "agent.ind.data." << baseObject->getPackageName() << "." << baseObject->getClassName();
// key << "console.obj.1.0." << baseObject->getPackageName() << "." << baseObject->getClassName();
headers["method"] = "indication";
@@ -738,10 +739,10 @@ void ManagementAgent::periodicProcessing (void)
if (qmf2Support) {
::qpid::messaging::Message m;
::qpid::messaging::ListContent content(m);
- ::qpid::messaging::Variant::List &list_ = content.asList();
- ::qpid::messaging::Variant::Map map_;
- ::qpid::messaging::Variant::Map values;
- ::qpid::messaging::Variant::Map headers;
+ Variant::List &list_ = content.asList();
+ Variant::Map map_;
+ Variant::Map values;
+ Variant::Map headers;
map_["_schema_id"] = mapEncodeSchemaId((*cdIter)->getPackageName(),
(*cdIter)->getClassName(),
@@ -793,8 +794,8 @@ void ManagementAgent::periodicProcessing (void)
messaging::Message msg;
messaging::MapContent content(msg);
- messaging::Variant::Map& map(content.asMap());
- messaging::Variant::Map headers;
+ Variant::Map& map(content.asMap());
+ Variant::Map headers;
headers["method"] = "indication";
headers["qmf.opcode"] = "_agent_heartbeat_indication";
@@ -841,9 +842,9 @@ void ManagementAgent::deleteObjectNowLH(const ObjectId& oid)
if (qmf2Support) {
::qpid::messaging::Message m;
::qpid::messaging::ListContent content(m);
- ::qpid::messaging::Variant::List &list_ = content.asList();
- ::qpid::messaging::Variant::Map map_;
- ::qpid::messaging::Variant::Map values;
+ Variant::List &list_ = content.asList();
+ Variant::Map map_;
+ Variant::Map values;
map_["_schema_id"] = mapEncodeSchemaId(object->getPackageName(),
object->getClassName(),
@@ -856,7 +857,7 @@ void ManagementAgent::deleteObjectNowLH(const ObjectId& oid)
stringstream key;
key << "agent.ind.data." << object->getPackageName() << "." << object->getClassName();
- ::qpid::messaging::Variant::Map headers;
+ Variant::Map headers;
headers["method"] = "indication";
headers["qmf.opcode"] = "_data_indication";
headers["qmf.content"] = "_data";
@@ -1051,7 +1052,7 @@ void ManagementAgent::handleMethodRequestLH (const std::string& body, string rep
qpid::messaging::Message outMsg;
qpid::messaging::MapContent outMap(outMsg);
- qpid::messaging::Variant::Map headers;
+ Variant::Map headers;
headers["method"] = "response";
headers["qmf.opcode"] = "_method_response";
@@ -1070,7 +1071,7 @@ void ManagementAgent::handleMethodRequestLH (const std::string& body, string rep
}
ObjectId objId;
- qpid::messaging::Variant::Map inArgs;
+ Variant::Map inArgs;
try {
// coversions will throw if input is invalid.
@@ -1581,7 +1582,7 @@ void ManagementAgent::handleGetQueryLH(const std::string& body, std::string repl
qpid::messaging::Message inMsg(body);
qpid::messaging::MapView inMap(inMsg);
qpid::messaging::MapView::const_iterator i;
- ::qpid::messaging::Variant::Map headers;
+ Variant::Map headers;
QPID_LOG(trace, "RECV GetQuery (v2): map=" << inMap << " seq=" << cid);
@@ -1593,9 +1594,9 @@ void ManagementAgent::handleGetQueryLH(const std::string& body, std::string repl
::qpid::messaging::Message outMsg;
::qpid::messaging::ListContent content(outMsg);
- ::qpid::messaging::Variant::List &list_ = content.asList();
- ::qpid::messaging::Variant::Map map_;
- ::qpid::messaging::Variant::Map values;
+ Variant::List &list_ = content.asList();
+ Variant::Map map_;
+ Variant::Map values;
string className;
i = inMap.find("_class");
@@ -1677,8 +1678,8 @@ void ManagementAgent::handleLocateRequestLH(const string&, const string& replyTo
messaging::Message msg;
messaging::MapContent content(msg);
- messaging::Variant::Map& map(content.asMap());
- messaging::Variant::Map headers;
+ Variant::Map& map(content.asMap());
+ Variant::Map headers;
headers["method"] = "indication";
headers["qmf.opcode"] = "_agent_locate_response";
@@ -1818,7 +1819,7 @@ bool ManagementAgent::authorizeAgentMessageLH(Message& msg)
qpid::messaging::Message outMsg;
qpid::messaging::MapContent outMap(outMsg);
- qpid::messaging::Variant::Map headers;
+ Variant::Map headers;
headers["method"] = "response";
headers["qmf.opcode"] = "_method_response";
@@ -2119,20 +2120,20 @@ void ManagementAgent::disallow(const std::string& className, const std::string&
disallowed[std::make_pair(className, methodName)] = message;
}
-void ManagementAgent::SchemaClassKey::mapEncode(qpid::messaging::Variant::Map& _map) const {
+void ManagementAgent::SchemaClassKey::mapEncode(Variant::Map& _map) const {
_map["_cname"] = name;
- _map["_hash"] = qpid::messaging::Uuid(hash);
+ _map["_hash"] = qpid::types::Uuid(hash);
}
-void ManagementAgent::SchemaClassKey::mapDecode(const qpid::messaging::Variant::Map& _map) {
- qpid::messaging::Variant::Map::const_iterator i;
+void ManagementAgent::SchemaClassKey::mapDecode(const Variant::Map& _map) {
+ Variant::Map::const_iterator i;
if ((i = _map.find("_cname")) != _map.end()) {
name = i->second.asString();
}
if ((i = _map.find("_hash")) != _map.end()) {
- const qpid::messaging::Uuid& uuid = i->second.asUuid();
+ const qpid::types::Uuid& uuid = i->second.asUuid();
memcpy(hash, uuid.data(), uuid.size());
}
}
@@ -2153,14 +2154,14 @@ uint32_t ManagementAgent::SchemaClassKey::encodedBufSize() const {
return 1 + name.size() + 16 /* bin128 */;
}
-void ManagementAgent::SchemaClass::mapEncode(qpid::messaging::Variant::Map& _map) const {
+void ManagementAgent::SchemaClass::mapEncode(Variant::Map& _map) const {
_map["_type"] = kind;
_map["_pending_sequence"] = pendingSequence;
_map["_data"] = data;
}
-void ManagementAgent::SchemaClass::mapDecode(const qpid::messaging::Variant::Map& _map) {
- qpid::messaging::Variant::Map::const_iterator i;
+void ManagementAgent::SchemaClass::mapDecode(const Variant::Map& _map) {
+ Variant::Map::const_iterator i;
if ((i = _map.find("_type")) != _map.end()) {
kind = i->second;
@@ -2176,8 +2177,8 @@ void ManagementAgent::SchemaClass::mapDecode(const qpid::messaging::Variant::Map
void ManagementAgent::exportSchemas(std::string& out) {
::qpid::messaging::Message m;
::qpid::messaging::ListContent content(m);
- ::qpid::messaging::Variant::List &list_ = content.asList();
- ::qpid::messaging::Variant::Map map_, kmap, cmap;
+ Variant::List &list_ = content.asList();
+ Variant::Map map_, kmap, cmap;
for (PackageMap::const_iterator i = packages.begin(); i != packages.end(); ++i) {
string name = i->first;
@@ -2218,7 +2219,7 @@ void ManagementAgent::importSchemas(qpid::framing::Buffer& inBuf) {
string package;
SchemaClassKey key;
SchemaClass klass;
- ::qpid::messaging::VariantMap map_, kmap, cmap;
+ VariantMap map_, kmap, cmap;
qpid::messaging::MapView::const_iterator i;
map_ = l->asMap();
@@ -2239,8 +2240,8 @@ void ManagementAgent::importSchemas(qpid::framing::Buffer& inBuf) {
}
}
-void ManagementAgent::RemoteAgent::mapEncode(qpid::messaging::Variant::Map& map_) const {
- ::qpid::messaging::VariantMap _objId, _values;
+void ManagementAgent::RemoteAgent::mapEncode(Variant::Map& map_) const {
+ VariantMap _objId, _values;
map_["_brokerBank"] = brokerBank;
map_["_agentBank"] = agentBank;
@@ -2253,7 +2254,7 @@ void ManagementAgent::RemoteAgent::mapEncode(qpid::messaging::Variant::Map& map_
map_["_values"] = _values;
}
-void ManagementAgent::RemoteAgent::mapDecode(const qpid::messaging::Variant::Map& map_) {
+void ManagementAgent::RemoteAgent::mapDecode(const Variant::Map& map_) {
qpid::messaging::MapView::const_iterator i;
if ((i = map_.find("_brokerBank")) != map_.end()) {
@@ -2285,8 +2286,8 @@ void ManagementAgent::RemoteAgent::mapDecode(const qpid::messaging::Variant::Map
void ManagementAgent::exportAgents(std::string& out) {
::qpid::messaging::Message m;
::qpid::messaging::ListContent content(m);
- ::qpid::messaging::Variant::List &list_ = content.asList();
- ::qpid::messaging::VariantMap map_, omap, amap;
+ Variant::List &list_ = content.asList();
+ VariantMap map_, omap, amap;
for (RemoteAgentMap::const_iterator i = remoteAgents.begin();
i != remoteAgents.end();
@@ -2315,7 +2316,7 @@ void ManagementAgent::importAgents(qpid::framing::Buffer& inBuf) {
for (l = content.begin(); l != content.end(); l++) {
std::auto_ptr<RemoteAgent> agent(new RemoteAgent(*this));
- ::qpid::messaging::VariantMap map_;
+ VariantMap map_;
qpid::messaging::MapView::const_iterator i;
map_ = l->asMap();
@@ -2342,9 +2343,9 @@ std::string ManagementAgent::debugSnapshot() {
return msg.str();
}
-qpid::messaging::Variant::Map ManagementAgent::toMap(const FieldTable& from)
+Variant::Map ManagementAgent::toMap(const FieldTable& from)
{
- qpid::messaging::Variant::Map map;
+ Variant::Map map;
for (FieldTable::const_iterator iter = from.begin(); iter != from.end(); iter++) {
const string& key(iter->first);
@@ -2356,9 +2357,9 @@ qpid::messaging::Variant::Map ManagementAgent::toMap(const FieldTable& from)
return map;
}
-qpid::messaging::Variant::List ManagementAgent::toList(const List& from)
+Variant::List ManagementAgent::toList(const List& from)
{
- qpid::messaging::Variant::List _list;
+ Variant::List _list;
for (List::const_iterator iter = from.begin(); iter != from.end(); iter++) {
const List::ValuePtr& val(*iter);
@@ -2369,15 +2370,15 @@ qpid::messaging::Variant::List ManagementAgent::toList(const List& from)
return _list;
}
-qpid::framing::FieldTable ManagementAgent::fromMap(const qpid::messaging::Variant::Map& from)
+qpid::framing::FieldTable ManagementAgent::fromMap(const Variant::Map& from)
{
qpid::framing::FieldTable ft;
- for (qpid::messaging::Variant::Map::const_iterator iter = from.begin();
+ for (Variant::Map::const_iterator iter = from.begin();
iter != from.end();
iter++) {
const string& key(iter->first);
- const qpid::messaging::Variant& val(iter->second);
+ const Variant& val(iter->second);
ft.set(key, toFieldValue(val));
}
@@ -2386,14 +2387,14 @@ qpid::framing::FieldTable ManagementAgent::fromMap(const qpid::messaging::Varian
}
-List ManagementAgent::fromList(const qpid::messaging::Variant::List& from)
+List ManagementAgent::fromList(const Variant::List& from)
{
List fa;
- for (qpid::messaging::Variant::List::const_iterator iter = from.begin();
+ for (Variant::List::const_iterator iter = from.begin();
iter != from.end();
iter++) {
- const qpid::messaging::Variant& val(*iter);
+ const Variant& val(*iter);
fa.push_back(toFieldValue(val));
}
@@ -2407,22 +2408,22 @@ boost::shared_ptr<FieldValue> ManagementAgent::toFieldValue(const Variant& in)
switch(in.getType()) {
- case messaging::VAR_VOID: return boost::shared_ptr<FieldValue>(new VoidValue());
- case messaging::VAR_BOOL: return boost::shared_ptr<FieldValue>(new BoolValue(in.asBool()));
- case messaging::VAR_UINT8: return boost::shared_ptr<FieldValue>(new Unsigned8Value(in.asUint8()));
- case messaging::VAR_UINT16: return boost::shared_ptr<FieldValue>(new Unsigned16Value(in.asUint16()));
- case messaging::VAR_UINT32: return boost::shared_ptr<FieldValue>(new Unsigned32Value(in.asUint32()));
- case messaging::VAR_UINT64: return boost::shared_ptr<FieldValue>(new Unsigned64Value(in.asUint64()));
- case messaging::VAR_INT8: return boost::shared_ptr<FieldValue>(new Integer8Value(in.asInt8()));
- case messaging::VAR_INT16: return boost::shared_ptr<FieldValue>(new Integer16Value(in.asInt16()));
- case messaging::VAR_INT32: return boost::shared_ptr<FieldValue>(new Integer32Value(in.asInt32()));
- case messaging::VAR_INT64: return boost::shared_ptr<FieldValue>(new Integer64Value(in.asInt64()));
- case messaging::VAR_FLOAT: return boost::shared_ptr<FieldValue>(new FloatValue(in.asFloat()));
- case messaging::VAR_DOUBLE: return boost::shared_ptr<FieldValue>(new DoubleValue(in.asDouble()));
- case messaging::VAR_STRING: return boost::shared_ptr<FieldValue>(new Str16Value(in.asString()));
- case messaging::VAR_UUID: return boost::shared_ptr<FieldValue>(new UuidValue(in.asUuid().data()));
- case messaging::VAR_MAP: return boost::shared_ptr<FieldValue>(new FieldTableValue(ManagementAgent::fromMap(in.asMap())));
- case messaging::VAR_LIST: return boost::shared_ptr<FieldValue>(new ListValue(ManagementAgent::fromList(in.asList())));
+ case types::VAR_VOID: return boost::shared_ptr<FieldValue>(new VoidValue());
+ case types::VAR_BOOL: return boost::shared_ptr<FieldValue>(new BoolValue(in.asBool()));
+ case types::VAR_UINT8: return boost::shared_ptr<FieldValue>(new Unsigned8Value(in.asUint8()));
+ case types::VAR_UINT16: return boost::shared_ptr<FieldValue>(new Unsigned16Value(in.asUint16()));
+ case types::VAR_UINT32: return boost::shared_ptr<FieldValue>(new Unsigned32Value(in.asUint32()));
+ case types::VAR_UINT64: return boost::shared_ptr<FieldValue>(new Unsigned64Value(in.asUint64()));
+ case types::VAR_INT8: return boost::shared_ptr<FieldValue>(new Integer8Value(in.asInt8()));
+ case types::VAR_INT16: return boost::shared_ptr<FieldValue>(new Integer16Value(in.asInt16()));
+ case types::VAR_INT32: return boost::shared_ptr<FieldValue>(new Integer32Value(in.asInt32()));
+ case types::VAR_INT64: return boost::shared_ptr<FieldValue>(new Integer64Value(in.asInt64()));
+ case types::VAR_FLOAT: return boost::shared_ptr<FieldValue>(new FloatValue(in.asFloat()));
+ case types::VAR_DOUBLE: return boost::shared_ptr<FieldValue>(new DoubleValue(in.asDouble()));
+ case types::VAR_STRING: return boost::shared_ptr<FieldValue>(new Str16Value(in.asString()));
+ case types::VAR_UUID: return boost::shared_ptr<FieldValue>(new UuidValue(in.asUuid().data()));
+ case types::VAR_MAP: return boost::shared_ptr<FieldValue>(new FieldTableValue(ManagementAgent::fromMap(in.asMap())));
+ case types::VAR_LIST: return boost::shared_ptr<FieldValue>(new ListValue(ManagementAgent::fromList(in.asList())));
}
QPID_LOG(error, "Unknown Variant type - not converted: [" << in.getType() << "]");
@@ -2430,7 +2431,7 @@ boost::shared_ptr<FieldValue> ManagementAgent::toFieldValue(const Variant& in)
}
// stolen from qpid/client/amqp0_10/Codecs.cpp - TODO: make Codecs public, and remove this dup.
-qpid::messaging::Variant ManagementAgent::toVariant(const boost::shared_ptr<FieldValue>& in)
+Variant ManagementAgent::toVariant(const boost::shared_ptr<FieldValue>& in)
{
const std::string iso885915("iso-8859-15");
const std::string utf8("utf8");
@@ -2475,7 +2476,7 @@ qpid::messaging::Variant ManagementAgent::toVariant(const boost::shared_ptr<Fiel
{
unsigned char data[16];
in->getFixedWidthValue<16>(data);
- out = qpid::messaging::Uuid(data);
+ out = qpid::types::Uuid(data);
} break;
//TODO: figure out whether and how to map values with codes 0x40-0xd8
diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.h b/qpid/cpp/src/qpid/management/ManagementAgent.h
index 913aa555a5..ab69ce0913 100644
--- a/qpid/cpp/src/qpid/management/ManagementAgent.h
+++ b/qpid/cpp/src/qpid/management/ManagementAgent.h
@@ -32,7 +32,7 @@
#include "qpid/management/ManagementEvent.h"
#include "qpid/management/Manageable.h"
#include "qmf/org/apache/qpid/broker/Agent.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include <qpid/framing/AMQFrame.h>
#include <qpid/framing/FieldValue.h>
#include <memory>
@@ -138,12 +138,12 @@ public:
void setBootSequence(uint16_t b) { bootSequence = b; }
// TODO: remove these when Variant API moved into common library.
- static messaging::Variant::Map toMap(const framing::FieldTable& from);
- static framing::FieldTable fromMap(const messaging::Variant::Map& from);
- static messaging::Variant::List toList(const framing::List& from);
- static framing::List fromList(const messaging::Variant::List& from);
- static boost::shared_ptr<framing::FieldValue> toFieldValue(const messaging::Variant& in);
- static messaging::Variant toVariant(const boost::shared_ptr<framing::FieldValue>& val);
+ static types::Variant::Map toMap(const framing::FieldTable& from);
+ static framing::FieldTable fromMap(const types::Variant::Map& from);
+ static types::Variant::List toList(const framing::List& from);
+ static framing::List fromList(const types::Variant::List& from);
+ static boost::shared_ptr<framing::FieldValue> toFieldValue(const types::Variant& in);
+ static types::Variant toVariant(const boost::shared_ptr<framing::FieldValue>& val);
private:
@@ -171,8 +171,8 @@ private:
ManagementObject* GetManagementObject (void) const { return mgmtObject; }
virtual ~RemoteAgent ();
- void mapEncode(qpid::messaging::Variant::Map& _map) const;
- void mapDecode(const qpid::messaging::Variant::Map& _map);
+ void mapEncode(qpid::types::Variant::Map& _map) const;
+ void mapDecode(const qpid::types::Variant::Map& _map);
};
// TODO: Eventually replace string with entire reply-to structure. reply-to
@@ -192,8 +192,8 @@ private:
std::string name;
uint8_t hash[16];
- void mapEncode(qpid::messaging::Variant::Map& _map) const;
- void mapDecode(const qpid::messaging::Variant::Map& _map);
+ void mapEncode(qpid::types::Variant::Map& _map) const;
+ void mapDecode(const qpid::types::Variant::Map& _map);
void encode(framing::Buffer& buffer) const;
void decode(framing::Buffer& buffer);
uint32_t encodedBufSize() const;
@@ -228,8 +228,8 @@ private:
bool hasSchema () { return (writeSchemaCall != 0) || !data.empty(); }
void appendSchema (framing::Buffer& buf);
- void mapEncode(qpid::messaging::Variant::Map& _map) const;
- void mapDecode(const qpid::messaging::Variant::Map& _map);
+ void mapEncode(qpid::types::Variant::Map& _map) const;
+ void mapDecode(const qpid::types::Variant::Map& _map);
};
typedef std::map<SchemaClassKey, SchemaClass, SchemaClassKeyComp> ClassMap;
@@ -283,7 +283,7 @@ private:
DisallowedMethods disallowed;
// Agent name and address
- qpid::messaging::Variant::Map attrMap;
+ qpid::types::Variant::Map attrMap;
std::string name_address;
// supported management protocol
@@ -307,7 +307,7 @@ private:
std::string routingKey);
void sendBuffer(const std::string& data,
const std::string& cid,
- const qpid::messaging::VariantMap& headers,
+ const qpid::types::VariantMap& headers,
qpid::broker::Exchange::shared_ptr exchange,
const std::string& routingKey);
void moveNewObjectsLH();
diff --git a/qpid/cpp/src/qpid/management/ManagementObject.cpp b/qpid/cpp/src/qpid/management/ManagementObject.cpp
index ee40ba9594..a51978d339 100644
--- a/qpid/cpp/src/qpid/management/ManagementObject.cpp
+++ b/qpid/cpp/src/qpid/management/ManagementObject.cpp
@@ -186,7 +186,7 @@ void ObjectId::setV2Key(const ManagementObject& object)
}
// encode as V2-format map
-void ObjectId::mapEncode(messaging::VariantMap& map) const
+void ObjectId::mapEncode(types::VariantMap& map) const
{
map["_object_name"] = v2Key;
if (!agentName.empty())
@@ -196,7 +196,7 @@ void ObjectId::mapEncode(messaging::VariantMap& map) const
}
// decode as v2-format map
-void ObjectId::mapDecode(const messaging::VariantMap& map)
+void ObjectId::mapDecode(const types::VariantMap& map)
{
messaging::MapView::const_iterator i;
@@ -213,9 +213,9 @@ void ObjectId::mapDecode(const messaging::VariantMap& map)
}
-ObjectId::operator messaging::VariantMap() const
+ObjectId::operator types::VariantMap() const
{
- messaging::VariantMap m;
+ types::VariantMap m;
mapEncode(m);
return m;
}
@@ -296,13 +296,13 @@ uint32_t ManagementObject::writeTimestampsSize() const
}
-void ManagementObject::writeTimestamps (messaging::VariantMap& map) const
+void ManagementObject::writeTimestamps (types::VariantMap& map) const
{
- messaging::VariantMap oid, sid;
+ types::VariantMap oid, sid;
sid["_package_name"] = getPackageName();
sid["_class_name"] = getClassName();
- sid["_hash"] = qpid::messaging::Uuid(getMd5Sum());
+ sid["_hash"] = qpid::types::Uuid(getMd5Sum());
map["_schema_id"] = sid;
objectId.mapEncode(oid);
@@ -313,7 +313,7 @@ void ManagementObject::writeTimestamps (messaging::VariantMap& map) const
map["_delete_ts"] = destroyTime;
}
-void ManagementObject::readTimestamps (const ::qpid::messaging::VariantMap& map)
+void ManagementObject::readTimestamps (const ::qpid::types::VariantMap& map)
{
messaging::MapView::const_iterator i;
@@ -340,11 +340,11 @@ int ManagementObject::getThreadIndex() {
}
-void ManagementObject::mapEncode(::qpid::messaging::VariantMap& map,
+void ManagementObject::mapEncode(::qpid::types::VariantMap& map,
bool includeProperties,
bool includeStatistics)
{
- messaging::VariantMap values;
+ types::VariantMap values;
writeTimestamps(map);
@@ -352,7 +352,7 @@ void ManagementObject::mapEncode(::qpid::messaging::VariantMap& map,
map["_values"] = values;
}
-void ManagementObject::mapDecode(const ::qpid::messaging::VariantMap& map)
+void ManagementObject::mapDecode(const ::qpid::types::VariantMap& map)
{
::qpid::messaging::MapView::const_iterator i;
diff --git a/qpid/cpp/src/qpid/messaging/Address.cpp b/qpid/cpp/src/qpid/messaging/Address.cpp
index a5d0671360..2902b8fc4b 100644
--- a/qpid/cpp/src/qpid/messaging/Address.cpp
+++ b/qpid/cpp/src/qpid/messaging/Address.cpp
@@ -26,6 +26,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
namespace {
const std::string SUBJECT_DIVIDER = "/";
const std::string OPTIONS_DIVIDER = ";";
diff --git a/qpid/cpp/src/qpid/messaging/AddressParser.cpp b/qpid/cpp/src/qpid/messaging/AddressParser.cpp
index 4b29f126f2..4f22410843 100644
--- a/qpid/cpp/src/qpid/messaging/AddressParser.cpp
+++ b/qpid/cpp/src/qpid/messaging/AddressParser.cpp
@@ -25,6 +25,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
AddressParser::AddressParser(const std::string& s) : input(s), current(0) {}
bool AddressParser::error(const std::string& message)
diff --git a/qpid/cpp/src/qpid/messaging/AddressParser.h b/qpid/cpp/src/qpid/messaging/AddressParser.h
index 801b5cead1..a3f41eb04d 100644
--- a/qpid/cpp/src/qpid/messaging/AddressParser.h
+++ b/qpid/cpp/src/qpid/messaging/AddressParser.h
@@ -31,8 +31,8 @@ class AddressParser
public:
AddressParser(const std::string&);
bool parse(Address& address);
- bool parseMap(Variant::Map& map);
- bool parseList(Variant::List& list);
+ bool parseMap(qpid::types::Variant::Map& map);
+ bool parseList(qpid::types::Variant::List& list);
private:
const std::string& input;
std::string::size_type current;
@@ -40,15 +40,15 @@ class AddressParser
bool readChar(char c);
bool readQuotedString(std::string& s);
- bool readQuotedValue(Variant& value);
+ bool readQuotedValue(qpid::types::Variant& value);
bool readString(std::string& value, char delimiter);
bool readWord(std::string& word, const std::string& delims = RESERVED);
- bool readSimpleValue(Variant& word);
+ bool readSimpleValue(qpid::types::Variant& word);
bool readKey(std::string& key);
- bool readValue(Variant& value);
- bool readKeyValuePair(Variant::Map& map);
- bool readMap(Variant& value);
- bool readList(Variant& value);
+ bool readValue(qpid::types::Variant& value);
+ bool readKeyValuePair(qpid::types::Variant::Map& map);
+ bool readMap(qpid::types::Variant& value);
+ bool readList(qpid::types::Variant& value);
bool readName(std::string& name);
bool readSubject(std::string& subject);
bool error(const std::string& message);
@@ -56,8 +56,8 @@ class AddressParser
bool iswhitespace();
bool in(const std::string& delims);
bool isreserved();
- void readListItems(Variant::List& list);
- void readMapEntries(Variant::Map& map);
+ void readListItems(qpid::types::Variant::List& list);
+ void readMapEntries(qpid::types::Variant::Map& map);
};
}} // namespace qpid::messaging
diff --git a/qpid/cpp/src/qpid/messaging/Connection.cpp b/qpid/cpp/src/qpid/messaging/Connection.cpp
index cb06af7693..853ba1d100 100644
--- a/qpid/cpp/src/qpid/messaging/Connection.cpp
+++ b/qpid/cpp/src/qpid/messaging/Connection.cpp
@@ -30,6 +30,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
typedef PrivateImplRef<qpid::messaging::Connection> PI;
Connection::Connection(ConnectionImpl* impl) { PI::ctor(*this, impl); }
diff --git a/qpid/cpp/src/qpid/messaging/ConnectionImpl.h b/qpid/cpp/src/qpid/messaging/ConnectionImpl.h
index 2f03c9610b..474f486736 100644
--- a/qpid/cpp/src/qpid/messaging/ConnectionImpl.h
+++ b/qpid/cpp/src/qpid/messaging/ConnectionImpl.h
@@ -25,10 +25,14 @@
#include "qpid/RefCounted.h"
namespace qpid {
+
+namespace types {
+class Variant;
+}
+
namespace messaging {
class Session;
-class Variant;
class ConnectionImpl : public virtual qpid::RefCounted
{
@@ -38,7 +42,7 @@ class ConnectionImpl : public virtual qpid::RefCounted
virtual void close() = 0;
virtual Session newSession(bool transactional, const std::string& name) = 0;
virtual Session getSession(const std::string& name) const = 0;
- virtual void setOption(const std::string& name, const Variant& value) = 0;
+ virtual void setOption(const std::string& name, const qpid::types::Variant& value) = 0;
private:
};
}} // namespace qpid::messaging
diff --git a/qpid/cpp/src/qpid/messaging/Duration.cpp b/qpid/cpp/src/qpid/messaging/Duration.cpp
new file mode 100644
index 0000000000..a2c443c746
--- /dev/null
+++ b/qpid/cpp/src/qpid/messaging/Duration.cpp
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "qpid/messaging/Duration.h"
+#include <limits>
+
+namespace qpid {
+namespace messaging {
+
+Duration::Duration(uint64_t ms) : milliseconds(ms) {}
+uint64_t Duration::getMilliseconds() const { return milliseconds; }
+
+Duration operator*(const Duration& duration, uint64_t multiplier)
+{
+ return Duration(duration.getMilliseconds() * multiplier);
+}
+
+Duration operator*(uint64_t multiplier, const Duration& duration)
+{
+ return Duration(duration.getMilliseconds() * multiplier);
+}
+
+const Duration Duration::FOREVER(std::numeric_limits<uint64_t>::max());
+const Duration Duration::IMMEDIATE(0);
+const Duration Duration::SECOND(1000);
+const Duration Duration::MINUTE(SECOND * 60);
+
+}} // namespace qpid::messaging
diff --git a/qpid/cpp/src/qpid/messaging/ListContent.cpp b/qpid/cpp/src/qpid/messaging/ListContent.cpp
index 038c1fad0b..4bd990e062 100644
--- a/qpid/cpp/src/qpid/messaging/ListContent.cpp
+++ b/qpid/cpp/src/qpid/messaging/ListContent.cpp
@@ -25,6 +25,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
class ListContentImpl : public Variant
{
Message* msg;
diff --git a/qpid/cpp/src/qpid/messaging/ListView.cpp b/qpid/cpp/src/qpid/messaging/ListView.cpp
index b717d157fa..5cf453254f 100644
--- a/qpid/cpp/src/qpid/messaging/ListView.cpp
+++ b/qpid/cpp/src/qpid/messaging/ListView.cpp
@@ -25,6 +25,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
class ListViewImpl : public Variant
{
public:
diff --git a/qpid/cpp/src/qpid/messaging/MapContent.cpp b/qpid/cpp/src/qpid/messaging/MapContent.cpp
index 1f190b85aa..11dcfbaf70 100644
--- a/qpid/cpp/src/qpid/messaging/MapContent.cpp
+++ b/qpid/cpp/src/qpid/messaging/MapContent.cpp
@@ -25,6 +25,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
class MapContentImpl : public Variant
{
Message* msg;
diff --git a/qpid/cpp/src/qpid/messaging/MapView.cpp b/qpid/cpp/src/qpid/messaging/MapView.cpp
index ffa6e91a16..8bb0a724d2 100644
--- a/qpid/cpp/src/qpid/messaging/MapView.cpp
+++ b/qpid/cpp/src/qpid/messaging/MapView.cpp
@@ -25,6 +25,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
class MapViewImpl : public Variant
{
public:
diff --git a/qpid/cpp/src/qpid/messaging/Message.cpp b/qpid/cpp/src/qpid/messaging/Message.cpp
index 4f8a358764..84245b7296 100644
--- a/qpid/cpp/src/qpid/messaging/Message.cpp
+++ b/qpid/cpp/src/qpid/messaging/Message.cpp
@@ -24,6 +24,8 @@
namespace qpid {
namespace messaging {
+using namespace qpid::types;
+
Message::Message(const std::string& bytes) : impl(new MessageImpl(bytes)) {}
Message::Message(const char* bytes, size_t count) : impl(new MessageImpl(bytes, count)) {}
@@ -50,16 +52,20 @@ const std::string& Message::getUserId() const { return impl->userId; }
void Message::setCorrelationId(const std::string& id) { impl->correlationId = id; }
const std::string& Message::getCorrelationId() const { return impl->correlationId; }
-void Message::setTtl(Duration ttl) { impl->ttl = ttl; }
-Duration Message::getTtl() const { return impl->ttl; }
+uint8_t Message::getPriority() const { return impl->priority; }
+void Message::setPriority(uint8_t priority) { impl->priority = priority; }
+
+void Message::setTtl(Duration ttl) { impl->ttl = ttl.getMilliseconds(); }
+Duration Message::getTtl() const { return Duration(impl->ttl); }
void Message::setDurable(bool durable) { impl->durable = durable; }
bool Message::getDurable() const { return impl->durable; }
-bool Message::isRedelivered() const { return impl->redelivered; }
+bool Message::getRedelivered() const { return impl->redelivered; }
+void Message::setRedelivered(bool redelivered) { impl->redelivered = redelivered; }
-const VariantMap& Message::getHeaders() const { return impl->getHeaders(); }
-VariantMap& Message::getHeaders() { return impl->getHeaders(); }
+const VariantMap& Message::getProperties() const { return impl->getHeaders(); }
+VariantMap& Message::getProperties() { return impl->getHeaders(); }
void Message::setContent(const std::string& c) { impl->setBytes(c); }
void Message::setContent(const char* chars, size_t count) { impl->setBytes(chars, count); }
diff --git a/qpid/cpp/src/qpid/messaging/MessageImpl.cpp b/qpid/cpp/src/qpid/messaging/MessageImpl.cpp
index 5d754ac487..dea6681244 100644
--- a/qpid/cpp/src/qpid/messaging/MessageImpl.cpp
+++ b/qpid/cpp/src/qpid/messaging/MessageImpl.cpp
@@ -28,13 +28,17 @@ namespace {
const std::string EMPTY_STRING = "";
}
+using namespace qpid::types;
+
MessageImpl::MessageImpl(const std::string& c) :
+ priority(0),
ttl(0),
durable(false),
redelivered(false),
bytes(c),
internalId(0) {}
MessageImpl::MessageImpl(const char* chars, size_t count) :
+ priority(0),
ttl(0),
durable (false),
redelivered(false),
diff --git a/qpid/cpp/src/qpid/messaging/MessageImpl.h b/qpid/cpp/src/qpid/messaging/MessageImpl.h
index bdbc1f6a1e..7793fc7943 100644
--- a/qpid/cpp/src/qpid/messaging/MessageImpl.h
+++ b/qpid/cpp/src/qpid/messaging/MessageImpl.h
@@ -22,7 +22,7 @@
*
*/
#include "qpid/messaging/Address.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/framing/SequenceNumber.h"
namespace qpid {
@@ -36,10 +36,11 @@ struct MessageImpl
std::string messageId;
std::string userId;
std::string correlationId;
+ uint8_t priority;
uint64_t ttl;
bool durable;
bool redelivered;
- Variant::Map headers;
+ qpid::types::Variant::Map headers;
std::string bytes;
@@ -57,8 +58,8 @@ struct MessageImpl
void setContentType(const std::string& s);
const std::string& getContentType() const;
- const Variant::Map& getHeaders() const;
- Variant::Map& getHeaders();
+ const qpid::types::Variant::Map& getHeaders() const;
+ qpid::types::Variant::Map& getHeaders();
void setBytes(const std::string& bytes);
void setBytes(const char* chars, size_t count);
diff --git a/qpid/cpp/src/qpid/messaging/Uuid.cpp b/qpid/cpp/src/qpid/types/Uuid.cpp
index 87eb34456f..9face4e5d2 100644
--- a/qpid/cpp/src/qpid/messaging/Uuid.cpp
+++ b/qpid/cpp/src/qpid/types/Uuid.cpp
@@ -18,14 +18,14 @@
* under the License.
*
*/
-#include "qpid/messaging/Uuid.h"
+#include "qpid/types/Uuid.h"
#include "qpid/sys/uuid.h"
#include <sstream>
#include <iostream>
#include <string.h>
namespace qpid {
-namespace messaging {
+namespace types {
using namespace std;
@@ -137,4 +137,4 @@ std::string Uuid::str() const
return os.str();
}
-}} // namespace qpid::messaging
+}} // namespace qpid::types
diff --git a/qpid/cpp/src/qpid/messaging/Variant.cpp b/qpid/cpp/src/qpid/types/Variant.cpp
index 2567b7508b..3729b6c947 100644
--- a/qpid/cpp/src/qpid/messaging/Variant.cpp
+++ b/qpid/cpp/src/qpid/types/Variant.cpp
@@ -18,7 +18,7 @@
* under the License.
*
*/
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "qpid/Msg.h"
#include "qpid/log/Statement.h"
#include <boost/format.hpp>
@@ -27,7 +27,7 @@
#include <sstream>
namespace qpid {
-namespace messaging {
+namespace types {
InvalidConversion::InvalidConversion(const std::string& msg) : Exception(msg) {}
@@ -687,4 +687,4 @@ bool Variant::isEqualTo(const Variant& other) const
return impl->isEqualTo(*other.impl);
}
-}} // namespace qpid::messaging
+}} // namespace qpid::types
diff --git a/qpid/cpp/src/tests/Address.cpp b/qpid/cpp/src/tests/Address.cpp
index f25a27d231..01d8683efe 100644
--- a/qpid/cpp/src/tests/Address.cpp
+++ b/qpid/cpp/src/tests/Address.cpp
@@ -20,11 +20,12 @@
*/
#include <iostream>
#include "qpid/messaging/Address.h"
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "unit_test.h"
using namespace qpid::messaging;
+using namespace qpid::types;
namespace qpid {
namespace tests {
diff --git a/qpid/cpp/src/tests/ClientMessage.cpp b/qpid/cpp/src/tests/ClientMessage.cpp
index ab1cf9d102..994c46552c 100644
--- a/qpid/cpp/src/tests/ClientMessage.cpp
+++ b/qpid/cpp/src/tests/ClientMessage.cpp
@@ -34,11 +34,11 @@ QPID_AUTO_TEST_CASE(testCopyConstructor)
{
Message m("my-data");
m.setSubject("my-subject");
- m.getHeaders()["a"] = "ABC";
+ m.getProperties()["a"] = "ABC";
Message c(m);
BOOST_CHECK_EQUAL(m.getContent(), c.getContent());
BOOST_CHECK_EQUAL(m.getSubject(), c.getSubject());
- BOOST_CHECK_EQUAL(m.getHeaders()["a"], c.getHeaders()["a"]);
+ BOOST_CHECK_EQUAL(m.getProperties()["a"], c.getProperties()["a"]);
}
QPID_AUTO_TEST_SUITE_END()
diff --git a/qpid/cpp/src/tests/ManagementTest.cpp b/qpid/cpp/src/tests/ManagementTest.cpp
index 58497eefcd..99b9c1f03e 100644
--- a/qpid/cpp/src/tests/ManagementTest.cpp
+++ b/qpid/cpp/src/tests/ManagementTest.cpp
@@ -56,7 +56,7 @@ QPID_AUTO_TEST_CASE(testObjectIdSerializeString) {
}
QPID_AUTO_TEST_CASE(testObjectIdEncode) {
- qpid::messaging::Variant::Map oidMap;
+ qpid::types::Variant::Map oidMap;
ObjectId oid(1, 2, 3, 9999);
oid.setV2Key("testkey");
diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp
index ef0685a508..d1f7441216 100644
--- a/qpid/cpp/src/tests/MessagingSessionTests.cpp
+++ b/qpid/cpp/src/tests/MessagingSessionTests.cpp
@@ -48,6 +48,7 @@ namespace tests {
QPID_AUTO_TEST_SUITE(MessagingSessionTests)
using namespace qpid::messaging;
+using namespace qpid::types;
using namespace qpid;
using qpid::broker::Broker;
using qpid::framing::Uuid;
@@ -130,7 +131,7 @@ struct MessagingFixture : public BrokerFixture
Message out(Uuid(true).str());
s.send(out);
Message in;
- BOOST_CHECK(r.fetch(in, 5*DURATION_SEC));
+ BOOST_CHECK(r.fetch(in, 5*Duration::SECOND));
BOOST_CHECK_EQUAL(out.getContent(), in.getContent());
r.close();
s.close();
@@ -196,7 +197,7 @@ struct MultiQueueFixture : MessagingFixture
}
};
-std::vector<std::string> fetch(Receiver& receiver, int count, Duration timeout=DURATION_SEC*5)
+std::vector<std::string> fetch(Receiver& receiver, int count, Duration timeout=Duration::SECOND*5)
{
std::vector<std::string> data;
Message message;
@@ -215,7 +216,7 @@ void send(Sender& sender, uint count = 1, uint start = 1, const std::string& bas
}
void receive(Receiver& receiver, uint count = 1, uint start = 1,
- const std::string& base = "Message", Duration timeout=DURATION_SEC*5)
+ const std::string& base = "Message", Duration timeout=Duration::SECOND*5)
{
for (uint i = start; i < start + count; ++i) {
BOOST_CHECK_EQUAL(receiver.fetch(timeout).getContent(), (boost::format("%1%_%2%") % base % i).str());
@@ -229,7 +230,7 @@ QPID_AUTO_TEST_CASE(testSimpleSendReceive)
Message out("test-message");
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(Duration::SECOND * 5);
fix.session.acknowledge();
BOOST_CHECK_EQUAL(in.getContent(), out.getContent());
}
@@ -240,15 +241,15 @@ QPID_AUTO_TEST_CASE(testSendReceiveHeaders)
Sender sender = fix.session.createSender(fix.queue);
Message out("test-message");
for (uint i = 0; i < 10; ++i) {
- out.getHeaders()["a"] = i;
+ out.getProperties()["a"] = i;
sender.send(out);
}
Receiver receiver = fix.session.createReceiver(fix.queue);
Message in;
for (uint i = 0; i < 10; ++i) {
- BOOST_CHECK(receiver.fetch(in, 5 * DURATION_SEC));
+ BOOST_CHECK(receiver.fetch(in, Duration::SECOND * 5));
BOOST_CHECK_EQUAL(in.getContent(), out.getContent());
- BOOST_CHECK_EQUAL(in.getHeaders()["a"].asUint32(), i);
+ BOOST_CHECK_EQUAL(in.getProperties()["a"].asUint32(), i);
fix.session.acknowledge();
}
}
@@ -300,7 +301,7 @@ QPID_AUTO_TEST_CASE(testSimpleTopic)
BOOST_CHECK_EQUAL(fetch(sub1, 4), boost::assign::list_of<std::string>("two")("three")("four")("five"));
BOOST_CHECK_EQUAL(fetch(sub3, 2), boost::assign::list_of<std::string>("four")("five"));
Message in;
- BOOST_CHECK(!sub2.fetch(in, 0));//TODO: or should this raise an error?
+ BOOST_CHECK(!sub2.fetch(in, Duration::IMMEDIATE));//TODO: or should this raise an error?
//TODO: check pending messages...
@@ -323,7 +324,7 @@ QPID_AUTO_TEST_CASE(testNextReceiver)
for (uint i = 0; i < fix.queues.size(); i++) {
Message msg;
- BOOST_CHECK(fix.session.nextReceiver().fetch(msg, DURATION_SEC));
+ BOOST_CHECK(fix.session.nextReceiver().fetch(msg, Duration::SECOND));
BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("Message_%1%") % (i+1)).str());
}
}
@@ -345,7 +346,7 @@ QPID_AUTO_TEST_CASE(testMapMessage)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(5 * Duration::SECOND);
MapView view(in);
BOOST_CHECK_EQUAL(view["abc"].asString(), "def");
BOOST_CHECK_EQUAL(view["pi"].asFloat(), 3.14f);
@@ -368,7 +369,7 @@ QPID_AUTO_TEST_CASE(testMapMessageWithInitial)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(5 * Duration::SECOND);
MapView view(in);
BOOST_CHECK_EQUAL(view["abc"].asString(), "def");
BOOST_CHECK_EQUAL(view["pi"].asFloat(), 3.14f);
@@ -388,7 +389,7 @@ QPID_AUTO_TEST_CASE(testListMessage)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(5 * Duration::SECOND);
ListView view(in);
BOOST_CHECK_EQUAL(view.size(), content.size());
BOOST_CHECK_EQUAL(view.front().asString(), "abc");
@@ -422,7 +423,7 @@ QPID_AUTO_TEST_CASE(testListMessageWithInitial)
content.encode();
sender.send(out);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(5 * Duration::SECOND);
ListView view(in);
BOOST_CHECK_EQUAL(view.size(), content.size());
BOOST_CHECK_EQUAL(view.front().asString(), "abc");
@@ -451,10 +452,10 @@ QPID_AUTO_TEST_CASE(testReject)
Message m2("accept-me");
sender.send(m2);
Receiver receiver = fix.session.createReceiver(fix.queue);
- Message in = receiver.fetch(5 * DURATION_SEC);
+ Message in = receiver.fetch(5 * Duration::SECOND);
BOOST_CHECK_EQUAL(in.getContent(), m1.getContent());
fix.session.reject(in);
- in = receiver.fetch(5 * DURATION_SEC);
+ in = receiver.fetch(5 * Duration::SECOND);
BOOST_CHECK_EQUAL(in.getContent(), m2.getContent());
fix.session.acknowledge();
}
@@ -833,17 +834,17 @@ QPID_AUTO_TEST_CASE(testTx)
send(sender2, 5, 1, "B");
ssn2.commit();
receive(receiver1, 5, 1, "B");//(only those from sender2 should be received)
- BOOST_CHECK(!receiver1.fetch(in, 0));//check there are no more messages
+ BOOST_CHECK(!receiver1.fetch(in, Duration::IMMEDIATE));//check there are no more messages
ssn1.rollback();
receive(receiver2, 5, 1, "B");
- BOOST_CHECK(!receiver2.fetch(in, 0));//check there are no more messages
+ BOOST_CHECK(!receiver2.fetch(in, Duration::IMMEDIATE));//check there are no more messages
ssn2.rollback();
receive(receiver1, 5, 1, "B");
- BOOST_CHECK(!receiver1.fetch(in, 0));//check there are no more messages
+ BOOST_CHECK(!receiver1.fetch(in, Duration::IMMEDIATE));//check there are no more messages
ssn1.commit();
//check neither receiver gets any more messages:
- BOOST_CHECK(!receiver1.fetch(in, 0));
- BOOST_CHECK(!receiver2.fetch(in, 0));
+ BOOST_CHECK(!receiver1.fetch(in, Duration::IMMEDIATE));
+ BOOST_CHECK(!receiver2.fetch(in, Duration::IMMEDIATE));
}
QPID_AUTO_TEST_SUITE_END()
diff --git a/qpid/cpp/src/tests/Uuid.cpp b/qpid/cpp/src/tests/Uuid.cpp
index 6d6c07169f..4c6505b139 100644
--- a/qpid/cpp/src/tests/Uuid.cpp
+++ b/qpid/cpp/src/tests/Uuid.cpp
@@ -18,7 +18,7 @@
#include "qpid/framing/Uuid.h"
#include "qpid/framing/Buffer.h"
-#include "qpid/messaging/Uuid.h"
+#include "qpid/types/Uuid.h"
#include "qpid/sys/alloca.h"
#include "unit_test.h"
@@ -80,15 +80,15 @@ QPID_AUTO_TEST_CASE(testUuidEncodeDecode) {
string(decoded.begin(), decoded.end()));
}
-QPID_AUTO_TEST_CASE(testMessagingUuid)
+QPID_AUTO_TEST_CASE(testTypesUuid)
{
- //tests for the Uuid class in the messaging namespace (introduced
+ //tests for the Uuid class in the types namespace (introduced
//to avoid pulling in dependencies from framing)
- messaging::Uuid a;
- messaging::Uuid b(true);
- messaging::Uuid c(true);
- messaging::Uuid d(b);
- messaging::Uuid e;
+ types::Uuid a;
+ types::Uuid b(true);
+ types::Uuid c(true);
+ types::Uuid d(b);
+ types::Uuid e;
e = c;
BOOST_CHECK(!a);
diff --git a/qpid/cpp/src/tests/Variant.cpp b/qpid/cpp/src/tests/Variant.cpp
index db9e419eab..0d456bc493 100644
--- a/qpid/cpp/src/tests/Variant.cpp
+++ b/qpid/cpp/src/tests/Variant.cpp
@@ -19,11 +19,11 @@
*
*/
#include <iostream>
-#include "qpid/messaging/Variant.h"
+#include "qpid/types/Variant.h"
#include "unit_test.h"
-using namespace qpid::messaging;
+using namespace qpid::types;
namespace qpid {
namespace tests {
diff --git a/qpid/cpp/src/tests/qpid_recv.cpp b/qpid/cpp/src/tests/qpid_recv.cpp
index 10738578ed..0a268ad6cf 100644
--- a/qpid/cpp/src/tests/qpid_recv.cpp
+++ b/qpid/cpp/src/tests/qpid_recv.cpp
@@ -34,6 +34,7 @@
#include <memory>
using namespace qpid::messaging;
+using namespace qpid::types;
using qpid::client::amqp0_10::FailoverUpdates;
using namespace std;
@@ -95,8 +96,8 @@ struct Options : public qpid::Options
Duration getTimeout()
{
- if (forever) return INFINITE_DURATION;
- else return timeout*DURATION_SEC;
+ if (forever) return Duration::FOREVER;
+ else return Duration::SECOND*timeout;
}
bool parse(int argc, char** argv)
@@ -130,7 +131,7 @@ class SequenceTracker
bool isDuplicate(Message& message)
{
- uint sn = message.getHeaders()["sn"];
+ uint sn = message.getProperties()["sn"];
if (lastSn < sn) {
lastSn = sn;
return false;
@@ -172,10 +173,10 @@ int main(int argc, char ** argv)
if (msg.getReplyTo()) std::cout << "ReplyTo: " << msg.getReplyTo() << std::endl;
if (msg.getCorrelationId().size()) std::cout << "CorrelationId: " << msg.getCorrelationId() << std::endl;
if (msg.getUserId().size()) std::cout << "UserId: " << msg.getUserId() << std::endl;
- if (msg.getTtl()) std::cout << "TTL: " << msg.getTtl() << std::endl;
+ if (msg.getTtl().getMilliseconds()) std::cout << "TTL: " << msg.getTtl().getMilliseconds() << std::endl;
if (msg.getDurable()) std::cout << "Durable: true" << std::endl;
- if (msg.isRedelivered()) std::cout << "Redelivered: true" << std::endl;
- std::cout << "Headers: " << msg.getHeaders() << std::endl;
+ if (msg.getRedelivered()) std::cout << "Redelivered: true" << std::endl;
+ std::cout << "Properties: " << msg.getProperties() << std::endl;
std::cout << std::endl;
}
std::cout << msg.getContent() << std::endl;//TODO: handle map or list messages
diff --git a/qpid/cpp/src/tests/qpid_send.cpp b/qpid/cpp/src/tests/qpid_send.cpp
index a8b0241a1d..564007958e 100644
--- a/qpid/cpp/src/tests/qpid_send.cpp
+++ b/qpid/cpp/src/tests/qpid_send.cpp
@@ -33,6 +33,7 @@
#include <memory>
using namespace qpid::messaging;
+using namespace qpid::types;
using qpid::client::amqp0_10::FailoverUpdates;
typedef std::vector<std::string> string_vector;
@@ -144,9 +145,9 @@ struct Options : public qpid::Options
std::string name;
std::string value;
if (nameval(property, name, value)) {
- message.getHeaders()[name] = value;
+ message.getProperties()[name] = value;
} else {
- message.getHeaders()[name] = Variant();
+ message.getProperties()[name] = Variant();
}
}
@@ -191,7 +192,7 @@ int main(int argc, char ** argv)
Message msg;
msg.setDurable(opts.durable);
if (opts.ttl) {
- msg.setTtl(opts.ttl);
+ msg.setTtl(Duration(opts.ttl));
}
if (!opts.replyto.empty()) msg.setReplyTo(Address(opts.replyto));
if (!opts.userid.empty()) msg.setUserId(opts.userid);
@@ -202,7 +203,7 @@ int main(int argc, char ** argv)
uint txCount = 0;
while (getline(std::cin, content)) {
msg.setContent(content);
- msg.getHeaders()["sn"] = ++sent;
+ msg.getProperties()["sn"] = ++sent;
sender.send(msg);
if (opts.tx && (sent % opts.tx == 0)) {
if (opts.rollbackFrequency && (++txCount % opts.rollbackFrequency == 0)) {
@@ -213,7 +214,7 @@ int main(int argc, char ** argv)
}
}
for (uint i = opts.sendEos; i > 0; --i) {
- msg.getHeaders()["sn"] = ++sent;
+ msg.getProperties()["sn"] = ++sent;
msg.setContent(EOS);//TODO: add in ability to send digest or similar
sender.send(msg);
}
diff --git a/qpid/cpp/src/tests/qpid_stream.cpp b/qpid/cpp/src/tests/qpid_stream.cpp
index 5ed7f84492..642b7a821f 100644
--- a/qpid/cpp/src/tests/qpid_stream.cpp
+++ b/qpid/cpp/src/tests/qpid_stream.cpp
@@ -32,6 +32,7 @@
#include <string>
using namespace qpid::messaging;
+using namespace qpid::types;
namespace qpid {
namespace tests {
@@ -118,7 +119,7 @@ struct Publish : Client
qpid::sys::AbsTime start = qpid::sys::now();
while (true) {
qpid::sys::AbsTime sentAt = qpid::sys::now();
- msg.getHeaders()[TIMESTAMP] = timestamp(sentAt);
+ msg.getProperties()[TIMESTAMP] = timestamp(sentAt);
sender.send(msg);
++sent;
qpid::sys::AbsTime waitTill(start, sent*interval);
@@ -150,7 +151,7 @@ struct Consume : Client
}
//calculate latency
uint64_t receivedAt = timestamp(qpid::sys::now());
- uint64_t sentAt = msg.getHeaders()[TIMESTAMP].asUint64();
+ uint64_t sentAt = msg.getProperties()[TIMESTAMP].asUint64();
double latency = ((double) (receivedAt - sentAt)) / qpid::sys::TIME_MSEC;
//update avg, min & max
diff --git a/qpid/extras/qmf/LICENSE.txt b/qpid/extras/qmf/LICENSE.txt
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/qpid/extras/qmf/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git a/qpid/extras/qmf/NOTICE.txt b/qpid/extras/qmf/NOTICE.txt
new file mode 100644
index 0000000000..32ccdb70c4
--- /dev/null
+++ b/qpid/extras/qmf/NOTICE.txt
@@ -0,0 +1,20 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Qpid distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
+
+Aside from contributions to the Apache Qpid project, this software also
+includes (binary only):
+
+ - None at this time
+
+
+
diff --git a/qpid/extras/qmf/src/py/qmf/console.py b/qpid/extras/qmf/src/py/qmf/console.py
index e598068262..3d32ae36f7 100644
--- a/qpid/extras/qmf/src/py/qmf/console.py
+++ b/qpid/extras/qmf/src/py/qmf/console.py
@@ -988,15 +988,7 @@ class Session:
data = Object(self, broker, schema, codec, True, True, False)
else:
data = self._decodeValue(codec, inner_type_code, broker)
- elif typecode == 21: # List
- #taken from codec10.read_list
- sc = Codec(codec.read_vbin32())
- count = sc.read_uint32()
- data = []
- while count > 0:
- type = sc.read_uint8()
- data.append(self._decodeValue(sc,type,broker))
- count -= 1
+ elif typecode == 21: data = codec.read_list() # List
elif typecode == 22: #Array
#taken from codec10.read_array
sc = Codec(codec.read_vbin32())
@@ -1032,14 +1024,7 @@ class Session:
elif typecode == 19: codec.write_int64 (int(value)) # S64
elif typecode == 20: value._encodeUnmanaged(codec) # OBJECT
elif typecode == 15: codec.write_map (value) # FTABLE
- elif typecode == 21: # List
- sc = Codec()
- self._encodeValue(sc, len(value), 3)
- for o in value:
- ltype=self.encoding(o)
- self._encodeValue(sc,ltype,1)
- self._encodeValue(sc, o, ltype)
- codec.write_vbin32(sc.encoded)
+ elif typecode == 21: codec.write_list (value) # List
elif typecode == 22: # Array
sc = Codec()
self._encodeValue(sc, len(value), 3)
@@ -1635,7 +1620,7 @@ class ObjectId:
else:
first = constructor.read_uint64()
second = constructor.read_uint64()
- self.agentName = str((first & 0x000000000FFFFFFF) >> 28)
+ self.agentName = str(first & 0x000000000FFFFFFF)
self.agentEpoch = (first & 0x0FFF000000000000) >> 48
self.objectName = str(second)
@@ -2008,7 +1993,7 @@ class Broker:
raise
def _updateAgent(self, obj):
- bankKey = obj.agentBank
+ bankKey = str(obj.agentBank)
agent = None
if obj._deleteTime == 0:
try:
@@ -2166,6 +2151,12 @@ class Broker:
self.cv.release()
def _v1Cb(self, msg):
+ try:
+ self._v1CbProtected(msg)
+ except Exception, e:
+ print "EXCEPTION in Broker._v1Cb:", e
+
+ def _v1CbProtected(self, msg):
"""
This is the general message handler for messages received via the QMFv1 exchanges.
"""
@@ -2187,7 +2178,7 @@ class Broker:
items = rkey.split('.')
if len(items) >= 4:
if items[0] == 'console' and items[3].isdigit():
- agent_addr = int(items[3]) # The QMFv1 Agent Bank
+ agent_addr = str(items[3]) # The QMFv1 Agent Bank
if agent_addr != None and agent_addr in self.agents:
agent = self.agents[agent_addr]
@@ -2286,7 +2277,7 @@ class Agent:
self.session = broker.session
self.schemaCache = self.session.schemaCache
self.brokerBank = broker.getBrokerBank()
- self.agentBank = agentBank
+ self.agentBank = str(agentBank)
self.label = label
self.isV2 = isV2
self.heartbeatInterval = interval
@@ -2310,9 +2301,12 @@ class Agent:
if 'qmf_object' in kwargs:
if self.session.console:
self.session.console.objectProps(self.broker, kwargs['qmf_object'])
- if 'qmf_object_stats' in kwargs:
+ elif 'qmf_object_stats' in kwargs:
if self.session.console:
self.session.console.objectStats(self.broker, kwargs['qmf_object_stats'])
+ elif 'qmf_event' in kwargs:
+ if self.session.console:
+ self.session.console.event(self.broker, kwargs['qmf_event'])
def touch(self):
@@ -2521,7 +2515,8 @@ class Agent:
"""
Handle a QMFv1 event indication
"""
- pass
+ event = Event(self, codec)
+ self.unsolicitedContext.doEvent(event)
def _v1HandleContentInd(self, codec, sequence, prop=False, stat=False):
@@ -2808,6 +2803,11 @@ class RequestContext(object):
self.rawQueryResults.append(data)
+ def doEvent(self, data):
+ if self.notifiable:
+ self.notifiable(qmf_event=data)
+
+
def setException(self, ex):
self.exception = ex
@@ -2942,18 +2942,19 @@ class RequestContext(object):
#===================================================================================================
class Event:
""" """
- def __init__(self, session, broker, codec):
- self.session = session
- self.broker = broker
+ def __init__(self, agent, codec):
+ self.agent = agent
+ self.session = agent.session
+ self.broker = agent.broker
self.classKey = ClassKey(codec)
self.timestamp = codec.read_int64()
self.severity = codec.read_uint8()
- self.schema = session.schemaCache.getSchema(self.classKey)
+ self.arguments = {}
+ self.schema = self.session.schemaCache.getSchema(self.classKey)
if not self.schema:
return
- self.arguments = {}
for arg in self.schema.arguments:
- self.arguments[arg.name] = session._decodeValue(codec, arg.type, broker)
+ self.arguments[arg.name] = self.session._decodeValue(codec, arg.type, self.broker)
def __repr__(self):
if self.schema == None:
diff --git a/qpid/java/broker/build.xml b/qpid/java/broker/build.xml
index 6902049435..2401978381 100644
--- a/qpid/java/broker/build.xml
+++ b/qpid/java/broker/build.xml
@@ -52,7 +52,7 @@
<mkdir dir="${velocity.compile.dir}" />
<!-- Compile LogMessages Velocity Generator -->
<javac source="${java.source}" target="${java.target}"
- destdir="${velocity.compile.dir}" debug="on"
+ destdir="${velocity.compile.dir}" debug="on" includeantruntime="false"
deprecation="${javac.deprecation}"
srcdir="src/velocity/java" >
<classpath>
diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml
index 8fb3a8cf5a..fd5d84a1e8 100644
--- a/qpid/java/broker/etc/config.xml
+++ b/qpid/java/broker/etc/config.xml
@@ -23,6 +23,7 @@
<prefix>${QPID_HOME}</prefix>
<work>${QPID_WORK}</work>
<conf>${prefix}/etc</conf>
+
<connector>
<!-- To enable SSL edit the keystorePath and keystorePassword
and set enabled to true.
@@ -92,145 +93,8 @@
</jmx>
</security>
- <virtualhosts>
-
- <default>test</default>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <housekeeping>
- <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
- </housekeeping>
-
- <exchanges>
- <exchange>
- <type>direct</type>
- <name>test.direct</name>
- <durable>true</durable>
- </exchange>
- <exchange>
- <type>topic</type>
- <name>test.topic</name>
- </exchange>
- </exchanges>
- <queues>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- <maximumMessageCount>50</maximumMessageCount>
- <!-- 50 messages -->
-
- <queue>
- <name>queue</name>
- </queue>
- <queue>
- <name>ping</name>
- </queue>
- <queue>
- <name>test-queue</name>
- <test-queue>
- <exchange>test.direct</exchange>
- <durable>true</durable>
- </test-queue>
- </queue>
- <queue>
- <name>test-ping</name>
- <test-ping>
- <exchange>test.direct</exchange>
- </test-ping>
- </queue>
-
- </queues>
- </localhost>
- </virtualhost>
-
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <queues>
- <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
- <maximumMessageCount>50</maximumMessageCount>
- <queue>
- <name>queue</name>
- <queue>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </queue>
- </queue>
- <queue>
- <name>ping</name>
- <ping>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </ping>
- </queue>
- </queues>
- </development>
- </virtualhost>
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
-
- <queues>
- <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
- <maximumMessageCount>50</maximumMessageCount>
- <queue>
- <name>queue</name>
- <queue>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </queue>
- </queue>
- <queue>
- <name>ping</name>
- <ping>
- <exchange>amq.direct</exchange>
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 4Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 2Mb -->
- <maximumMessageAge>600000</maximumMessageAge>
- <!-- 10 mins -->
- </ping>
- </queue>
- </queues>
- </test>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/broker/etc/persistent_config.xml b/qpid/java/broker/etc/persistent_config.xml
deleted file mode 100644
index 67ef28117d..0000000000
--- a/qpid/java/broker/etc/persistent_config.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- -
- - 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.
- -
-
- This is an example config using the BDBMessageStore available from
- the Red Hat Messaging project at etp.108.redhat.com and distributed under GPL.
- -->
-
-<broker>
- <prefix>${QPID_HOME}</prefix>
- <work>${QPID_WORK}</work>
- <conf>${prefix}/etc</conf>
- <connector>
- <transport>nio</transport>
- <port>5672</port>
- <sslport>8672</sslport>
- <socketReceiveBuffer>32768</socketReceiveBuffer>
- <socketSendBuffer>32768</socketSendBuffer>
- </connector>
- <management>
- <enabled>true</enabled>
- <jmxport>8999</jmxport>
- <ssl>
- <enabled>true</enabled>
- <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore -->
- <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath>
- <keyStorePassword>password</keyStorePassword>
- </ssl>
- </management>
- <advanced>
- <filterchain enableExecutorPool="true"/>
- <enablePooledAllocator>false</enablePooledAllocator>
- <enableDirectBuffers>false</enableDirectBuffers>
- <framesize>65535</framesize>
- <compressBufferOnQueue>false</compressBufferOnQueue>
- </advanced>
-
- <security>
- <principal-databases>
- <principal-database>
- <name>passwordfile</name>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${conf}/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </principal-databases>
-
- <access>
- <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
- </access>
- <jmx>
- <access>${conf}/jmxremote.access</access>
- <principal-database>passwordfile</principal-database>
- </jmx>
- </security>
-
- <virtualhosts>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/localhost-store</environment-path>
- </store>
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/development-store</environment-path>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdbstore/test-store</environment-path>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
- <heartbeat>
- <delay>0</delay>
- <timeoutFactor>2.0</timeoutFactor>
- </heartbeat>
- <queue>
- <auto_register>true</auto_register>
- </queue>
-
- <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
-</broker>
-
-
diff --git a/qpid/java/broker/etc/transient_config.xml b/qpid/java/broker/etc/transient_config.xml
deleted file mode 100644
index a21afe7d21..0000000000
--- a/qpid/java/broker/etc/transient_config.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- -
- - 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.
- -
-
- This is an example config file that uses the MemoryMessageStore.
- As a result it is aimed at brokers sending transient messages.
-
- -->
-<broker>
- <prefix>${QPID_HOME}</prefix>
- <work>${QPID_WORK}</work>
- <conf>${prefix}/etc</conf>
- <connector>
- <transport>nio</transport>
- <port>5672</port>
- <sslport>8672</sslport>
- <socketReceiveBuffer>32768</socketReceiveBuffer>
- <socketSendBuffer>32768</socketSendBuffer>
- </connector>
- <management>
- <enabled>true</enabled>
- <jmxport>8999</jmxport>
- <ssl>
- <enabled>true</enabled>
- <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore -->
- <keyStorePath>${prefix}/../test_resources/ssl/keystore.jks</keyStorePath>
- <keyStorePassword>password</keyStorePassword>
- </ssl>
- </management>
- <advanced>
- <filterchain enableExecutorPool="true"/>
- <enablePooledAllocator>false</enablePooledAllocator>
- <enableDirectBuffers>false</enableDirectBuffers>
- <framesize>65535</framesize>
- <compressBufferOnQueue>false</compressBufferOnQueue>
- </advanced>
-
- <security>
- <principal-databases>
- <principal-database>
- <name>passwordfile</name>
- <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
- <attributes>
- <attribute>
- <name>passwordFile</name>
- <value>${conf}/passwd</value>
- </attribute>
- </attributes>
- </principal-database>
- </principal-databases>
-
- <access>
- <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
- </access>
- <jmx>
- <access>${conf}/jmxremote.access</access>
- <principal-database>passwordfile</principal-database>
- </jmx>
- </security>
-
- <virtualhosts>
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
- <heartbeat>
- <delay>0</delay>
- <timeoutFactor>2.0</timeoutFactor>
- </heartbeat>
- <queue>
- <auto_register>true</auto_register>
- </queue>
-
- <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
-</broker>
-
-
diff --git a/qpid/java/broker/etc/virtualhosts.xml b/qpid/java/broker/etc/virtualhosts.xml
new file mode 100644
index 0000000000..4bc6956e5a
--- /dev/null
+++ b/qpid/java/broker/etc/virtualhosts.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+ <virtualhost>
+ <name>localhost</name>
+ <localhost>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <housekeeping>
+ <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
+ </housekeeping>
+
+ <exchanges>
+ <exchange>
+ <type>direct</type>
+ <name>test.direct</name>
+ <durable>true</durable>
+ </exchange>
+ <exchange>
+ <type>topic</type>
+ <name>test.topic</name>
+ </exchange>
+ </exchanges>
+ <queues>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ <maximumMessageCount>50</maximumMessageCount>
+ <!-- 50 messages -->
+
+ <queue>
+ <name>queue</name>
+ </queue>
+ <queue>
+ <name>ping</name>
+ </queue>
+ <queue>
+ <name>test-queue</name>
+ <test-queue>
+ <exchange>test.direct</exchange>
+ <durable>true</durable>
+ </test-queue>
+ </queue>
+ <queue>
+ <name>test-ping</name>
+ <test-ping>
+ <exchange>test.direct</exchange>
+ </test-ping>
+ </queue>
+
+ </queues>
+ </localhost>
+ </virtualhost>
+
+
+ <virtualhost>
+ <name>development</name>
+ <development>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <queues>
+ <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+ <maximumMessageCount>50</maximumMessageCount>
+ <queue>
+ <name>queue</name>
+ <queue>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </queue>
+ </queue>
+ <queue>
+ <name>ping</name>
+ <ping>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </ping>
+ </queue>
+ </queues>
+ </development>
+ </virtualhost>
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+
+ <queues>
+ <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+ <maximumMessageCount>50</maximumMessageCount>
+ <queue>
+ <name>queue</name>
+ <queue>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </queue>
+ </queue>
+ <queue>
+ <name>ping</name>
+ <ping>
+ <exchange>amq.direct</exchange>
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 4Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 2Mb -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ <!-- 10 mins -->
+ </ping>
+ </queue>
+ </queues>
+ </test>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
index 879eb7c9e6..edf88f9b5a 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
@@ -21,18 +21,19 @@
package org.apache.qpid.server.configuration;
import java.io.File;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Locale;
-import java.util.Collections;
+import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationFactory;
+import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
@@ -52,18 +53,17 @@ public class ServerConfiguration implements SignalHandler
private Configuration _config;
// Default Configuration values
- //todo make these all public, to make validation of configuration easier.
public static final int DEFAULT_BUFFER_READ_LIMIT_SIZE = 262144;
public static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
public static final boolean DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED = false;
public static final String DEFAULT_STATUS_UPDATES = "on";
public static final String SECURITY_CONFIG_RELOADED = "SECURITY CONFIGURATION RELOADED";
- private static final int DEFAULT_FRAME_SIZE = 65536;
- private static final int DEFAULT_PORT = 5672;
- private static final int DEFAUL_SSL_PORT = 8672;
- private static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
- private static final int DEFAULT_JMXPORT = 8999;
+ public static final int DEFAULT_FRAME_SIZE = 65536;
+ public static final int DEFAULT_PORT = 5672;
+ public static final int DEFAULT_SSL_PORT = 8672;
+ public static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
+ public static final int DEFAULT_JMXPORT = 8999;
private static int _jmxPort = DEFAULT_JMXPORT;
@@ -71,6 +71,7 @@ public class ServerConfiguration implements SignalHandler
private SecurityConfiguration _securityConfiguration = null;
private File _configFile;
+ private File _vhostsFile;
private Logger _log = LoggerFactory.getLogger(this.getClass());
@@ -134,8 +135,6 @@ public class ServerConfiguration implements SignalHandler
{
setConfig(conf);
- substituteEnvironmentVariables();
-
_jmxPort = getConfig().getInt("management.jmxport", 8999);
_securityConfiguration = new SecurityConfiguration(conf.subset("security"));
@@ -143,61 +142,86 @@ public class ServerConfiguration implements SignalHandler
}
- private void setupVirtualHosts(Configuration conf) throws ConfigurationException
+ /*
+ * Modified to enforce virtualhosts configuration in external file or main file, but not
+ * both, as a fix for QPID-2360 and QPID-2361.
+ */
+ @SuppressWarnings("unchecked")
+ private void setupVirtualHosts(Configuration conf) throws ConfigurationException
{
- List vhosts = conf.getList("virtualhosts");
- Iterator i = vhosts.iterator();
- while (i.hasNext())
+ List<String> vhostFiles = conf.getList("virtualhosts");
+ Configuration vhostConfig = conf.subset("virtualhosts");
+
+ // Only one configuration mechanism allowed
+ if (!vhostFiles.isEmpty() && !vhostConfig.subset("virtualhost").isEmpty())
{
- Object thing = i.next();
- if (thing instanceof String)
- {
- //Open the Virtualhost.xml file and copy values in to main config
- XMLConfiguration vhostConfiguration = new XMLConfiguration((String) thing);
- Iterator keys = vhostConfiguration.getKeys();
- while (keys.hasNext())
- {
- String key = (String) keys.next();
- conf.setProperty("virtualhosts." + key, vhostConfiguration.getProperty(key));
- }
- }
+ throw new ConfigurationException("Only one of external or embedded virtualhosts configuration allowed.");
+ }
+
+ // We can only have one vhosts XML file included
+ if (vhostFiles.size() > 1)
+ {
+ throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
+ }
+
+ // Virtualhost configuration object
+ Configuration vhostConfiguration = new HierarchicalConfiguration();
+
+ // Load from embedded configuration if possible
+ if (!vhostConfig.subset("virtualhost").isEmpty())
+ {
+ vhostConfiguration = vhostConfig;
}
-
- List hosts = conf.getList("virtualhosts.virtualhost.name");
+ else
+ {
+ // Load from the external configuration if possible
+ for (String fileName : vhostFiles)
+ {
+ // Open the vhosts XML file and copy values from it to our config
+ _vhostsFile = new File(fileName);
+ vhostConfiguration = parseConfig(new File(fileName));
+ }
+ }
+
+ // Now extract the virtual host names from the configuration object
+ List hosts = vhostConfiguration.getList("virtualhost.name");
for (int j = 0; j < hosts.size(); j++)
{
String name = (String) hosts.get(j);
- // Add the keys of the virtual host to the main config then bail out
-
- VirtualHostConfiguration vhostConfig = new VirtualHostConfiguration(name, conf.subset("virtualhosts.virtualhost." + name));
- _virtualHosts.put(vhostConfig.getName(), vhostConfig);
+
+ // Add the virtual hosts to the server configuration
+ VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + name));
+ _virtualHosts.put(virtualhost.getName(), virtualhost);
}
-
}
- private void substituteEnvironmentVariables()
+ private static void substituteEnvironmentVariables(Configuration conf)
{
for (Entry<String, String> var : envVarMap.entrySet())
{
String val = System.getenv(var.getKey());
if (val != null)
{
- getConfig().setProperty(var.getValue(), val);
+ conf.setProperty(var.getValue(), val);
}
}
}
- private final static Configuration parseConfig(File file) throws ConfigurationException
+ private static Configuration parseConfig(File file) throws ConfigurationException
{
ConfigurationFactory factory = new ConfigurationFactory();
factory.setConfigurationFileName(file.getAbsolutePath());
Configuration conf = factory.getConfiguration();
- Iterator keys = conf.getKeys();
+
+ Iterator<?> keys = conf.getKeys();
if (!keys.hasNext())
{
keys = null;
conf = flatConfig(file);
}
+
+ substituteEnvironmentVariables(conf);
+
return conf;
}
@@ -311,13 +335,25 @@ public class ServerConfiguration implements SignalHandler
if (_configFile != null)
{
Configuration newConfig = parseConfig(_configFile);
+
_securityConfiguration = new SecurityConfiguration(newConfig.subset("security"));
-
+
+ // Reload virtualhosts from correct location
+ Configuration newVhosts;
+ if (_vhostsFile == null)
+ {
+ newVhosts = newConfig.subset("virtualhosts");
+ }
+ else
+ {
+ newVhosts = parseConfig(_vhostsFile);
+ }
+
VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry();
for (String hostname : _virtualHosts.keySet())
{
VirtualHost vhost = vhostRegistry.getVirtualHost(hostname);
- SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newConfig.subset("virtualhosts.virtualhost."+hostname+".security"));
+ SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newVhosts.subset("virtualhost."+hostname+".security"));
vhost.getAccessManager().configureGlobalPlugins(_securityConfiguration);
vhost.getAccessManager().configureHostPlugins(hostSecurityConfig);
}
@@ -601,7 +637,7 @@ public class ServerConfiguration implements SignalHandler
public int getSSLPort()
{
- return getConfig().getInt("connector.ssl.port", DEFAUL_SSL_PORT);
+ return getConfig().getInt("connector.ssl.port", DEFAULT_SSL_PORT);
}
public String getKeystorePath()
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
index e478f0f1f3..934367890d 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java
@@ -20,11 +20,20 @@
*/
package org.apache.qpid.server.configuration;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.List;
+import java.util.Locale;
+
import junit.framework.TestCase;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
-
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.exchange.ExchangeType;
import org.apache.qpid.server.protocol.AMQProtocolEngine;
import org.apache.qpid.server.protocol.AMQProtocolSession;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -33,24 +42,15 @@ import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
import org.apache.qpid.transport.TestNetworkDriver;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-
public class ServerConfigurationTest extends TestCase
{
-
private XMLConfiguration _config;
@Override
public void setUp()
{
//Highlight that this test will cause a new AR to be created
-// ApplicationRegistry.getInstance();
+ ApplicationRegistry.getInstance();
_config = new XMLConfiguration();
}
@@ -59,7 +59,7 @@ public class ServerConfigurationTest extends TestCase
public void tearDown() throws Exception
{
//Correctly Close the AR we created
-// ApplicationRegistry.remove();
+ ApplicationRegistry.remove();
}
public void testSetJMXManagementPort() throws ConfigurationException
@@ -756,10 +756,9 @@ public class ServerConfigurationTest extends TestCase
public void testFirewallConfiguration() throws Exception
{
- // Write out config
+ // Write out config
File mainFile = File.createTempFile(getClass().getName(), null);
mainFile.deleteOnExit();
- FileWriter out;
writeConfigFile(mainFile, false);
// Load config
@@ -903,6 +902,10 @@ public class ServerConfigurationTest extends TestCase
}
private void writeConfigFile(File mainFile, boolean allow) throws IOException {
+ writeConfigFile(mainFile, allow, true, null, "test");
+ }
+
+ private void writeConfigFile(File mainFile, boolean allow, boolean includeVhosts, File vhostsFile, String name) throws IOException {
FileWriter out = new FileWriter(mainFile);
out.write("<broker>\n");
out.write("\t<management><enabled>false</enabled></management>\n");
@@ -927,15 +930,101 @@ public class ServerConfigurationTest extends TestCase
out.write("\t\t\t<rule access=\""+ ((allow) ? "allow" : "deny") +"\" network=\"127.0.0.1\"/>");
out.write("\t\t</firewall>\n");
out.write("\t</security>\n");
+ if (includeVhosts)
+ {
+ out.write("\t<virtualhosts>\n");
+ out.write("\t\t<virtualhost>\n");
+ out.write(String.format("\t\t\t<name>%s</name>\n", name));
+ out.write(String.format("\t\t<%s> \n", name));
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write(String.format("\t\t\t\t\t<name>%s.topic</name>\n", name));
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write(String.format("\t\t</%s> \n", name));
+ out.write("\t\t</virtualhost>\n");
+ out.write("\t</virtualhosts>\n");
+ }
+ if (vhostsFile != null)
+ {
+ out.write("\t<virtualhosts>"+vhostsFile.getAbsolutePath()+"</virtualhosts>\n");
+ }
+ out.write("</broker>\n");
+ out.close();
+ }
+
+ private void writeTestFishConfigFile(File mainFile) throws IOException {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<broker>\n");
+ out.write("\t<management><enabled>false</enabled></management>\n");
+ out.write("\t<security>\n");
+ out.write("\t\t<principal-databases>\n");
+ out.write("\t\t\t<principal-database>\n");
+ out.write("\t\t\t\t<name>passwordfile</name>\n");
+ out.write("\t\t\t\t<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>\n");
+ out.write("\t\t\t\t<attributes>\n");
+ out.write("\t\t\t\t\t<attribute>\n");
+ out.write("\t\t\t\t\t\t<name>passwordFile</name>\n");
+ out.write("\t\t\t\t\t\t<value>/dev/null</value>\n");
+ out.write("\t\t\t\t\t</attribute>\n");
+ out.write("\t\t\t\t</attributes>\n");
+ out.write("\t\t\t</principal-database>\n");
+ out.write("\t\t</principal-databases>\n");
+ out.write("\t\t<jmx>\n");
+ out.write("\t\t\t<access>/dev/null</access>\n");
+ out.write("\t\t\t<principal-database>passwordfile</principal-database>\n");
+ out.write("\t\t</jmx>\n");
+ out.write("\t\t<firewall>\n");
+ out.write("\t\t\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
+ out.write("\t\t</firewall>\n");
+ out.write("\t</security>\n");
out.write("\t<virtualhosts>\n");
out.write("\t\t<virtualhost>\n");
out.write("\t\t\t<name>test</name>\n");
+ out.write("\t\t<test> \n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test> \n");
+ out.write("\t\t</virtualhost>\n");
+ out.write("\t\t<virtualhost>\n");
+ out.write("\t\t\t<name>fish</name>\n");
+ out.write("\t\t<fish> \n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>fish.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fish> \n");
out.write("\t\t</virtualhost>\n");
out.write("\t</virtualhosts>\n");
out.write("</broker>\n");
out.close();
}
+ private void writeFirewallVhostsFile(File vhostsFile, boolean allow) throws IOException
+ {
+ FileWriter out = new FileWriter(vhostsFile);
+ String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ?
+ out.write("<virtualhosts><virtualhost>");
+ out.write("<name>test</name>");
+ out.write("<test>");
+ out.write("<security><firewall>");
+ out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>");
+ out.write("</firewall></security>");
+ out.write("</test>");
+ out.write("</virtualhost></virtualhosts>");
+ out.close();
+ }
+
public void testCombinedConfigurationFirewallReload() throws Exception
{
// Write out config
@@ -1041,42 +1130,538 @@ public class ServerConfigurationTest extends TestCase
}
}
- public void testnewParserOutputVsOldParserOutput() throws ConfigurationException
- {
- String configDir = System.getProperty("QPID_HOME")+"/etc";
+ private void writeVirtualHostsFile(File vhostsFile, String name) throws IOException {
+ FileWriter out = new FileWriter(vhostsFile);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write(String.format("\t\t<name>%s</name>\n", name));
+ out.write(String.format("\t\t<%s>\n", name));
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write(String.format("\t\t</%s>\n", name));
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ }
- XMLConfiguration oldConfig = new XMLConfiguration(configDir +"/config-systests-ServerConfigurationTest-Old.xml");
- Configuration newConfig = new ServerConfiguration(new File(configDir+"/config-systests-ServerConfigurationTest-New.xml")).getConfig();
+ private void writeMultiVirtualHostsFile(File vhostsFile) throws IOException {
+ FileWriter out = new FileWriter(vhostsFile);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<name>topic</name>\n");
+ out.write("\t\t<topic>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>topic</type>\n");
+ out.write("\t\t\t\t\t<name>test.topic</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</topic>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<name>fanout</name>\n");
+ out.write("\t\t<fanout>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<type>fanout</type>\n");
+ out.write("\t\t\t\t\t<name>test.fanout</name>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fanout>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ }
- Iterator xmlKeys = oldConfig.getKeys();
- while (xmlKeys.hasNext())
+ private void writeMultipleVhostsConfigFile(File mainFile, File[] vhostsFileArray) throws IOException {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<broker>\n");
+ out.write("\t<management><enabled>false</enabled></management>\n");
+ out.write("\t<security>\n");
+ out.write("\t\t<principal-databases>\n");
+ out.write("\t\t\t<principal-database>\n");
+ out.write("\t\t\t\t<name>passwordfile</name>\n");
+ out.write("\t\t\t\t<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>\n");
+ out.write("\t\t\t\t<attributes>\n");
+ out.write("\t\t\t\t\t<attribute>\n");
+ out.write("\t\t\t\t\t\t<name>passwordFile</name>\n");
+ out.write("\t\t\t\t\t\t<value>/dev/null</value>\n");
+ out.write("\t\t\t\t\t</attribute>\n");
+ out.write("\t\t\t\t</attributes>\n");
+ out.write("\t\t\t</principal-database>\n");
+ out.write("\t\t</principal-databases>\n");
+ out.write("\t\t<jmx>\n");
+ out.write("\t\t\t<access>/dev/null</access>\n");
+ out.write("\t\t\t<principal-database>passwordfile</principal-database>\n");
+ out.write("\t\t</jmx>\n");
+ out.write("\t\t<firewall>\n");
+ out.write("\t\t\t<rule access=\"allow\" network=\"127.0.0.1\"/>");
+ out.write("\t\t</firewall>\n");
+ out.write("\t</security>\n");
+ for (File vhostsFile : vhostsFileArray)
{
- String key = (String) xmlKeys.next();
- assertEquals("Incorrect value for "+key, oldConfig.getProperty(key), newConfig.getProperty(key));
+ out.write("\t<virtualhosts>"+vhostsFile.getAbsolutePath()+"</virtualhosts>\n");
}
+ out.write("</broker>\n");
+ out.close();
}
+ private void writeCombinedConfigFile(File mainFile, File fileA, File fileB) throws Exception
+ {
+ FileWriter out = new FileWriter(mainFile);
+ out.write("<configuration><system/>");
+ out.write("<xml fileName=\"" + fileA.getAbsolutePath() + "\"/>");
+ out.write("<xml fileName=\"" + fileB.getAbsolutePath() + "\"/>");
+ out.write("</configuration>");
+ out.close();
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in the main
+ * configuration file only.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testInternalVirtualhostConfigFile() throws Exception
+ {
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, true, null, "test");
- public void testNoVirtualhostXMLFile() throws Exception
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+ Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ assertEquals("Incorrect exchange type", "topic", exchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testExternalVirtualhostXMLFile() throws Exception
{
- int REGISTRY=1;
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+ writeVirtualHostsFile(vhostsFile, "test");
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
- File configFile = new File(System.getProperty("QPID_HOME")+"/etc/config.xml");
- assertTrue(configFile.exists());
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+ Exchange exchange = virtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ assertEquals("Incorrect exchange type", "topic", exchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only, with two vhosts that have different properties.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testExternalMultiVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts-multi");
+ vhostsFile.deleteOnExit();
+ writeMultiVirtualHostsFile(vhostsFile);
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+
+ assertEquals("Incorrect virtualhost count", 2, virtualHostRegistry.getVirtualHosts().size());
+
+ // test topic host
+ VirtualHost topicVirtualHost = virtualHostRegistry.getVirtualHost("topic");
+ Exchange topicExchange = topicVirtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.topic"));
+
+ assertEquals("Incorrect topic virtualhost name", "topic", topicVirtualHost.getName());
+ assertEquals("Incorrect topic exchange type", "topic", topicExchange.getType().getName().toString());
+
+ // Test fanout host
+ VirtualHost fanoutVirtualHost = virtualHostRegistry.getVirtualHost("fanout");
+ Exchange fanoutExchange = fanoutVirtualHost.getExchangeRegistry().getExchange(new AMQShortString("test.fanout"));
+
+ assertEquals("Incorrect fanout virtualhost name", "fanout", fanoutVirtualHost.getName());
+ assertEquals("Incorrect fanout exchange type", "fanout", fanoutExchange.getType().getName().toString());
+ }
+
+ /**
+ * Test that configuration does not load when virtual hosts are specified in both the main
+ * configuration file and an external file. Should throw a {@link ConfigurationException}.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testInternalAndExternalVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeVirtualHostsFile(vhostsFile, "test");
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeConfigFile(mainFile, false, true, vhostsFile, "test");
+
+ // Load config
try
{
- ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(configFile), REGISTRY);
-
- VirtualHostRegistry virtualHostRegistry = ApplicationRegistry.getInstance(REGISTRY).getVirtualHostRegistry();
+ @SuppressWarnings("unused")
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ fail("Different virtualhost XML configurations not allowed");
+ }
+ catch (ConfigurationException ce)
+ {
+ assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage());
+ }
+ }
+
+ /**
+ * Test that configuration does not load when virtual hosts are specified in multiple external
+ * files. Should throw a {@link ConfigurationException}.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testMultipleInternalVirtualhostXMLFile() throws Exception
+ {
+ // Write out vhosts
+ File vhostsFileOne = File.createTempFile(getClass().getName(), "vhosts-one");
+ vhostsFileOne.deleteOnExit();
+ writeVirtualHostsFile(vhostsFileOne, "one");
+ File vhostsFileTwo = File.createTempFile(getClass().getName(), "vhosts-two");
+ vhostsFileTwo.deleteOnExit();
+ writeVirtualHostsFile(vhostsFileTwo, "two");
+
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ writeMultipleVhostsConfigFile(mainFile, new File[] { vhostsFileOne, vhostsFileTwo });
+
+ // Load config
+ try
+ {
+ @SuppressWarnings("unused")
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ fail("Multiple virtualhost XML configurations not allowed");
+ }
+ catch (ConfigurationException ce)
+ {
+ assertEquals("Incorrect error message",
+ "Only one external virtualhosts configuration file allowed, multiple filenames found.",
+ ce.getMessage());
+ }
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file in the first of two configurations and embedded in the second. This
+ * will throe a {@link ConfigurationException} since the configurations have different
+ * types.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedDifferentVirtualhostConfig() throws Exception
+ {
+ // Write out vhosts config
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeVirtualHostsFile(vhostsFile, "external");
+
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, false, vhostsFile, null);
+ writeConfigFile(fileB, false);
- assertEquals("Incorrect virtualhost count", 3 , virtualHostRegistry.getVirtualHosts().size());
+ // Load config
+ try
+ {
+ @SuppressWarnings("unused")
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+ fail("Different virtualhost XML configurations not allowed");
}
- finally
+ catch (ConfigurationException ce)
{
- ApplicationRegistry.remove(REGISTRY);
+ assertEquals("Incorrect error message", "Only one of external or embedded virtualhosts configuration allowed.", ce.getMessage());
}
}
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified two overriding configurations
+ * each with an embedded virtualhost section. The first configuration section should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigEmbeddedVirtualhost() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, true, null, "a");
+ writeConfigFile(fileB, false, true, null, "b");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration virtualHost = config.getVirtualHostConfig("a");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "a", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified two overriding configurations
+ * each with an external virtualhost XML file. The first configuration file should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigExternalVirtualhost() throws Exception
+ {
+ // Write out vhosts config
+ File vhostsOne = File.createTempFile(getClass().getName(), "vhosts-one");
+ vhostsOne.deleteOnExit();
+ writeVirtualHostsFile(vhostsOne, "one");
+ File vhostsTwo = File.createTempFile(getClass().getName(), "vhosts-two");
+ vhostsTwo.deleteOnExit();
+ writeVirtualHostsFile(vhostsTwo, "two");
+
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "a");
+ File fileB = File.createTempFile(getClass().getName(), "b");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeConfigFile(fileA, false, false, vhostsOne, null);
+ writeConfigFile(fileB, false, false, vhostsTwo, null);
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration virtualHost = config.getVirtualHostConfig("one");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "one", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when an overriding virtualhost configuration resets
+ * a property of an embedded virtualhost section. The overriding configuration property value
+ * should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedConfigEmbeddedVirtualhostOverride() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File fileA = File.createTempFile(getClass().getName(), "override");
+ File fileB = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeCombinedConfigFile(mainFile, fileA, fileB);
+ writeTestFishConfigFile(fileB);
+
+ // Write out overriding virtualhosts section
+ FileWriter out = new FileWriter(fileA);
+ out.write("<broker>\n");
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<test>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test>\n");
+ out.write("\t\t<fish>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>true</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</fish>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.write("</broker>\n");
+ out.close();
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration testHost = config.getVirtualHostConfig("test");
+ ExchangeConfiguration testExchange = testHost.getExchangeConfiguration("test.topic");
+ VirtualHostConfiguration fishHost = config.getVirtualHostConfig("fish");
+ ExchangeConfiguration fishExchange = fishHost.getExchangeConfiguration("fish.topic");
+
+ assertEquals("Incorrect virtualhost count", 2, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test", testHost.getName());
+ assertFalse("Incorrect exchange durable property", testExchange.getDurable());
+ assertEquals("Incorrect virtualhost name", "fish", fishHost.getName());
+ assertTrue("Incorrect exchange durable property", fishExchange.getDurable());
+ }
+
+ /**
+ * Test that configuration loads correctly when virtual hosts are specified in an external
+ * configuration file only.
+ * <p>
+ * Test for QPID-2360
+ */
+ public void testExternalFirewallVirtualhostXMLFile() throws Exception
+ {
+ // Write out config
+ File mainFile = File.createTempFile(getClass().getName(), "config");
+ mainFile.deleteOnExit();
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ vhostsFile.deleteOnExit();
+ writeConfigFile(mainFile, false, false, vhostsFile, null);
+ writeFirewallVhostsFile(vhostsFile, false);
+
+ // Load config
+ ApplicationRegistry reg = new ConfigurationFileApplicationRegistry(mainFile);
+ ApplicationRegistry.initialise(reg, 1);
+ // Test config
+ VirtualHostRegistry virtualHostRegistry = reg.getVirtualHostRegistry();
+ VirtualHost virtualHost = virtualHostRegistry.getVirtualHost("test");
+
+ assertEquals("Incorrect virtualhost count", 1, virtualHostRegistry.getVirtualHosts().size());
+ assertEquals("Incorrect virtualhost name", "test", virtualHost.getName());
+ }
+
+ /**
+ * Test that configuration loads correctly when the virtualhost configuration is a set of overriding
+ * configuration files that resets a property of a virtualhost. The opmost overriding configuration
+ * property value should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedVirtualhostOverride() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ File fileA = File.createTempFile(getClass().getName(), "vhosts-override");
+ File fileB = File.createTempFile(getClass().getName(), "vhosts-base");
+ mainFile.deleteOnExit();
+ vhostsFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeConfigFile(mainFile, true, false, vhostsFile, null);
+ writeCombinedConfigFile(vhostsFile, fileA, fileB);
+
+ // Write out overriding virtualhosts sections
+ FileWriter out = new FileWriter(fileA);
+ out.write("<virtualhosts>\n");
+ out.write("\t<virtualhost>\n");
+ out.write("\t\t<test>\n");
+ out.write("\t\t\t<exchanges>\n");
+ out.write("\t\t\t\t<exchange>\n");
+ out.write("\t\t\t\t\t<durable>false</durable>\n");
+ out.write("\t\t\t\t</exchange>\n");
+ out.write("\t\tt</exchanges>\n");
+ out.write("\t\t</test>\n");
+ out.write("\t</virtualhost>\n");
+ out.write("</virtualhosts>\n");
+ out.close();
+ writeVirtualHostsFile(fileB, "test");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration testHost = config.getVirtualHostConfig("test");
+ ExchangeConfiguration testExchange = testHost.getExchangeConfiguration("test.topic");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test", testHost.getName());
+ assertFalse("Incorrect exchange durable property", testExchange.getDurable());
+ }
+
+ /**
+ * Test that configuration loads correctly when the virtualhost configuration is a set of overriding
+ * configuration files that define multiple virtualhosts, one per file. Only the virtualhosts defined in
+ * the topmost file should be used.
+ * <p>
+ * Test for QPID-2361
+ */
+ public void testCombinedMultipleVirtualhosts() throws Exception
+ {
+ // Write out combined config file
+ File mainFile = File.createTempFile(getClass().getName(), "main");
+ File vhostsFile = File.createTempFile(getClass().getName(), "vhosts");
+ File fileA = File.createTempFile(getClass().getName(), "vhosts-one");
+ File fileB = File.createTempFile(getClass().getName(), "vhosts-two");
+ mainFile.deleteOnExit();
+ vhostsFile.deleteOnExit();
+ fileA.deleteOnExit();
+ fileB.deleteOnExit();
+ writeConfigFile(mainFile, true, false, vhostsFile, null);
+ writeCombinedConfigFile(vhostsFile, fileA, fileB);
+
+ // Write both virtualhosts definitions
+ writeVirtualHostsFile(fileA, "test-one");
+ writeVirtualHostsFile(fileB, "test-two");
+
+ // Load config
+ ServerConfiguration config = new ServerConfiguration(mainFile.getAbsoluteFile());
+
+ // Test config
+ VirtualHostConfiguration oneHost = config.getVirtualHostConfig("test-one");
+
+ assertEquals("Incorrect virtualhost count", 1, config.getVirtualHosts().length);
+ assertEquals("Incorrect virtualhost name", "test-one", oneHost.getName());
+ }
}
diff --git a/qpid/java/client/test/example_build.xml b/qpid/java/client/test/example_build.xml
index a12862be04..329c12982c 100644
--- a/qpid/java/client/test/example_build.xml
+++ b/qpid/java/client/test/example_build.xml
@@ -66,7 +66,7 @@
<!-- Compile Java -->
<target name="compile" depends="init">
- <javac destdir="${example.classes}" debug="on">
+ <javac destdir="${example.classes}" debug="on" includeantruntime="false">
<classpath refid="example_amq.classpath"/>
<src path="${example.src}"/>
<exclude name="**/Test*.java"/>
diff --git a/qpid/java/common.xml b/qpid/java/common.xml
index bbde7b7f62..611be5a0b8 100644
--- a/qpid/java/common.xml
+++ b/qpid/java/common.xml
@@ -105,7 +105,7 @@
</macrodef>
<mkdir dir="${tasks.classes}"/>
- <javac source="${java.source}" target="${java.target}" srcdir="${tasks.src}" destdir="${tasks.classes}" classpath="${java.class.path}">
+ <javac source="${java.source}" target="${java.target}" srcdir="${tasks.src}" destdir="${tasks.classes}" classpath="${java.class.path}" includeantruntime="false">
<compilerarg line="${javac.compiler.args}"/>
</javac>
diff --git a/qpid/java/module.xml b/qpid/java/module.xml
index 96401f2178..290b88b014 100644
--- a/qpid/java/module.xml
+++ b/qpid/java/module.xml
@@ -188,7 +188,7 @@
<echo message="Targeting : ${java.target}" level="info"/>
<javac source="${java.source}" target="${java.target}"
- destdir="${module.classes}" debug="on"
+ destdir="${module.classes}" debug="on" includeantruntime="false"
deprecation="${javac.deprecation}">
<compilerarg line="${javac.compiler.args}"/>
<src refid="module.src.path"/>
diff --git a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
index 33cc90b895..7deb80bcd9 100644
--- a/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
+++ b/qpid/java/systests/etc/config-systests-ServerConfigurationTest-New.xml
@@ -18,9 +18,6 @@
- specific language governing permissions and limitations
- under the License.
-
-
- This is an example config using the BDBMessageStore available from
- the Red Hat Messaging project at etp.108.redhat.com and distributed under GPL.
-->
<broker>
@@ -68,17 +65,8 @@
</jmx>
</security>
- <virtualhosts>
- <virtualhost>
- <name>dev-only</name>
- <dev-only>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
- <environment-path>${work}/bdbstore/dev-only-store</environment-path>
- </store>
- </dev-only>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-ServerConfigurationTest-New.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
@@ -86,8 +74,6 @@
<queue>
<auto_register>true</auto_register>
</queue>
-
- <virtualhosts>${conf}/virtualhosts-ServerConfigurationTest-New.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-acl-settings.xml b/qpid/java/systests/etc/config-systests-acl-settings.xml
index d7c1ef70df..eebc75f05f 100644
--- a/qpid/java/systests/etc/config-systests-acl-settings.xml
+++ b/qpid/java/systests/etc/config-systests-acl-settings.xml
@@ -20,141 +20,7 @@
-
-->
<broker>
-
- <virtualhosts>
-
- <virtualhost>
- <name>test</name>
- <test>
- <queues>
- <exchange>amq.direct</exchange>
- <!-- 4Mb -->
- <maximumQueueDepth>4235264</maximumQueueDepth>
- <!-- 2Mb -->
- <maximumMessageSize>2117632</maximumMessageSize>
- <!-- 10 mins -->
- <maximumMessageAge>600000</maximumMessageAge>
- </queues>
-
-
- <security>
- <access>
- <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
- </access>
- <access_control_list>
- <!-- This section grants pubish rights to an exchange + routing key pair -->
- <publish>
- <exchanges>
- <exchange>
- <name>amq.direct</name>
- <routing_keys>
-
- <!-- Allow clients to publish requests -->
- <routing_key>
- <value>example.RequestQueue</value>
- <users>
- <user>client</user>
- </users>
- </routing_key>
-
- <!-- Allow the processor to respond to a client on their Temporary Topic -->
- <routing_key>
- <value>tmp_*</value>
- <users>
- <user>server</user>
- </users>
- </routing_key>
- <routing_key>
- <value>TempQueue*</value>
- <users>
- <user>server</user>
- </users>
- </routing_key>
- </routing_keys>
-
- </exchange>
- </exchanges>
- </publish>
-
- <!-- This section grants users the ability to consume from the broker -->
- <consume>
- <queues>
- <temporary>
- <users>
- <user>client</user>
- </users>
- </temporary>
-
- <!-- Only allow the server to consume from the Request Queue-->
- <queue>
- <name>example.RequestQueue</name>
- <users>
- <user>server</user>
- </users>
- </queue>
-
-
- </queues>
- </consume>
-
- <!-- This section grants users the ability to create queues and exchanges -->
- <create>
- <queues>
- <temporary>
- <users>
- <user>client</user>
- </users>
- </temporary>
-
- <!-- Allow clients to create queue on this exchange-->
- <queue>
- <exchanges>
- <exchange>
- <name>amq.direct</name>
- <users>
- <user>client</user>
- </users>
- </exchange>
- </exchanges>
- </queue>
- <!-- Allow the server to create the Request Queue-->
- <queue>
- <name>example.RequestQueue</name>
- <users>
- <user>server</user>
- </users>
- </queue>
-
- </queues>
- </create>
-
-
- </access_control_list>
-
- </security>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <security>
- <access>
- <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
- </access>
-
- <access_control_list>
- <!-- This section grants specific users full permissions to all artifacts in this virtualhost -->
- <access>
- <users>
- <user>guest</user>
- </users>
- </access>
- </access_control_list>
- </security>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-acl.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-acl.xml b/qpid/java/systests/etc/config-systests-acl.xml
index 34104dbe6b..535108235e 100644
--- a/qpid/java/systests/etc/config-systests-acl.xml
+++ b/qpid/java/systests/etc/config-systests-acl.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-acl-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
diff --git a/qpid/java/systests/etc/config-systests-derby-settings.xml b/qpid/java/systests/etc/config-systests-derby-settings.xml
index 9c25b5682e..3ed3a9e33b 100644
--- a/qpid/java/systests/etc/config-systests-derby-settings.xml
+++ b/qpid/java/systests/etc/config-systests-derby-settings.xml
@@ -20,45 +20,7 @@
-
-->
<broker>
- <virtualhosts>
- <directory>${conf}/virtualhosts</directory>
-
- <virtualhost>
- <name>localhost</name>
- <localhost>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/localhost-store</environment-path>
- </store>
-
- <housekeeping>
- <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
- </housekeeping>
-
- </localhost>
- </virtualhost>
-
- <virtualhost>
- <name>development</name>
- <development>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/development-store</environment-path>
- </store>
- </development>
- </virtualhost>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.DerbyMessageStore</class>
- <environment-path>${work}/derbyDB/test-store</environment-path>
- </store>
- </test>
- </virtualhost>
-
- </virtualhosts>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-derby.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-derby.xml b/qpid/java/systests/etc/config-systests-derby.xml
index 18ba0c4ad9..ba27a0c020 100644
--- a/qpid/java/systests/etc/config-systests-derby.xml
+++ b/qpid/java/systests/etc/config-systests-derby.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-derby-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
diff --git a/qpid/java/systests/etc/config-systests-firewall-2.xml b/qpid/java/systests/etc/config-systests-firewall-2.xml
index 1c560d751d..8380fab3d9 100644
--- a/qpid/java/systests/etc/config-systests-firewall-2.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-2.xml
@@ -96,32 +96,8 @@
</firewall>
</security>
- <virtualhosts>
- <default>test</default>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- <security>
- <firewall default-action="allow"/>
- </security>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-systests-firewall-2.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/systests/etc/config-systests-firewall-3.xml b/qpid/java/systests/etc/config-systests-firewall-3.xml
index 05c4df6069..2068581ca1 100644
--- a/qpid/java/systests/etc/config-systests-firewall-3.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-3.xml
@@ -96,32 +96,8 @@
</firewall>
</security>
- <virtualhosts>
- <default>test</default>
-
- <virtualhost>
- <name>test</name>
- <test>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- </test>
- </virtualhost>
-
- <virtualhost>
- <name>test2</name>
- <test2>
- <store>
- <class>org.apache.qpid.server.store.MemoryMessageStore
- </class>
- </store>
- <security>
- <firewall default-action="deny"/>
- </security>
- </test2>
- </virtualhost>
- </virtualhosts>
+ <virtualhosts>${conf}/virtualhosts-systests-firewall-3.xml</virtualhosts>
+
<heartbeat>
<delay>0</delay>
<timeoutFactor>2.0</timeoutFactor>
diff --git a/qpid/java/systests/etc/config-systests-firewall-settings.xml b/qpid/java/systests/etc/config-systests-firewall-settings.xml
index d115e74663..aa73be0646 100644
--- a/qpid/java/systests/etc/config-systests-firewall-settings.xml
+++ b/qpid/java/systests/etc/config-systests-firewall-settings.xml
@@ -25,4 +25,6 @@
<rule access="allow" network="127.0.0.1"/>
</firewall>
</security>
+
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests-firewall.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests-firewall.xml b/qpid/java/systests/etc/config-systests-firewall.xml
index 90773f5cc2..c0ce71210f 100644
--- a/qpid/java/systests/etc/config-systests-firewall.xml
+++ b/qpid/java/systests/etc/config-systests-firewall.xml
@@ -22,8 +22,9 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
- <xml fileName="${QPID_FIREWALL_SETTINGS}"/>
+ <xml fileName="${test.config}" optional="true"/>
+ <xml fileName="${QPID_FIREWALL_CONFIG_SETTINGS}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/config-systests-firewall-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
</override>
diff --git a/qpid/java/systests/etc/config-systests-settings.xml b/qpid/java/systests/etc/config-systests-settings.xml
index 4e9c863fda..a7f538aec1 100644
--- a/qpid/java/systests/etc/config-systests-settings.xml
+++ b/qpid/java/systests/etc/config-systests-settings.xml
@@ -26,4 +26,5 @@
<enabled>false</enabled>
</ssl>
</management>
+ <virtualhosts>${QPID_HOME}/etc/virtualhosts-systests.xml</virtualhosts>
</broker>
diff --git a/qpid/java/systests/etc/config-systests.xml b/qpid/java/systests/etc/config-systests.xml
index 290c082a4f..5d7d878e76 100644
--- a/qpid/java/systests/etc/config-systests.xml
+++ b/qpid/java/systests/etc/config-systests.xml
@@ -22,7 +22,7 @@
<configuration>
<system/>
<override>
- <xml fileName="${test.config}" config-optional="true"/>
+ <xml fileName="${test.config}" optional="true"/>
<xml fileName="${QPID_HOME}/etc/config-systests-settings.xml"/>
<xml fileName="${QPID_HOME}/etc/config.xml"/>
</override>
diff --git a/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
index 168aa074da..1b6845662b 100644
--- a/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
+++ b/qpid/java/systests/etc/virtualhosts-ServerConfigurationTest-New.xml
@@ -26,7 +26,7 @@
<dev-only>
<queues>
<exchange>amq.direct</exchange>
- <!-- Small defaults for development -->
+ <!-- Small defaults for development -->
<maximumQueueDepth>102400</maximumQueueDepth> <!-- 100k -->
<maximumMessageSize>20480</maximumMessageSize> <!-- 20kb -->
<maximumMessageAge>60000</maximumMessageAge> <!-- 1 mins -->
@@ -35,6 +35,11 @@
<name>dev-queue</name>
</queue>
</queues>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ <environment-path>${QPID_WORK}/bdbstore/dev-only-store</environment-path>
+ </store>
</dev-only>
</virtualhost>
</virtualhosts>
+ \ No newline at end of file
diff --git a/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml b/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml
new file mode 100644
index 0000000000..50fda4e999
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-acl-settings.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <queues>
+ <exchange>amq.direct</exchange>
+ <!-- 4Mb -->
+ <maximumQueueDepth>4235264</maximumQueueDepth>
+ <!-- 2Mb -->
+ <maximumMessageSize>2117632</maximumMessageSize>
+ <!-- 10 mins -->
+ <maximumMessageAge>600000</maximumMessageAge>
+ </queues>
+
+
+ <security>
+ <access>
+ <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
+ </access>
+ <access_control_list>
+ <!-- This section grants pubish rights to an exchange + routing key pair -->
+ <publish>
+ <exchanges>
+ <exchange>
+ <name>amq.direct</name>
+ <routing_keys>
+
+ <!-- Allow clients to publish requests -->
+ <routing_key>
+ <value>example.RequestQueue</value>
+ <users>
+ <user>client</user>
+ </users>
+ </routing_key>
+
+ <!-- Allow the processor to respond to a client on their Temporary Topic -->
+ <routing_key>
+ <value>tmp_*</value>
+ <users>
+ <user>server</user>
+ </users>
+ </routing_key>
+ <routing_key>
+ <value>TempQueue*</value>
+ <users>
+ <user>server</user>
+ </users>
+ </routing_key>
+ </routing_keys>
+
+ </exchange>
+ </exchanges>
+ </publish>
+
+ <!-- This section grants users the ability to consume from the broker -->
+ <consume>
+ <queues>
+ <temporary>
+ <users>
+ <user>client</user>
+ </users>
+ </temporary>
+
+ <!-- Only allow the server to consume from the Request Queue-->
+ <queue>
+ <name>example.RequestQueue</name>
+ <users>
+ <user>server</user>
+ </users>
+ </queue>
+
+
+ </queues>
+ </consume>
+
+ <!-- This section grants users the ability to create queues and exchanges -->
+ <create>
+ <queues>
+ <temporary>
+ <users>
+ <user>client</user>
+ </users>
+ </temporary>
+
+ <!-- Allow clients to create queue on this exchange-->
+ <queue>
+ <exchanges>
+ <exchange>
+ <name>amq.direct</name>
+ <users>
+ <user>client</user>
+ </users>
+ </exchange>
+ </exchanges>
+ </queue>
+ <!-- Allow the server to create the Request Queue-->
+ <queue>
+ <name>example.RequestQueue</name>
+ <users>
+ <user>server</user>
+ </users>
+ </queue>
+
+ </queues>
+ </create>
+
+
+ </access_control_list>
+
+ </security>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <security>
+ <access>
+ <class>org.apache.qpid.server.security.access.plugins.SimpleXML</class>
+ </access>
+
+ <access_control_list>
+ <!-- This section grants specific users full permissions to all artifacts in this virtualhost -->
+ <access>
+ <users>
+ <user>guest</user>
+ </users>
+ </access>
+ </access_control_list>
+ </security>
+ </test2>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-acl.xml b/qpid/java/systests/etc/virtualhosts-systests-acl.xml
new file mode 100644
index 0000000000..4a56c39de0
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-acl.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts-systests-acl-settings.xml"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml b/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml
new file mode 100644
index 0000000000..ed5ffbb1fd
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-derby-settings.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <directory>${QPID_HOME}/virtualhosts</directory>
+ <default>test</default>
+
+ <virtualhost>
+ <localhost>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/localhost-store</environment-path>
+ </store>
+ </localhost>
+ </virtualhost>
+
+ <virtualhost>
+ <development>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/development-store</environment-path>
+ </store>
+ </development>
+ </virtualhost>
+
+ <virtualhost>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.DerbyMessageStore</class>
+ <environment-path>${QPID_WORK}/derbyDB/test-store</environment-path>
+ </store>
+ </test>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-derby.xml b/qpid/java/systests/etc/virtualhosts-systests-derby.xml
new file mode 100644
index 0000000000..171be37416
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-derby.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts-systests-derby-settings.xml"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml
new file mode 100644
index 0000000000..b85ab83676
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall-2.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ <security>
+ <firewall default-action="allow"/>
+ </security>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ </test2>
+ </virtualhost>
+</virtualhosts> \ No newline at end of file
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml
new file mode 100644
index 0000000000..ebfc2bad20
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall-3.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<virtualhosts>
+ <default>test</default>
+
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ </test>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test2</name>
+ <test2>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore
+ </class>
+ </store>
+ <security>
+ <firewall default-action="deny"/>
+ </security>
+ </test2>
+ </virtualhost>
+</virtualhosts>
+
+
diff --git a/qpid/java/systests/etc/virtualhosts-systests-firewall.xml b/qpid/java/systests/etc/virtualhosts-systests-firewall.xml
new file mode 100644
index 0000000000..51ab6739b3
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests-firewall.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_FIREWALL_VIRTUALHOSTS_SETTINGS}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/etc/virtualhosts-systests.xml b/qpid/java/systests/etc/virtualhosts-systests.xml
new file mode 100644
index 0000000000..71f1cc9889
--- /dev/null
+++ b/qpid/java/systests/etc/virtualhosts-systests.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<configuration>
+ <system/>
+ <override>
+ <xml fileName="${test.virtualhosts}" optional="true"/>
+ <xml fileName="${QPID_HOME}/etc/virtualhosts.xml"/>
+ </override>
+</configuration>
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
index 0a88ef391c..4a2d626a5b 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/configuration/ServerConfigurationFileTest.java
@@ -42,6 +42,8 @@ public class ServerConfigurationFileTest extends QpidTestCase
}
saveTestConfiguration();
+ saveTestVirtualhosts();
+
_serverConfig = new ServerConfiguration(_configFile);
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
index 3429edd6bc..a4b47268e2 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java
@@ -20,19 +20,16 @@
*/
package org.apache.qpid.server.logging;
+import javax.jms.Connection;
+import javax.jms.Queue;
+import javax.jms.Session;
+
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.util.FileUtils;
-import org.apache.qpid.util.LogMonitor;
-
-import javax.jms.Connection;
-import javax.jms.Queue;
-import javax.jms.Session;
-import java.io.File;
public class AlertingTest extends AbstractTestLogging
{
@@ -49,6 +46,7 @@ public class AlertingTest extends AbstractTestLogging
{
// Update the configuration to make our virtualhost Persistent.
makeVirtualHostPersistent(VIRTUALHOST);
+ setConfigurationProperty("virtualhosts.virtualhost." + VIRTUALHOST + ".housekeeping.expiredMessageCheckPeriod", "5000");
_numMessages = 50;
@@ -114,7 +112,7 @@ public class AlertingTest extends AbstractTestLogging
message.append(FileUtils.readFileAsString(getTestConfigFile()));
message.append("\nVirtualhost maxMessageCount:\n");
- message.append((new ServerConfiguration(_configFile)).getConfig().getString("virtualhosts.virtualhost." + VIRTUALHOST + ".queues.maximumMessageCount"));
+ message.append(new ServerConfiguration(_configFile).getVirtualHostConfig(VIRTUALHOST).getMaximumMessageCount());
fail(message.toString());
}
@@ -185,7 +183,7 @@ public class AlertingTest extends AbstractTestLogging
setupConnection();
// Validate the queue depth is as expected
- long messageCount = ((AMQSession) _session).getQueueDepth((AMQDestination) _destination);
+ long messageCount = ((AMQSession<?, ?>) _session).getQueueDepth((AMQDestination) _destination);
assertEquals("Broker has invalid message count for test", 2, messageCount);
// Ensure the alert has not occured yet
@@ -198,5 +196,4 @@ public class AlertingTest extends AbstractTestLogging
// Validate that the alert occured.
wasAlertFired();
}
-
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
index 1bcef1dbb0..c3c2574519 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java
@@ -20,13 +20,13 @@
*/
package org.apache.qpid.server.logging;
-import org.apache.commons.configuration.Configuration;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.qpid.server.configuration.ServerConfiguration;
import org.apache.qpid.server.logging.subjects.AbstractTestLogSubject;
import org.apache.qpid.util.LogMonitor;
-import java.util.List;
-
/**
* The MessageStore test suite validates that the follow log messages as
* specified in the Functional Specification.
@@ -90,7 +90,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
//Validate each vhost logs a creation
results = _monitor.waitAndFindMatches("MST-1001", DEFAULT_LOG_WAIT);
@@ -101,15 +101,12 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
{
String result = getLog(results.get(index));
- // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // getSlice will return extract the vhost from vh(/test) -> '/test'
// so remove the '/' to get the name
String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ // Get the store class used in the configuration for the virtualhost.
+ String fullStoreName = configuration.getVirtualHostConfig(vhostName).getMessageStoreClass();
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
@@ -157,7 +154,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
// Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
//Validate each vhost logs a creation
results = _monitor.waitAndFindMatches("MST-1003", DEFAULT_LOG_WAIT);
@@ -168,15 +165,12 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging
{
String result = getLog(results.get(index));
- // getSlize will return extract the vhost from vh(/test) -> '/test'
+ // getSlice will return extract the vhost from vh(/test) -> '/test'
// so remove the '/' to get the name
String vhostName = AbstractTestLogSubject.getSlice("vh", result).substring(1);
- // To get the store class used in the configuration we need to know
- // the virtualhost name, found above. AND
- // the index that the virtualhost is within the configuration.
- // we can retrive that from the vhosts list previously extracted.
- String fullStoreName = configuration.getConfig().getString("virtualhosts.virtualhost(" + vhosts.indexOf(vhostName) + ")." + vhostName + ".store.class");
+ // Get the store class used in the configuration for the virtualhost.
+ String fullStoreName = configuration.getVirtualHostConfig(vhostName).getMessageStoreClass();
// Get the Simple class name from the expected class name of o.a.q.s.s.MMS
String storeName = fullStoreName.substring(fullStoreName.lastIndexOf(".") + 1);
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
index b97bd64a55..d4c3689365 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java
@@ -21,11 +21,12 @@
package org.apache.qpid.server.logging;
+import java.util.Arrays;
+import java.util.List;
+
import junit.framework.AssertionFailedError;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.configuration.ServerConfiguration;
-import java.util.List;
+import org.apache.qpid.server.configuration.ServerConfiguration;
/**
* Virtualhost Test Cases
@@ -60,28 +61,26 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
public void testVirtualhostCreation() throws Exception
{
//Wait for the correct VHT message to arrive.
- _monitor.waitForMessage("VHT-1001",DEFAULT_LOG_WAIT);
-
- List<String> results = _monitor.findMatches(VHT_PREFIX);
+ _monitor.waitForMessage(VHT_PREFIX + "1001", DEFAULT_LOG_WAIT);
+
+ //Validate each vhost logs a creation
+ List<String> results = _monitor.findMatches(VHT_PREFIX + "1001");
+
try
{
- // Validation
+ // Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = _monitor.findMatches("VHT-1001");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
for (int index = 0; index < results.size(); index++)
{
- String result = getLog(results.get(index));
-
// Retrieve the vhostname from the log entry message 'Created : <vhostname>'
+ String result = getLog(results.get(index));
String vhostName = getMessageString(fromMessage(result)).split(" ")[2];
- assertTrue("Virualhost named in log not found in config file:" + vhostName + ":" + vhosts, vhosts.contains(vhostName));
+ assertTrue("Virtualhost named in log not found in config file:" + vhostName + ":" + vhosts, vhosts.contains(vhostName));
}
}
catch (AssertionFailedError afe)
@@ -114,21 +113,19 @@ public class VirtualHostLoggingTest extends AbstractTestLogging
{
stopBroker();
- //Wait for the correct VHT message to arrive.
- _monitor.waitForMessage("VHT-1002",DEFAULT_LOG_WAIT);
-
- List<String> results = _monitor.findMatches(VHT_PREFIX);
+ // Wait for the correct VHT message to arrive.
+ _monitor.waitForMessage(VHT_PREFIX + "1002", DEFAULT_LOG_WAIT);
+
+ // Validate each vhost logs a closure
+ List<String> results = _monitor.findMatches(VHT_PREFIX + "1002");
+
try
{
- // Validation
-
+ // Load VirtualHost list from file.
ServerConfiguration configuration = new ServerConfiguration(_configFile);
- List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name");
-
- //Validate each vhost logs a creation
- results = _monitor.findMatches("VHT-1002");
+ List<String> vhosts = Arrays.asList(configuration.getVirtualHosts());
- assertEquals("Each vhost did not create a store.", vhosts.size(), results.size());
+ assertEquals("Each vhost did not close their store.", vhosts.size(), results.size());
}
catch (AssertionFailedError afe)
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
index 5e387be91b..ec9a297047 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/security/firewall/FirewallConfigTest.java
@@ -33,8 +33,8 @@ import org.apache.qpid.test.utils.QpidTestCase;
public class FirewallConfigTest extends QpidTestCase
{
-
- private File tmpFile = null;
+ private File _tmpConfig, _tmpVirtualhosts;
+
@Override
protected void setUp() throws Exception
{
@@ -46,22 +46,32 @@ public class FirewallConfigTest extends QpidTestCase
fail("QPID_HOME not set");
}
- // Setup initial config.
+ // Setup initial config file.
_configFile = new File(QPID_HOME, "etc/config-systests-firewall.xml");
- tmpFile = File.createTempFile("config-systests-firewall", ".xml");
- setSystemProperty("QPID_FIREWALL_SETTINGS", tmpFile.getAbsolutePath());
- tmpFile.deleteOnExit();
+
+ // Setup temporary config file
+ _tmpConfig = File.createTempFile("config-systests-firewall", ".xml");
+ setSystemProperty("QPID_FIREWALL_CONFIG_SETTINGS", _tmpConfig.getAbsolutePath());
+ _tmpConfig.deleteOnExit();
+
+ // Setup temporary virtualhosts file
+ _tmpVirtualhosts = File.createTempFile("virtualhosts-systests-firewall", ".xml");
+ setSystemProperty("QPID_FIREWALL_VIRTUALHOSTS_SETTINGS", _tmpVirtualhosts.getAbsolutePath());
+ _tmpVirtualhosts.deleteOnExit();
}
private void writeFirewallFile(boolean allow, boolean inVhost) throws IOException
{
- FileWriter out = new FileWriter(tmpFile);
+ FileWriter out = new FileWriter(inVhost ? _tmpVirtualhosts : _tmpConfig);
String ipAddr = "127.0.0.1"; // FIXME: get this from InetAddress.getLocalHost().getAddress() ?
- out.write("<broker>");
if (inVhost)
{
out.write("<virtualhosts><virtualhost><test>");
}
+ else
+ {
+ out.write("<broker>");
+ }
out.write("<security><firewall>");
out.write("<rule access=\""+((allow) ? "allow" : "deny")+"\" network=\""+ipAddr +"\"/>");
out.write("</firewall></security>");
@@ -69,7 +79,10 @@ public class FirewallConfigTest extends QpidTestCase
{
out.write("</test></virtualhost></virtualhosts>");
}
- out.write("</broker>");
+ else
+ {
+ out.write("</broker>");
+ }
out.close();
}
@@ -188,6 +201,23 @@ public class FirewallConfigTest extends QpidTestCase
});
}
+ public void testAllowOnReloadInVhost() throws Exception
+ {
+ testFirewall(false, true, new Runnable() {
+
+ public void run()
+ {
+ try
+ {
+ reloadBroker();
+ } catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ });
+ }
+
public void testDenyOnReload() throws Exception
{
testDeny(false, new Runnable() {
@@ -224,18 +254,17 @@ public class FirewallConfigTest extends QpidTestCase
);
}
-
+
private void testDeny(boolean inVhost, Runnable restartOrReload) throws Exception
{
- if (_broker.equals(VM))
- {
- // No point running this test in a vm broker
- return;
- }
-
- writeFirewallFile(false, inVhost);
- super.setUp();
-
+ testFirewall(true, inVhost, restartOrReload);
+ }
+
+ /*
+ * Check we can get a connection
+ */
+ private boolean checkConnection() throws Exception
+ {
Exception exception = null;
Connection conn = null;
try
@@ -246,22 +275,27 @@ public class FirewallConfigTest extends QpidTestCase
{
exception = e;
}
- assertNotNull(exception);
- // Check we can get a connection
+ return conn != null;
+ }
+
+ private void testFirewall(boolean initial, boolean inVhost, Runnable restartOrReload) throws Exception
+ {
+ if (_broker.equals(VM))
+ {
+ // No point running this test in a vm broker
+ return;
+ }
+
+ writeFirewallFile(initial, inVhost);
+ super.setUp();
- writeFirewallFile(true, inVhost);
+ assertEquals("Initial connection check failed", initial, checkConnection());
+
+ // Reload changed firewall file after restart or reload
+ writeFirewallFile(!initial, inVhost);
restartOrReload.run();
- exception = null;
- try
- {
- conn = getConnection();
- }
- catch (JMSException e)
- {
- exception = e;
- }
- assertNull(exception);
- }
+ assertEquals("Second connection check failed", !initial, checkConnection());
+ }
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
index cf815fbc05..8f76141bb1 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/ct/DurableSubscriberTest.java
@@ -19,6 +19,10 @@ package org.apache.qpid.test.unit.ct;
import javax.jms.*;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.test.utils.QpidTestCase;
/**
@@ -163,5 +167,301 @@ public class DurableSubscriberTest extends QpidTestCase
durConnection2.close();
}
}
+
+ /**
+ * create and register a durable subscriber without a message selector and then unsubscribe it
+ * create and register a durable subscriber with a message selector and then close it
+ * restart the broker
+ * send matching and non matching messages
+ * recreate and register the durable subscriber with a message selector
+ * verify only the matching messages are received
+ */
+ public void testDurSubChangedToHaveSelectorThenRestart() throws Exception
+ {
+ if (! isBrokerStorePersistent())
+ {
+ _logger.warn("Test skipped due to requirement of a persistent store");
+ return;
+ }
+
+ final String SUB_NAME=getTestQueueName();
+
+ TopicConnectionFactory factory = getConnectionFactory();
+ Topic topic = (Topic) getInitialContext().lookup(_topicName);
+
+ //create and register a durable subscriber then unsubscribe it
+ TopicConnection durConnection = factory.createTopicConnection("guest", "guest");
+ TopicSession durSession = durConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub1 = durSession.createDurableSubscriber(topic, SUB_NAME);
+ durConnection.start();
+ durSub1.close();
+ durSession.unsubscribe(SUB_NAME);
+ durSession.close();
+ durConnection.close();
+
+ //create and register a durable subscriber with a message selector and then close it
+ TopicConnection durConnection2 = factory.createTopicConnection("guest", "guest");
+ TopicSession durSession2 = durConnection2.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub2 = durSession2.createDurableSubscriber(topic, SUB_NAME, "testprop='true'", false);
+ durConnection2.start();
+ durSub2.close();
+ durSession2.close();
+ durConnection2.close();
+
+ //now restart the server
+ try
+ {
+ restartBroker();
+ }
+ catch (Exception e)
+ {
+ _logger.error("problems restarting broker: " + e);
+ throw e;
+ }
+
+ //send messages matching and not matching the selector
+ TopicConnection pubConnection = factory.createTopicConnection("guest", "guest");
+ TopicSession pubSession = pubConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicPublisher publisher = pubSession.createPublisher(topic);
+ for (int i = 0; i < 5; i++)
+ {
+ Message message = pubSession.createMessage();
+ message.setStringProperty("testprop", "true");
+ publisher.publish(message);
+ message = pubSession.createMessage();
+ message.setStringProperty("testprop", "false");
+ publisher.publish(message);
+ }
+ publisher.close();
+ pubSession.close();
+
+ //now recreate the durable subscriber with selector to check there are no exceptions generated
+ //and then verify the messages are received correctly
+ TopicConnection durConnection3 = (TopicConnection) factory.createConnection("guest", "guest");
+ TopicSession durSession3 = (TopicSession) durConnection3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub3 = durSession3.createDurableSubscriber(topic, SUB_NAME, "testprop='true'", false);
+ durConnection3.start();
+
+ for (int i = 0; i < 5; i++)
+ {
+ Message message = durSub3.receive(2000);
+ if (message == null)
+ {
+ fail("testDurSubChangedToHaveSelectorThenRestart test failed. Expected message " + i + " was not returned");
+ }
+ else
+ {
+ assertTrue("testDurSubChangedToHaveSelectorThenRestart test failed. Got message not matching selector",
+ message.getStringProperty("testprop").equals("true"));
+ }
+ }
+
+ durSub3.close();
+ durSession3.unsubscribe(SUB_NAME);
+ durSession3.close();
+ durConnection3.close();
+ }
+
+
+ /**
+ * create and register a durable subscriber with a message selector and then unsubscribe it
+ * create and register a durable subscriber without a message selector and then close it
+ * restart the broker
+ * send matching and non matching messages
+ * recreate and register the durable subscriber without a message selector
+ * verify ALL the sent messages are received
+ */
+ public void testDurSubChangedToNotHaveSelectorThenRestart() throws Exception
+ {
+ if (! isBrokerStorePersistent())
+ {
+ _logger.warn("Test skipped due to requirement of a persistent store");
+ return;
+ }
+
+ final String SUB_NAME=getTestQueueName();
+
+ TopicConnectionFactory factory = getConnectionFactory();
+ Topic topic = (Topic) getInitialContext().lookup(_topicName);
+
+ //create and register a durable subscriber with selector then unsubscribe it
+ TopicConnection durConnection = factory.createTopicConnection("guest", "guest");
+ TopicSession durSession = durConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub1 = durSession.createDurableSubscriber(topic, SUB_NAME, "testprop='true'", false);
+ durConnection.start();
+ durSub1.close();
+ durSession.unsubscribe(SUB_NAME);
+ durSession.close();
+ durConnection.close();
+
+ //create and register a durable subscriber without the message selector and then close it
+ TopicConnection durConnection2 = factory.createTopicConnection("guest", "guest");
+ TopicSession durSession2 = durConnection2.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub2 = durSession2.createDurableSubscriber(topic, SUB_NAME);
+ durConnection2.start();
+ durSub2.close();
+ durSession2.close();
+ durConnection2.close();
+
+ //now restart the server
+ try
+ {
+ restartBroker();
+ }
+ catch (Exception e)
+ {
+ _logger.error("problems restarting broker: " + e);
+ throw e;
+ }
+
+ //send messages matching and not matching the original used selector
+ TopicConnection pubConnection = factory.createTopicConnection("guest", "guest");
+ TopicSession pubSession = pubConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicPublisher publisher = pubSession.createPublisher(topic);
+ for (int i = 1; i <= 5; i++)
+ {
+ Message message = pubSession.createMessage();
+ message.setStringProperty("testprop", "true");
+ publisher.publish(message);
+ message = pubSession.createMessage();
+ message.setStringProperty("testprop", "false");
+ publisher.publish(message);
+ }
+ publisher.close();
+ pubSession.close();
+
+ //now recreate the durable subscriber without selector to check there are no exceptions generated
+ //then verify ALL messages sent are received
+ TopicConnection durConnection3 = (TopicConnection) factory.createConnection("guest", "guest");
+ TopicSession durSession3 = (TopicSession) durConnection3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicSubscriber durSub3 = durSession3.createDurableSubscriber(topic, SUB_NAME);
+ durConnection3.start();
+
+ for (int i = 1; i <= 10; i++)
+ {
+ Message message = durSub3.receive(2000);
+ if (message == null)
+ {
+ fail("testDurSubChangedToNotHaveSelectorThenRestart test failed. Expected message " + i + " was not received");
+ }
+ }
+
+ durSub3.close();
+ durSession3.unsubscribe(SUB_NAME);
+ durSession3.close();
+ durConnection3.close();
+ }
+
+
+ public void testResubscribeWithChangedSelectorAndRestart() throws Exception
+ {
+ if (! isBrokerStorePersistent())
+ {
+ _logger.warn("Test skipped due to requirement of a persistent store");
+ return;
+ }
+
+ Connection conn = getConnection();
+ conn.start();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ AMQTopic topic = new AMQTopic((AMQConnection) conn, "testResubscribeWithChangedSelectorAndRestart");
+ MessageProducer producer = session.createProducer(topic);
+
+ // Create durable subscriber that matches A
+ TopicSubscriber subA = session.createDurableSubscriber(topic,
+ "testResubscribeWithChangedSelector",
+ "Match = True", false);
+
+ // Send 1 matching message and 1 non-matching message
+ TextMessage msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
+ msg.setBooleanProperty("Match", true);
+ producer.send(msg);
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart2");
+ msg.setBooleanProperty("Match", false);
+ producer.send(msg);
+
+ Message rMsg = subA.receive(1000);
+ assertNotNull(rMsg);
+ assertEquals("Content was wrong",
+ "testResubscribeWithChangedSelectorAndRestart1",
+ ((TextMessage) rMsg).getText());
+
+ rMsg = subA.receive(1000);
+ assertNull(rMsg);
+
+ // Send another 1 matching message and 1 non-matching message
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
+ msg.setBooleanProperty("Match", true);
+ producer.send(msg);
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart2");
+ msg.setBooleanProperty("Match", false);
+ producer.send(msg);
+
+ // Disconnect subscriber without receiving the message to
+ //leave it on the underlying queue
+ subA.close();
+
+ // Reconnect with new selector that matches B
+ TopicSubscriber subB = session.createDurableSubscriber(topic,
+ "testResubscribeWithChangedSelectorAndRestart","Match = False", false);
+
+ //verify no messages are now present on the queue as changing selector should have issued
+ //an unsubscribe and thus deleted the previous durable backing queue for the subscription.
+ //check the dur sub's underlying queue now has msg count 1
+ AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "testResubscribeWithChangedSelector");
+ assertEquals("Msg count should be 0", 0, ((AMQSession)session).getQueueDepth(subQueue));
+
+
+ // Check that new messages are received properly
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
+ msg.setBooleanProperty("Match", true);
+ producer.send(msg);
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart2");
+ msg.setBooleanProperty("Match", false);
+ producer.send(msg);
+
+ rMsg = subB.receive(1000);
+ assertNotNull(rMsg);
+ assertEquals("Content was wrong",
+ "testResubscribeWithChangedSelectorAndRestart2",
+ ((TextMessage) rMsg).getText());
+
+ rMsg = subB.receive(1000);
+ assertNull(rMsg);
+
+ //now restart the server
+ try
+ {
+ restartBroker();
+ }
+ catch (Exception e)
+ {
+ _logger.error("problems restarting broker: " + e);
+ throw e;
+ }
+
+ // Check that new messages are still received properly
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart1");
+ msg.setBooleanProperty("Match", true);
+ producer.send(msg);
+ msg = session.createTextMessage("testResubscribeWithChangedSelectorAndRestart2");
+ msg.setBooleanProperty("Match", false);
+ producer.send(msg);
+
+ rMsg = subB.receive(1000);
+ assertNotNull(rMsg);
+ assertEquals("Content was wrong",
+ "testResubscribeWithChangedSelectorAndRestart2",
+ ((TextMessage) rMsg).getText());
+
+ rMsg = subB.receive(1000);
+ assertNull(rMsg);
+
+ session.unsubscribe("testResubscribeWithChangedSelectorAndRestart");
+ subB.close();
+ session.close();
+ conn.close();
+ }
+
}
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
index cafd212dd3..119949b0d6 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/unit/topic/DurableSubscriptionTest.java
@@ -20,8 +20,13 @@
*/
package org.apache.qpid.test.unit.topic;
+import java.io.IOException;
+import java.util.Set;
+
+import org.apache.qpid.management.common.JMXConnnectionFactory;
import org.apache.qpid.test.utils.QpidTestCase;
import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
@@ -39,6 +44,9 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TopicSubscriber;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
/**
* @todo Code to check that a consumer gets only one particular method could be factored into a re-usable method (as
@@ -58,6 +66,36 @@ public class DurableSubscriptionTest extends QpidTestCase
/** Timeout for receive() if we are not expecting a message */
private static final long NEGATIVE_RECEIVE_TIMEOUT = 1000;
+ private JMXConnector _jmxc;
+ private MBeanServerConnection _mbsc;
+ private static final String USER = "admin";
+ private static final String PASSWORD = "admin";
+ private boolean _jmxConnected;
+
+ public void setUp() throws Exception
+ {
+ setConfigurationProperty("management.enabled", "true");
+ _jmxConnected=false;
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception
+ {
+ if(_jmxConnected)
+ {
+ try
+ {
+ _jmxc.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ super.tearDown();
+ }
+
public void testUnsubscribe() throws Exception
{
AMQConnection con = (AMQConnection) getConnection("guest", "guest");
@@ -79,6 +117,12 @@ public class DurableSubscriptionTest extends QpidTestCase
_logger.info("Producer sending message A");
producer.send(session1.createTextMessage("A"));
+
+ ((AMQSession)session1).sync();
+
+ //check the dur sub's underlying queue now has msg count 1
+ AMQQueue subQueue = new AMQQueue("amq.topic", "clientid" + ":" + "MySubscription");
+ assertEquals("Msg count should be 1", 1, ((AMQSession)session1).getQueueDepth(subQueue));
Message msg;
_logger.info("Receive message on consumer 1:expecting A");
@@ -96,11 +140,46 @@ public class DurableSubscriptionTest extends QpidTestCase
msg = consumer2.receive(NEGATIVE_RECEIVE_TIMEOUT);
_logger.info("Receive message on consumer 1 :expecting null");
assertEquals(null, msg);
+
+ ((AMQSession)session2).sync();
+
+ //check the dur sub's underlying queue now has msg count 0
+ assertEquals("Msg count should be 0", 0, ((AMQSession)session2).getQueueDepth(subQueue));
consumer2.close();
_logger.info("Unsubscribe session2/consumer2");
session2.unsubscribe("MySubscription");
-
+
+ ((AMQSession)session2).sync();
+
+ if(isJavaBroker() && isExternalBroker())
+ {
+ //Verify that the queue was deleted by querying for its JMX MBean
+ _jmxc = JMXConnnectionFactory.getJMXConnection(5000, "127.0.0.1",
+ getManagementPort(getPort()), USER, PASSWORD);
+
+ _jmxConnected = true;
+ _mbsc = _jmxc.getMBeanServerConnection();
+
+ //must replace the occurrence of ':' in queue name with '-'
+ String queueObjectNameText = "clientid" + "-" + "MySubscription";
+
+ ObjectName objName = new ObjectName("org.apache.qpid:type=VirtualHost.Queue,name="
+ + queueObjectNameText + ",*");
+
+ Set<ObjectName> objectInstances = _mbsc.queryNames(objName, null);
+
+ if(objectInstances.size() != 0)
+ {
+ fail("Queue MBean was found. Expected queue to have been deleted");
+ }
+ else
+ {
+ _logger.info("Underlying dueue for the durable subscription was confirmed deleted.");
+ }
+ }
+
+ //verify unsubscribing the durable subscriber did not affect the non-durable one
_logger.info("Producer sending message B");
producer.send(session1.createTextMessage("B"));
@@ -459,6 +538,9 @@ public class DurableSubscriptionTest extends QpidTestCase
rMsg = subA.receive(NEGATIVE_RECEIVE_TIMEOUT);
assertNull(rMsg);
+ // Send another 1 matching message and 1 non-matching message
+ sendMatchingAndNonMatchingMessage(session, producer);
+
// Disconnect subscriber
subA.close();
@@ -466,9 +548,15 @@ public class DurableSubscriptionTest extends QpidTestCase
TopicSubscriber subB = session.createDurableSubscriber(topic,
"testResubscribeWithChangedSelector","Match = False", false);
+ //verify no messages are now present as changing selector should have issued
+ //an unsubscribe and thus deleted the previous backing queue for the subscription.
+ rMsg = subB.receive(NEGATIVE_RECEIVE_TIMEOUT);
+ assertNull("Should not have received message as the queue underlying the " +
+ "subscription should have been cleared/deleted when the selector was changed", rMsg);
- // Check messages are recieved properly
+ // Check that new messages are received properly
sendMatchingAndNonMatchingMessage(session, producer);
+
rMsg = subB.receive(NEGATIVE_RECEIVE_TIMEOUT);
assertNotNull(rMsg);
assertEquals("Content was wrong",
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
index d693c7f6c1..9ec0f61351 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java
@@ -17,14 +17,41 @@
*/
package org.apache.qpid.test.utils;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import junit.framework.TestCase;
import junit.framework.TestResult;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQConnectionFactory;
@@ -39,33 +66,8 @@ import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
import org.apache.qpid.server.store.DerbyMessageStore;
import org.apache.qpid.url.URLSyntaxException;
import org.apache.qpid.util.LogMonitor;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.PrintStream;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -86,6 +88,7 @@ public class QpidTestCase extends TestCase
private Map<org.apache.log4j.Logger, Level> _loggerLevelSetForTest = new HashMap<org.apache.log4j.Logger, Level>();
private XMLConfiguration _testConfiguration = new XMLConfiguration();
+ private XMLConfiguration _testVirtualhosts = new XMLConfiguration();
protected static final String INDEX = "index";
@@ -178,9 +181,10 @@ public class QpidTestCase extends TestCase
protected static final String QPID_HOME = "QPID_HOME";
- protected static int DEFAULT_VM_PORT = 1;
- protected static int DEFAULT_PORT = Integer.getInteger("test.port", 5672);
- protected static int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", 8999);
+ public static final int DEFAULT_VM_PORT = 1;
+ public static final int DEFAULT_PORT = Integer.getInteger("test.port", ServerConfiguration.DEFAULT_PORT);
+ public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT);
+ public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.sslport", ServerConfiguration.DEFAULT_SSL_PORT);
protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA);
protected String _broker = System.getProperty(BROKER, VM);
@@ -208,6 +212,7 @@ public class QpidTestCase extends TestCase
protected List<Connection> _connections = new ArrayList<Connection>();
public static final String QUEUE = "queue";
public static final String TOPIC = "topic";
+
/** Map to hold test defined environment properties */
private Map<String, String> _env;
@@ -477,14 +482,16 @@ public class QpidTestCase extends TestCase
{
port = getPort(port);
- // Save any configuratio changes that have been made
+ // Save any configuration changes that have been made
saveTestConfiguration();
+ saveTestVirtualhosts();
Process process = null;
if (_broker.equals(VM))
{
setConfigurationProperty("management.jmxport", String.valueOf(getManagementPort(port)));
saveTestConfiguration();
+
// create an in_VM broker
final ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(_configFile);
try
@@ -608,22 +615,41 @@ public class QpidTestCase extends TestCase
public String getTestConfigFile()
{
String path = _output == null ? System.getProperty("java.io.tmpdir") : _output;
- return path + "/" + getTestQueueName() + ".xml";
+ return path + "/" + getTestQueueName() + "-config.xml";
+ }
+
+ public String getTestVirtualhostsFile()
+ {
+ String path = _output == null ? System.getProperty("java.io.tmpdir") : _output;
+ return path + "/" + getTestQueueName() + "-virtualhosts.xml";
}
protected void saveTestConfiguration() throws ConfigurationException
{
+ // Specifiy the test config file
String testConfig = getTestConfigFile();
- //Specifiy the test configuration
setSystemProperty("test.config", testConfig);
- // This is a work
+ // Create the file if configuration does not exist
if (_testConfiguration.isEmpty())
{
- _testConfiguration.addProperty("test", getTestQueueName());
+ _testConfiguration.addProperty("__ignore", "true");
}
+ _testConfiguration.save(testConfig);
+ }
- _testConfiguration.save(getTestConfigFile());
+ protected void saveTestVirtualhosts() throws ConfigurationException
+ {
+ // Specifiy the test virtualhosts file
+ String testVirtualhosts = getTestVirtualhostsFile();
+ setSystemProperty("test.virtualhosts", testVirtualhosts);
+
+ // Create the file if configuration does not exist
+ if (_testVirtualhosts.isEmpty())
+ {
+ _testVirtualhosts.addProperty("__ignore", "true");
+ }
+ _testVirtualhosts.save(testVirtualhosts);
}
public void cleanBroker()
@@ -690,29 +716,23 @@ public class QpidTestCase extends TestCase
protected void makeVirtualHostPersistent(String virtualhost)
throws ConfigurationException, IOException
{
- Class storeClass = DerbyMessageStore.class;
-
- Class bdb = null;
+ Class<?> storeClass = null;
try
{
- bdb = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
+ // Try and lookup the BDB class
+ storeClass = Class.forName("org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
}
catch (ClassNotFoundException e)
{
// No BDB store, we'll use Derby instead.
- }
-
- if (bdb != null)
- {
- storeClass = bdb;
+ storeClass = DerbyMessageStore.class;
}
- _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
- ".store.class", storeClass.getName());
- _testConfiguration.setProperty("virtualhosts.virtualhost." + virtualhost +
- ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
- "${QPID_WORK}/" + virtualhost);
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store.class",
+ storeClass.getName());
+ setConfigurationProperty("virtualhosts.virtualhost." + virtualhost + ".store." + DerbyMessageStore.ENVIRONMENT_PATH_PROPERTY,
+ "${QPID_WORK}/" + virtualhost);
}
/**
@@ -730,6 +750,7 @@ public class QpidTestCase extends TestCase
// Call save Configuration to be sure we have saved the test specific
// file. As the optional status
saveTestConfiguration();
+ saveTestVirtualhosts();
ServerConfiguration configuration = new ServerConfiguration(_configFile);
return configuration.getConfig().getString(property);
@@ -753,9 +774,15 @@ public class QpidTestCase extends TestCase
protected void setConfigurationProperty(String property, String value)
throws ConfigurationException, IOException
{
- //Write the value in to this configuration file which will override the
- // defaults.
- _testConfiguration.setProperty(property, value);
+ // Choose which file to write the property to based on prefix.
+ if (property.startsWith("virtualhosts"))
+ {
+ _testVirtualhosts.setProperty(StringUtils.substringAfter(property, "virtualhosts."), value);
+ }
+ else
+ {
+ _testConfiguration.setProperty(property, value);
+ }
}
/**
diff --git a/qpid/java/test-profiles/Excludes b/qpid/java/test-profiles/Excludes
index ccb907e597..05f68cbe9d 100644
--- a/qpid/java/test-profiles/Excludes
+++ b/qpid/java/test-profiles/Excludes
@@ -29,3 +29,5 @@ org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverTest#testClientAck
org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverOnMessageTest#*
org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverTest#*
+// QPID-2418 : The queue backing the dur sub is not currently deleted at subscription change, so the test will fail.
+org.apache.qpid.test.unit.ct.DurableSubscriberTest#testResubscribeWithChangedSelectorAndRestart
diff --git a/qpid/java/test-profiles/JavaExcludes b/qpid/java/test-profiles/JavaExcludes
index 184a6f9e78..6b9f22fd93 100644
--- a/qpid/java/test-profiles/JavaExcludes
+++ b/qpid/java/test-profiles/JavaExcludes
@@ -16,6 +16,3 @@ org.apache.qpid.client.SessionCreateTest#*
// QPID-2097 exclude it from the InVM test runs until InVM JMX Interface is reliable
org.apache.qpid.management.jmx.ManagementActorLoggingTest#*
org.apache.qpid.server.queue.ModelTest#*
-
-//QPID-2422: Derby currently doesnt persist queue arguments and 0-91 support causes exclusivity mismatch after restart
-org.apache.qpid.test.unit.ct.DurableSubscriberTest#*
diff --git a/qpid/java/test-profiles/log4j-test.xml b/qpid/java/test-profiles/log4j-test.xml
index 2d77942a81..39d30d104a 100644
--- a/qpid/java/test-profiles/log4j-test.xml
+++ b/qpid/java/test-profiles/log4j-test.xml
@@ -51,6 +51,10 @@
<level value="WARN"/>
</logger>
+ <logger name="apache.commons.configuration.ConfigurationFactory">
+ <level value="ERROR"/>
+ </logger>
+
<root>
<level value="${root.logging.level}"/>
<appender-ref ref="console" />
diff --git a/qpid/python/qpid/messaging/endpoints.py b/qpid/python/qpid/messaging/endpoints.py
index 195c6e7ef7..3a23cd6e28 100644
--- a/qpid/python/qpid/messaging/endpoints.py
+++ b/qpid/python/qpid/messaging/endpoints.py
@@ -294,22 +294,23 @@ class Session:
The options map permits the following parameters::
<name> [ / <subject> ] ; {
- create: <create-policy>,
- delete: <delete-policy>,
- assert: <assert-policy>,
+ create: always | sender | receiver | never,
+ delete: always | sender | receiver | never,
+ assert: always | sender | receiver | never,
+ mode: browse | consume,
node: {
- type: <node-type>,
- durable: <node-durability>,
- x-declare: { ... <queue-declare overrides> ... }
+ type: queue | topic,
+ durable: True | False,
+ x-declare: { ... <declare-overrides> ... },
x-bindings: [<binding_1>, ... <binding_n>]
- }
+ },
link: {
name: <link-name>,
- durable: <link-durability>,
- reliability: <link-reliability>,
- x-declare: { ... <queue-declare overrides> ... }
- x-bindings: [<binding_1>, ... <binding_n>]
- x-subscribe: { ... <message-subscribe overrides> ... }
+ durable: True | False,
+ reliability: unreliable | at-most-once | at-least-once | exactly-once,
+ x-declare: { ... <declare-overrides> ... },
+ x-bindings: [<binding_1>, ... <binding_n>],
+ x-subscribe: { ... <subscribe-overrides> ... }
}
}
@@ -337,8 +338,9 @@ class Session:
- I{queue}: this is the default node-type
The x-declare map permits protocol specific keys and values to be
- specified. These keys and values are passed through when creating a
- node or asserting facts about an existing node.
+ specified when exchanges or queues are declared. These keys and
+ values are passed through when creating a node or asserting facts
+ about an existing node.
Examples
--------
diff --git a/qpid/tests/LICENSE.txt b/qpid/tests/LICENSE.txt
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/qpid/tests/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git a/qpid/tests/NOTICE.txt b/qpid/tests/NOTICE.txt
new file mode 100644
index 0000000000..32ccdb70c4
--- /dev/null
+++ b/qpid/tests/NOTICE.txt
@@ -0,0 +1,20 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Qpid distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
+
+Aside from contributions to the Apache Qpid project, this software also
+includes (binary only):
+
+ - None at this time
+
+
+
diff --git a/qpid/tools/LICENSE.txt b/qpid/tools/LICENSE.txt
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/qpid/tools/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git a/qpid/tools/NOTICE.txt b/qpid/tools/NOTICE.txt
new file mode 100644
index 0000000000..32ccdb70c4
--- /dev/null
+++ b/qpid/tools/NOTICE.txt
@@ -0,0 +1,20 @@
+=========================================================================
+== NOTICE file corresponding to the section 4 d of ==
+== the Apache License, Version 2.0, ==
+== in this case for the Apache Qpid distribution. ==
+=========================================================================
+
+This product includes software developed by the Apache Software Foundation
+(http://www.apache.org/).
+
+Please read the LICENSE.txt file present in the root directory of this
+distribution.
+
+
+Aside from contributions to the Apache Qpid project, this software also
+includes (binary only):
+
+ - None at this time
+
+
+