You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2013/02/18 11:18:29 UTC

svn commit: r1447183 [2/7] - in /qpid/branches/java-broker-config-qpid-4390: ./ qpid/ qpid/bin/ qpid/cpp/bindings/ qpid/cpp/bindings/qpid/dotnet/ qpid/cpp/bindings/qpid/examples/perl/ qpid/cpp/bindings/qpid/perl/ qpid/cpp/bindings/qpid/perl/lib/ qpid/c...

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,56 +15,59 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
-    # Establishes a connection to a remote endpoint.
+    # A +Connection+ represents a network connection to a remote endpoint.
     class Connection
 
       attr_reader :options # :nodoc:
 
-      # Creates a connection object, but does not actually connect to
-      # the specified location.
+      # Creates a connection object. Raises a MessagingError if an invalid
+      # connection option is used.
       #
-      # ==== Options
+      # == Options
       #
-      #   :url - the URL for the broker (def. +"localhost"+)
-      #   :options - connection options (def. +{}+)
+      # * +:url+ - the URL for the broker
+      # * +:options+ - connection options
       #
-      # ==== Controlling Reconnect Behavior
+      # == Controlling Reconnect Behavior
       #
       # The following connection options can be used to configure
       # the reconnection behavior for this connection.
       #
-      # * :username
-      # * :password
-      # * :heartbeat
-      # * :tcp_nodelay
-      # * :sasl_mechanism
-      # * :sasl_service
-      # * :sasl_min_ssf
-      # * :sasl_max_ssf
-      # * :transport
-      # * :reconnect - +true+ or +false+; indicates wehtehr to attempt reconnections
-      # * :reconnect_timeout - the number of seconds to attempt reconnecting
-      # * :reconnect_limit - the number of retries before reporting failure
-      # * :reconnect_interval_min - initial delay, in seconds, before attempting a reconnection
-      # * :reconnect_interval_max - number of seconds to wait before additional reconnect attempts
-      # * :reconnect_interval - shorthand for setting both min and max values
-      # * :reconnect_urls - a list of alternate URLs to use for reconnection attempts
+      # * +:username+ - the authentication username
+      # * +:password+ - the authentication password
+      # * +:heartbeat+
+      # * +:tcp_nodelay+
+      # * +:sasl_mechanism+
+      # * +:sasl_service+
+      # * +:sasl_min_ssf+
+      # * +:sasl_max_ssf+
+      # * +:transport+
+      # * +:reconnect+ - indicates whether to attempt reconnections
+      # * +:reconnect_timeout+ - the number of seconds to attempt reconnecting
+      # * +:reconnect_limit+ - the number of retries before reporting failure
+      # * +:reconnect_interval_min+ - initial delay, in seconds, before attempting a reconnection
+      # * +:reconnect_interval_max+ - number of seconds to wait before additional reconnect attempts
+      # * +:reconnect_interval+ - shorthand for setting both min and max values
+      # * +:reconnect_urls+ - a list of alternate URLs to use for reconnection attempts
       #
-      # ==== Examples
+      # == Examples
       #
+      #   # creates a connection to the broker running local *localhost*
       #   conn = Qpid::Messaging::Connnection.new
+      #   # creates a connection to *broker1.domain.com* on port *5672*
       #   conn = Qpid::Messaging::Connection.new :url => "amqp:tcp:broker1.domain.com:5672"
+      #   # creates a connection to localhost with the specified authentication credentials
       #   conn = Qpid::Messaging::Connection.new :options => {:username => "login", :password => "password"}
       #
       def initialize(opts = {})
         @url = opts[:url] || "localhost"
-        @options = convert_options(opts[:options] || {})
+        @options = Qpid::Messaging.stringify(opts[:options] || {})
         @connection_impl = opts[:impl] || Cqpid::Connection.new(@url, @options)
       end
 
@@ -74,8 +77,9 @@ module Qpid
 
       # Establishes the connection.
       #
-      # ==== Examples
+      # == Examples
       #
+      #   # open a connection if it's not already open
       #   conn.open unless conn.open?
       #
       def open
@@ -84,25 +88,34 @@ module Qpid
 
       # Reports whether the connection is open.
       #
-      # ==== Examples
+      # == Examples
       #
+      #   # close the connection if it's not already closed
       #   conn.close if conn.open?
       #
       def open?; true && !@connection_impl.nil? && @connection_impl.isOpen; end
 
       # Closes the connection.
+      #
+      # == Examples
+      #
+      #   # close a connection
+      #   conn.close
+      #
       def close; @connection_impl.close; end
 
       # Creates a new session.
       #
-      # ==== Arguments
+      # == Arguments
       #
-      # * :name - specifies the name for this session
-      # * :transactional - if +true+ then a creates a transaction session (def. +false+)
+      # * +:name+ - specifies the name for this session
+      # * +:transactional+ - if +true+ then a creates a transaction session (def. +false+)
       #
-      # ==== Examples
+      # == Examples
       #
+      #   # create a session named 'session1'
       #   session = conn.create_session :name => "session1"
+      #   # create a transactional session
       #   session = conn.create_session :transaction => true
       #
       def create_session(args = {})
@@ -119,26 +132,42 @@ module Qpid
         end
       end
 
-      # Returns a session for the specified session name.
+      # Returns a Session with the given name. Raises an exception if no
+      # session with the given name exists.
+      #
+      # == Options
       #
-      # ==== Examples
+      # * +name+ - the existing session's name
       #
+      # == Examples
+      #
+      #   # retrieve a session named 'mysession' from the current connection
+      #   name = "my-session"
+      #   # if no such session exists then catchh the exception raised
       #   begin
-      #     session = conn.session "mysession"
-      #   rescue SessionNameException => error
-      #      puts "No such session."
+      #     session = conn.session name
+      #   rescue MessagingException => error
+      #      puts "No such session: #{name}."
       #   end
       #
       def session name
-        begin
-          session_impl = @connection_impl.getSession name
-          Qpid::Messaging::Session.new self, session_impl if session_impl
-        rescue
-          raise Qpid::Messaging::SessionNameException.new "No such session: #{name}"
-        end
+        session_impl = @connection_impl.getSession name
+        Qpid::Messaging::Session.new self, session_impl if session_impl
       end
 
       # Returns the username used to authenticate with the connection.
+      #
+      # If the connection did not user authentication credentials, then the
+      # username returned is "anonymous".
+      #
+      # == Examples
+      #
+      #   # create a new connection for user "qpiduser"
+      #   conn = Qpid::Messaging::Connection.new :username => "qpiduser"
+      #   conn.open
+      #   # displays the authenticate username
+      #   puts "Connected as #{conn.authenticated_username}" # should say 'qpiduser'
+      #
       def authenticated_username; @connection_impl.getAuthenticatedUsername if open?; end
 
       private

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/duration.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/duration.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/duration.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/duration.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,7 +15,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
@@ -23,19 +23,21 @@ module Qpid
 
     # A Duration represents a period of time in milliseconds
     #
-    # It defines the following named values as symbols:
+    # == Named Durations
+    #
+    # The following named +Durations+ are available as symbols:
     #
-    # [:FOREVER]
+    # [FOREVER]
     #   The maximum integer value for the platform. Effectively this will wait
     #   forever.
     #
-    # [:IMMEDIATE]
+    # [IMMEDIATE]
     #   An alias for 0 milliseconds.
     #
-    # [:SECOND]
+    # [SECOND]
     #   An alias for 1,000 milliseconds.
     #
-    # [:MINUTE]
+    # [MINUTE]
     #   And alias for 60,000 millisecons.
     #
     class Duration
@@ -44,12 +46,13 @@ module Qpid
       #
       # ==== Options
       #
-      # * length - The duration in milliseconds.
+      # * +length+ - The duration in +milliseconds+.
       #
       # ==== Examples
       #
-      #   # Wait up to 10 seconds for an incoming message
-      #   receiver.get Qpid::Messaging::Duration.new 10000
+      #   # creates a duration of 15 seconds
+      #   # REMEMBER: Duration deals in milliseconds
+      #   delay = Qpid::Messaging::Duration.new 15000
       #
       def initialize length
         @duration_impl = Cqpid::Duration.new length
@@ -59,26 +62,42 @@ module Qpid
         @duration_impl
       end
 
-      # Returns the period of time in milliseconds
+      # Returns the period of time in +milliseconds+.
       #
       # ==== Examples
       #
-      #   duration = Qpid::Messaging::Duration.new :length => 5000
-      #   puts "Waiting #{duration.milliseconds} ms for a message."
-      #   msg = receiver.fetch duration
+      #   # doubling growth in waiting for messages in a loop
+      #   do loop
+      #     set the base duration waiting length
+      #     timeout = Qpid::Messaging::Duration::SECOND
+      #     msg = nil
+      #     # loop until we receive a message
+      #     while msg.nil?
+      #       puts "Waiting #{timeout.milliseconds}ms"
+      #       msg = recv.get timeout
+      #       # if nothing was received, double the duration
+      #       if msg.nil?
+      #         # double out timeout
+      #         timeout = timeout * 2
+      #       else
+      #         # do something with the message
+      #         puts "Received: #{msg.content}"
+      #       end
+      #     end
+      #   end
       #
       def milliseconds
         @duration_impl.getMilliseconds
       end
 
-      # Returns a new Duration with a period of time that is a multiple
-      # of the original Duration.
+      # Multiplies the duration of the +Duration+ and returns a new instance.
       #
       # Raises exceptions on a negative factor. Returns
       # Qpid::Messaging::Duration::IMMEDIATE when the factor is 0.
       #
       # ==== Examples
       #
+      #   # return a duration that is 2 minutes (120,000 ms)
       #   twominutes = Qpid::Messaging::Duration::MINUTE * 2
       #
       def *(factor)

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/encoding.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,43 +15,60 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
     # Encodes the supplied content into the given message.
-    def self.encode content, message, encoding = nil
-      prepared = content
-      case content
-      when Hash
-        prepared = {}
-        content.each_pair do |key,value|
-          prepared[key.to_s] = value.to_s
-        end
-        Cqpid::encode prepared, message.message_impl
-      when Array
-        prepared = []
-        content.each {|value| prepared << value.to_s}
-        Cqpid::encode prepared, message.message_impl
-      end
+    def self.encode content, message, encoding = nil # :nodoc:
+      Cqpid::encode content, message.message_impl, encoding
     end
 
     # Decodes and returns the message's content.
-    def self.decode(message, content_type = nil)
-      content_type = message.content_type unless content_type
+    def self.decode(message, content_type = nil) # :nodoc:
+      content_type = message.content_type if content_type.nil?
 
       case content_type
         when "amqp/map"
-          Cqpid.decodeMap message.message_impl
+          return Cqpid.decodeMap message.message_impl
         when "amqp/list"
-          Cqpid.decodeList message.message_impl
+          return Cqpid.decodeList message.message_impl
       end
 
       message.content
     end
 
+    # Takes as input any type and converts anything that's a symbol
+    # into a string.
+    def self.stringify(value) # :nodoc:
+      # set the default value
+      result = value
+
+      case value
+
+      when Symbol
+        result = value.to_s
+
+      when Hash
+        result = {}
+        value.each_pair do |key, value|
+          result[stringify(key)] = stringify(value)
+        end
+
+      when Array
+        result = []
+        value.each do |element|
+          result  << stringify(element)
+        end
+
+      end
+
+      return result
+
+    end
+
   end
 
 end

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/message.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,27 +15,26 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
     # A +Message+ represents an routable piece of information.
-    #
-    # The content for a message is automatically encoded and decoded.
-    #
     class Message
 
-      # Creates a new instance of +Message+.
+      # Creates a +Message+.
       #
       # ==== Options
       #
-      # * :content - The content.
+      # * +:content+ - the content
       #
       # ==== Examples
       #
+      #   # create a simple message and sends it
       #   message = Qpid::Messaging::Message.new :content => "This is a message."
+      #   sender.send message
       #
       def initialize(args = {})
         @message_impl = (args[:impl] if args[:impl]) || nil
@@ -49,54 +48,48 @@ module Qpid
         @message_impl
       end
 
-      # Sets the address to which replies should be sent for the +Message+.
+      # Sets the reply-to address.
       #
-      # *NOTE:* The address must be an instance of Address.
+      # The address can either be an instance of Address or else and
+      # address string.
       #
       # ==== Options
       #
-      # * address - an instance of +Address+
+      # * +address+ - the address
       #
       # ==== Examples
       #
+      #   # set replies using an Address
       #   msg.reply_to = Qpid:Messaging::Address.new "my-responses"
+      #   # set replies using an address string
+      #   msg.reply_to = "my-feed/responses"
       #
       def reply_to=(address)
-        raise ArgumentError, "Agument must be an Address" unless address.is_a? Qpid::Messaging::Address
+        address = Qpid::Messaging::Address.new "#{address}" if !address.is_a? Qpid::Messaging::Address
+
         @message_impl.setReplyTo address.address_impl
       end
 
       # Returns the reply to address for the +Message+.
-      #
       def reply_to
         address_impl = @message_impl.getReplyTo
         # only return an address if a reply to was specified
-        Qpid::Messaging::Address.new(nil, nil, nil, nil, address_impl) if address_impl
+        Qpid::Messaging::Address.new(nil, address_impl) if address_impl
       end
 
       # Sets the subject for the +Message+.
       #
       # ==== Options
       #
-      # * subject - the subject
-      #
-      # ==== Examples
-      #
-      #   msg.subject = "mysubject"
-      #
+      # * +subject+ - the subject
       def subject=(subject); @message_impl.setSubject subject; end
 
       # Returns the subject of the +Message+.
-      #
-      # ==== Options
-      #
-      #   puts "The subject is #{msg.subject}"
-      #
       def subject; @message_impl.getSubject; end
 
       # Sets the content type for the +Message+.
       #
-      # This should be set by the sending applicaton and indicates to
+      # This should be set by the sending application and indicates to the
       # recipients of the message how to interpret or decode the content.
       #
       # By default, only dictionaries and maps are automatically given a content
@@ -105,23 +98,17 @@ module Qpid
       #
       # ==== Options
       #
-      # * content_type - the content type.
-      #
-      def content_type=(content_type); @message_impl.setContentType content_type; end
-
-      # Returns the content type for the +Message+.
+      # * +content_type+ - the content type
       #
       # ==== Examples
       #
-      #   case msg.content_type
-      #     when "myapp/image"
-      #       ctl.handle_image msg
-      #       end
-      #     when "myapp/audio"
-      #       ctl.handle_audio msg
-      #       end
-      #   end
+      #   # send base64 encoded data in a mesage
+      #   msg = Qpid::Messaging::Message.new :content = "UXBpZCBSdWxlcyEK"
+      #   msg.content_type = "application/base64"
       #
+      def content_type=(content_type); @message_impl.setContentType content_type; end
+
+      # Returns the content type for the +Message+.
       def content_type; @message_impl.getContentType; end
 
       # Sets the message id.
@@ -131,16 +118,17 @@ module Qpid
       #
       # ==== Options
       #
-      # * id - the id
+      # * +id+ - the id
       #
       # ==== Examples
       #
+      #   # this example only works in Ruby >= 1.9, for 1.8 use a UUID library
+      #   require 'SecureRandom'
+      #   msg.message_id = SecureRandom.uuid
       #
       def message_id=(message_id); @message_impl.setMessageId message_id.to_s; end
 
       # Returns the message id.
-      #
-      # See +message_id=+ for details.
       def message_id; @message_impl.getMessageId; end
 
       # Sets the user id for the +Message+.
@@ -149,44 +137,38 @@ module Qpid
       # the connection itself, as the messaging infrastructure will verify
       # this.
       #
-      # See +Qpid::Messaging::Connection.authenticated_username+
+      # See Qpid::Messaging::Connection.authenticated_username
       #
       # *NOTE:* If the id is not a +String+ then the id is set using
       # the object's string representation.
       #
       # ==== Options
       #
-      # * id - the id
+      # * +id+ - the id
       #
       def user_id=(user_id); @message_impl.setUserId user_id; end
 
       # Returns the user id for the +Message+.
-      #
-      # See +user_id=+ for details.
-      #
       def user_id; @message_impl.getUserId; end
 
       # Sets the correlation id of the +Message+.
       #
       # The correlation id can be used as part of a protocol for message
-      # exchange patterns; e.g., a requestion-response pattern might require
+      # exchange patterns; e.g., a request-response pattern might require
       # the correlation id of the request and the response to match, or it
       # might use the message id of the request as the correlation id on
-      # the response
+      # the response.
       #
       # *NOTE:* If the id is not a +String+ then the id is setup using
       # the object's string representation.
       #
       # ==== Options
       #
-      # * id - the id
+      # * +id+ - the id
       #
       def correlation_id=(correlation_id); @message_impl.setCorrelationId correlation_id; end
 
       # Returns the correlation id of the +Message+.
-      #
-      # *NOTE:* See +correlation_id=+ for details.
-      #
       def correlation_id; @message_impl.getCorrelationId; end
 
       # Sets the priority of the +Message+.
@@ -200,19 +182,21 @@ module Qpid
       #
       # ==== Options
       #
-      # * priority - the priority
+      # * +priority+ - the priority
       #
       def priority=(priority); @message_impl.setPriority priority; end
 
       # Returns the priority for the +Message+.
-      #
       def priority; @message_impl.getPriority; end
 
       # Sets the time-to-live in milliseconds.
       #
+      # This can be used by the messaging infrastructure to discard messages
+      # that are no longer of relevance.
+      #
       # ==== Options
       #
-      # * duration - the number of milliseconds
+      # * +duration+ - the number of milliseconds
       #
       def ttl=(duration)
         if duration.is_a? Qpid::Messaging::Duration
@@ -229,16 +213,15 @@ module Qpid
       #
       # This is a hint to the messaging infrastructure that the message
       # should be persisted or otherwise stored. This helps to ensure
-      # that th emessage is not lost during to failures or a shutdown.
+      # that the message is not lost due to failures or a shutdown.
       #
       # ==== Options
       #
-      # * durable - the durability flag (def. false)
+      # * +durable+ - the durability flag (def. false)
       #
       def durable=(durable); @message_impl.setDurable durable; end
 
       # Returns the durability for the +Message+.
-      #
       def durable; @message_impl.getDurable; end
 
       # This is a hint to the messaging infrastructure that if de-duplication
@@ -247,17 +230,16 @@ module Qpid
       #
       # ==== Options
       #
-      # * redelivered - sets the redelivered state (def. false)
+      # * +redelivered+ - sets the redelivered state (def. false)
       #
       # ==== Examples
       #
-      #   # processed is an array of processed message ids
+      #   # processed is a collection of messages already received
       #   msg.redelivered = true if processed.include? msg.message_id
       #
       def redelivered=(redelivered); @message_impl.setRedelivered redelivered; end
 
       # Returns whether the +Message+ has been marked as redelivered.
-      #
       def redelivered; @message_impl.getRedelivered; end
 
       # Returns all named properties.
@@ -265,14 +247,13 @@ module Qpid
       # *NOTE:* It is recommended to use the []= method for
       # retrieving and setting properties. Using this method may
       # result in non-deterministic behavior.
-      #
       def properties; @message_impl.getProperties; end
 
       # Returns the value for the named property.
       #
       # ==== Options
       #
-      # * name - the property name
+      # * +name+ - the property name
       #
       # ==== Examples
       #
@@ -283,44 +264,51 @@ module Qpid
 
       # Assigns a value to the named property.
       #
-      # *NOTE:* Both the key or the value may be a symbol, but they will
-      # both be converted to a +String+ for ease of transport.
+      # A property's name or value, if a symbol, will be converted to a string
+      # representation. However, you will still be able to access them using
+      # a symbol for the name.
       #
       # ==== Options
       #
-      # * name - the property name
-      # * value - the property value
-      def []=(key, value); @message_impl.setProperty(key.to_s, value.to_s); end
+      # * +name+ - the property name
+      # * +value+ - the property value
+      #
+      # ==== Examples
+      #
+      #   # set the signed attribute on a message and then retrieve it
+      #   msg[:signed] = true # sets "signed" => true
+      #   puts "It's signed" if msg["signed"] # outputs "It's signed"
+      #
+      def []=(key, value)
+        @message_impl.setProperty(key.to_s,
+                                  Qpid::Messaging.stringify(value))
+      end
 
       # Sets the content for the +Message+.
       #
       # Content is automatically encoded for Array and Hash types. Other types
-      # need to set their own content types (via +content_type+) in order to
+      # need to set their own content types (via content_type) in order to
       # specify how recipients should process the content.
       #
       # ==== Options
       #
-      # * content - the content
+      # * +content+ - the content
       #
       # ==== Examples
       #
-      #   msg.content = "This is a simple message." # a simple message
-      #   msg.content = {:foo => :bar} # content is automatically encoded
+      #   # set a simple content for a message
+      #   msg.content = "This is a simple message."
+      #   # sets content that is automatically encoded
+      #   msg.content = {:foo => :bar}
       #
       def content=(content)
         content_type = nil
-        @content = content
+        @content = Qpid::Messaging.stringify(content)
         case @content
         when Hash
           content_type = "amqp/map"
-          new_content  = {}
-          content.each_pair{|key, value| new_content[key.to_s] = value.to_s}
-          @content = new_content
         when Array
-          new_content  = []
           content_type = "amqp/list"
-          content.each {|element| new_content << element.to_s}
-          @content = new_content
         end
         if content_type.nil?
           @message_impl.setContent @content
@@ -354,8 +342,7 @@ module Qpid
         @content
       end
 
-      # Returns the content's size.
-      #
+      # Returns the content's size in bytes.
       def content_size; @message_impl.getContentSize; end
 
     end

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/receiver.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/receiver.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/receiver.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/receiver.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,23 +15,32 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
-    # Receiver is the entity through which messages are received.
+    # +Receiver+ is the entity through which messages are received.
     #
-    # An instance of Receiver can only be created using an active (not
-    # previously closed) Session.
+    # An instance of +Receiver+ can only be created using an active (i.e., not
+    # previously closed) Session. See Qpid::Messaging::Session.create_receiver
+    # for more details.
     #
     # ==== Example
     #
+    #   # create a connection and a session
     #   conn     = Qpid::Messaging::Connection.new :url => "mybroker:5762"
     #   conn.open
     #   session  = conn.create_session
-    #   receiver = session.create_receiver "my-sender-queue"
+    #
+    #   # create a receiver that listens on the "updates" topic of "alerts"
+    #   receiver = session.create_receiver "alerts/updates"
+    #
+    #   # wait for an incoming message and process it
+    #   incoming = receiver.get Qpid::Messaging::Duration::FOREVER
+    #   process(incoming)
+    #
     class Receiver
 
       def initialize(session, receiver_impl) # :nodoc:
@@ -46,27 +55,24 @@ module Qpid
       # Retrieves a message from the local queue, or waits for up to
       # the duration specified for one to become available.
       #
-      # If a block is given, then it will be invaked after the next message
-      # is received or the call times out, passing in the message or nil
-      # respectively.
+      # If no message is received within the specified time then a
+      # MessagingException is raised.
       #
       # ==== Options
-      # * duration - the timeout to wait (def. Duration::FOREVER)
-      #
-      # ==== Examples
       #
-      #   msg = rcvr.get # Uses the default timeout of forever
+      # * duration - the timeout to wait
       #
-      #   msg = rcvr.get Qpid::Messaging::Duration::IMMEDIATE # returns a message or exits immediately
+      # ==== Examples
       #
-      #   # passes in a block to handle the received message
-      #   rcvr.get Qpid::Messaging::Duration::SECOND do |message|
-      #     if message.nil?
-      #       puts "No message was received."
-      #     else
-      #       puts "Received this message: #{message.content}"
-      #     end
+      #   # retrieves a message, also handles exceptions raised on no messages
+      #   begin
+      #     # checks for a message, returning immediately
+      #     msg = recv.get Qpid::Messaging::Duration::IMMEDIATE
+      #     puts "Received this message: #{message.content}"
+      #   rescue
+      #     puts "No messages available.
       #   end
+      #
       def get(duration = Qpid::Messaging::Duration::FOREVER)
         message_impl = @receiver_impl.get duration.duration_impl
         create_message_wrapper message_impl unless message_impl.nil?
@@ -75,33 +81,35 @@ module Qpid
       # Retrieves a message from the receiver's subscription, or waits
       # for up to the duration specified for one to become available.
       #
-      # If a block is given, then it will be invaked after the next message
-      # is received or the call times out, passing in the message or nil
-      # respectively.
+      # If no message is fetched within the specified time then a
+      # MessagingException is raised.
       #
       # ==== Options
+      #
       # * duration - the timeout to wait (def. Duration::FOREVER)
       #
       # ==== Examples
       #
-      #   msg = rcvr.fetch # Uses the default timeout of forever
-      #
-      #   msg = rcvr.fetch Qpid::Messaging::Duration::IMMEDIATE # returns a message or exits immediately
-      #
-      #   # passes in a block to handle the received message
-      #   rcvr.fetch Qpid::Messaging::Duration::SECOND do |message|
-      #     if message.nil?
-      #       puts "No message was received."
-      #     else
-      #       puts "Received this message: #{message.content}"
-      #     end
+      #   # retrieves a message, also handles exceptions raised on no messages
+      #   begin
+      #     # checks for a message, times out after one second
+      #     msg = recv.fetch Qpid::Messaging::Duration::SECOND
+      #     puts "Fetched this message: #{message.content}"
+      #   rescue
+      #     puts "No messages available.
       #   end
+      #
       def fetch(duration = Qpid::Messaging::Duration::FOREVER)
         message_impl = @receiver_impl.fetch duration.duration_impl
         create_message_wrapper message_impl unless message_impl.nil?
       end
 
-      # Sets the capacity for this +Receiver+.
+      # Sets the capacity.
+      #
+      # The capacity of a +Receiver+ is the number of Messages that can be
+      # pre-fetched from the broker and held locally. If capacity is 0 then
+      # messages will never be pre-fetched and all messages must instead be
+      # retrieved using #fetch.
       #
       # ==== Options
       #
@@ -109,63 +117,50 @@ module Qpid
       #
       # ==== Examples
       #
-      #   receiver.capacity = 50 # sets the incoming capacity to 50 messages
+      #   # create a receiver and give it a capacity of 50
+      #   recv = session.create_receiver "alerts/minor"
+      #   recv.capacity = 50
       #
       def capacity=(capacity); @receiver_impl.setCapacity capacity; end
 
       # Returns the capacity.
-      #
-      #
-      # The capacity is the numnber of incoming messages that can be held
-      # locally before being fetched.
-      #
-      # ==== Examples
-      #
-      #   puts "The receiver can hold #{rcv.capacity} messages."
-      #
       def capacity; @receiver_impl.getCapacity; end
 
-      # Returns the number of slots for receiving messages.
+      # Returns the number of messages locally held.
+      #
+      # The available is always 0 <= available <= capacity.
       #
-      # This differs from +capacity+ in that it is the available slots in
-      # the capacity for holding incoming messages, where available <= capacity.
+      # If the #capacity is set to 0 then available will always be 0.
       #
       # ==== Examples
       #
-      #   puts "You can receive #{rcv.available} messages before blocking."
+      #   # output the number of messages waiting while processing
+      #   loop do
+      #     puts "There are #{recv.available} messages pending..."
+      #     # wait forever (the default) for the next message
+      #     msg = recv.get
+      #     # process the message
+      #     dispatch_message msg
+      #   end
       #
       def available; @receiver_impl.getAvailable; end
 
       # Returns the number of messages that have been received and acknowledged
       # but whose acknowledgements have not been confirmed by the sender.
-      #
-      # ==== Examples
-      #
-      #   puts "You have #{rcv.unsettled} messages to be confirmed."
-      #
       def unsettled; @receiver_impl.getUnsettled; end
 
       # Closes this +Receiver+.
       #
-      # This does not affect the +Session+.
+      # This does not affect the owning Session or Connection.
       def close; @receiver_impl.close; end
 
-      # Returns whether the receiver is closed.
-      #
-      # ==== Examples
-      #
-      #   recv.close unless recv.closed?
-      #
+      # Returns whether the +Receiver+ is closed.
       def closed?; @receiver_impl.isClosed; end
 
       # Returns the name of this +Receiver+.
-      #
-      # ==== Examples
-      #
-      #   puts "Receiver: #{recv.name}"
       def name; @receiver_impl.getName; end
 
-      # Returns the Session for this +Receiver+.
+      # Returns the owning Session for this +Receiver+.
       def session; @session; end
 
       private

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/sender.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/sender.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/sender.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/sender.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,23 +15,39 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
-    # Sender is the entity through which messages sent.
+    # +Sender+ is the entity through which messages are sent.
     #
-    # An instance of Sender can only be created using an active (not previously
-    # closed) Session.
+    # An instance of +Sender+ can only be created using an active (not previously
+    # closed) Session. See Qpid::Messaging::Session.create_sender for more details.
     #
     # ==== Examples
     #
-    #   conn    = Qpid::Messaging::Connection.new :url => "mybroker:5762"
+    #   # create a connection
+    #   conn = Qpid::Messaging::Connection.new "mybroker:5672"
     #   conn.open
-    #   session = conn.create_session
-    #   sender  = session.create_session "my-sender-queue;{create:always}"
+    #
+    #   if conn.open?
+    #
+    #     # create a session
+    #     session = conn.create_session
+    #
+    #     # create a sender that posts messages to the "updates" queue
+    #     sender = session.create_sender "updates;{create:always}
+    #
+    #     # begin sending updates
+    #     loop do
+    #       # wait for the next event content then send it
+    #       content = wait_for_event
+    #       sender.send Qpid::Messaging::Message.new :content => content
+    #     end
+    #   end
+    #
     class Sender
 
       def initialize(session, sender_impl) # :nodoc:
@@ -43,15 +59,13 @@ module Qpid
         @sender_impl
       end
 
-      # Sends a message.
-      #
-      # If a block is given, then it will be invoked after the message
-      # is sent.
+      # Sends a message, optionally blocking until the message is received
+      # by the broker.
       #
       # ==== Options
       #
-      # * message - The message to send.
-      # * :sync - See note below on synching.
+      # * +message+ - The message to send.
+      # * +:sync+ - Block until received. See note below on synching.
       #
       # ==== Synching
       #
@@ -61,9 +75,13 @@ module Qpid
       #
       # ==== Examples
       #
-      #   sender.send message do |message|
-      #     puts "Message sent: #{message.content}"
-      #   end
+      #   # send a message
+      #   outgoing = Qpid::Messaging::Message.new :content => content
+      #   sender.send outgoing
+      #
+      #   # send a message, wait for confirmation from the broker
+      #   outgoing = Qpid::Messaging::Message.new :content => content
+      #   sender.send outgoing, :sync => true
       #
       def send(message, args = {}, &block)
         sync = args[:sync] || false
@@ -73,52 +91,27 @@ module Qpid
 
       # Closes this +Sender+.
       #
-      # This does not affect the +Session+.
+      # This does not affect the owning Session or Connection.
       def close; @sender_impl.close; end
 
       # Returns the human-readable name for this +Sender+.
-      #
-      # ==== Examples
-      #
-      #   puts "Sender: #{sender.name}"
-      #
       def name; @sender_impl.getName; end
 
       # Sets the capacity for this +Sender+.
       #
       # The capacity is the number of outgoing messages that can be held
-      # pending confirmation or receipt by the broker.
+      # pending confirmation of receipt by the broker.
       #
       # ==== Options
       #
-      # * capacity - the capacity
-      #
-      # ==== Examples
-      #
-      #   sender.capacity = 50 # sets the outgoing capacity to 50 messages
-      #
+      # * +capacity+ - the capacity
       def capacity=(capacity); @sender_impl.setCapacity capacity; end
 
       # Returns the capacity.
-      #
-      # The capacity is the total number of outgoing messages that can be
-      # sent before a called to +send+ begins to block by default.
-      #
-      # ==== Examples
-      #
-      #   puts "You can send a maximum of #{sender.capacity} messages."
-      #
       def capacity; @sender_impl.getCapacity; end
 
       # Returns the number of messages sent that are pending receipt
       # confirmation by the broker.
-      #
-      # ==== Examples
-      #
-      #   if sender.unsettled > 0
-      #     puts "There are #{sender.unsettled} messages pending."
-      #   end
-      #
       def unsettled; @sender_impl.getUnsettled; end
 
       # Returns the available slots for sending messages.
@@ -127,21 +120,11 @@ module Qpid
       # the senders capacity for holding outgoing messages. The difference
       # between capacity and available is the number of messages that
       # have not been delivered yet.
-      #
-      # ==== Examples
-      #
-      #   puts "You can send #{sender.available} messages before blocking."
-      #
       def available
         @sender_impl.getAvailable
       end
 
-      # Returns the +Session+ for this sender.
-      #
-      # ==== Examples
-      #
-      #   recv.session.close if done
-      #
+      # Returns the Session for this sender.
       def session; @session; end
 
     end

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb Mon Feb 18 10:18:24 2013
@@ -1,4 +1,4 @@
-#
+#--
 # 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
@@ -15,44 +15,41 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
+#++
 
 module Qpid
 
   module Messaging
 
-    # A Session represents a distinct conversation between end points.
+    # A +Session+ represents a distinct conversation between end points. They are
+    # created from an active (i.e., not closed) Connection.
+    #
+    # A +Session+ is used to acknowledge individual or all messages that have
+    # passed through it
     class Session
 
       def initialize(connection, session) # :nodoc:
         @connection   = connection
         @session_impl = session
-        @senders      = Hash.new
-        @receivers    = Hash.new
       end
 
       def session_impl # :nodoc:
         @session_impl
       end
 
-      # Returns the +Connection+ associated with this session.
+      # Returns the Connection associated with this session.
       def connection
         @connection
       end
 
       # Creates a new endpoint for sending messages.
       #
-      # The +address+ can either be an instance +Address+ or else a
-      # string that describes an address endpoint.
+      # The address can either be an instance Address or else an
+      # address string.
       #
       # ==== Arguments
       #
-      # * +address+ The end point address.
-      #
-      # ==== Examples
-      #
-      #   sender = session.create_sender "my-queue;{create:always}"
-      #
+      # * +address+ - the end point address.
       def create_sender(address)
         _address = address
 
@@ -63,43 +60,28 @@ module Qpid
         sender_impl = @session_impl.createSender(_address)
         sender_name = sender_impl.getName
 
-        @senders[sender_name] = Qpid::Messaging::Sender.new(self, sender_impl)
-
-        @senders[sender_name]
+        Qpid::Messaging::Sender.new(self, sender_impl)
       end
 
-      # Retrieves the +Sender+ with the specified name.
+      # Retrieves the Sender with the specified name.
       #
-      # The +Sender+ must have been previously created using
-      # the +create_sender+ method.
+      # Raises an exception if no such Sender exists.
       #
       # ==== Arguments
       #
-      # * +name+ The +Sender+ name.
-      #
-      # ==== Examples
-      #
-      #   sender = session.sender "my-queue"
-      #
+      # * +name+ - the name of the Sender
       def sender(name)
-        raise Qpid::Messaging::KeyError, "No such sender: #{name}" unless @senders.has_key? name
-
-        @senders[name]
+        Qpid::Messaging::Sender.new self, @session_impl.getSender(name)
       end
 
       # Creates a new endpoint for receiving messages.
       #
-      # The +address+ can either be an instance +Address+ or else a
-      # string that describes an address endpoint.
+      # The +address+ can either be an instance Address or else an
+      # address string.
       #
       # ==== Arguments
       #
-      # * +address+ The end point address.
-      #
-      # ==== Examples
-      #
-      #   receiver = session.create_receiver "my-queue"
-      #
+      # * +address+ - the end point address.
       def create_receiver(address)
         result        = nil
         receiver_impl = nil
@@ -111,36 +93,24 @@ module Qpid
           receiver_impl = @session_impl.createReceiver(address)
         end
 
-        receiver_name = receiver_impl.getName
-
-        @receivers[receiver_name] = Qpid::Messaging::Receiver.new self, receiver_impl
-
-        @receivers[receiver_name]
+        Qpid::Messaging::Receiver.new self, receiver_impl
       end
 
-      # Retrieves the +Receiver+ with the specified name.
-      #
-      # The +Receiver+ must have been previously created using
-      # the +create_receiver+ method.
+      # Retrieves the +Receiver+ with the specified name, or nil if no such
+      # Receiver exists.
       #
       # ==== Arguments
       #
-      # * +name+ The +Receiver+ name.
-      #
-      # ==== Examples
-      #
-      #   receiver = session.receiver "my-queue"
-      #
+      # * +name+ - the name of the Receiver
       def receiver(name)
-        raise Qpid::Messaging::KeyError, "No such receiver: #{name}" unless @receivers.has_key? name
-
-        @receivers[name]
+        Qpid::Messaging::Receiver.new self, @session_impl.getReceiver(name)
       end
 
       # Closes the +Session+ and all associated +Sender+ and +Receiver+ instances.
       #
-      # NOTE: All +Session+ instances for a +Connection+ are closed when the
-      # +Connection+ is closed.
+      # *NOTE:* All +Session+ instances for a Connection are closed when the
+      # Connection is closed. But closing a +Session+ does not affect the
+      # owning Connection.
       def close; @session_impl.close; end
 
       # Commits any pending transactions for a transactional session.
@@ -154,21 +124,30 @@ module Qpid
       #
       # ==== Arguments
       #
-      # * :message - if specified, then only the +Message+ specified is acknowledged
-      # * :sync - if true then the call will block until processed by the server (def. false)
+      # * +options+ - the set of options
+      #
+      # ==== Options
+      #
+      # * :message - if specified, then only that Message is acknowledged
+      # * :sync - if true, the call will block until processed by the broker
       #
       # ==== Examples
       #
-      #   session.acknowledge                     # acknowledges all received messages
-      #   session.acknowledge :message => message # acknowledge one message
-      #   session.acknowledge :sync => true       # blocks until the call completes
+      #   # acknowledge all received messages
+      #   session.acknowledge
+      #
+      #   # acknowledge a single message
+      #   session.acknowledge :message => message
+      #
+      #   # acknowledge all messages, wait until the call finishes
+      #   session.acknowledge :sync => true
       #
       #--
       # TODO: Add an optional block to be used for blocking calls.
       #++
-      def acknowledge(args = {})
-        sync = args[:sync] || false
-        message = args[:message] if args[:message]
+      def acknowledge(options = {})
+        sync = options[:sync] || false
+        message = options[:message] if options[:message]
 
         unless message.nil?
           @session_impl.acknowledge message.message_impl, sync
@@ -189,11 +168,15 @@ module Qpid
       # NOTE: A message connot be released once it has been acknowled.
       def release(message); @session_impl.release message.message_impl; end
 
-      # Requests synchronization with the server.
+      # Requests synchronization with the broker.
       #
       # ==== Arguments
       #
-      # * :block - if true then the call blocks until the server acknowledges it (def. false)
+      # * +options+ - the list of options
+      #
+      # ==== Options
+      #
+      # * +:block+ - if true, the call blocks until the broker acknowledges it
       #
       #--
       # TODO: Add an optional block to be used for blocking calls.
@@ -204,26 +187,43 @@ module Qpid
       end
 
       # Returns the total number of receivable messages, and messages already
-      # received, by +Receiver+ instances associated with this +Session+.
+      # received, by Receiver instances associated with this +Session+.
       def receivable; @session_impl.getReceivable; end
 
-      # Returns the number of messages that have been acknowledged by this session
-      # whose acknowledgements have not been confirmed as processed by the server.
+      # Returns the number of messages that have been acknowledged by this
+      # +Session+ whose acknowledgements have not been confirmed as processed
+      # by the broker.
       def unsettled_acks; @session_impl.getUnsettledAcks; end
 
-      # Fetches the +Receiver+ for the next message.
+      # Fetches the next Receiver with a message pending. Waits the specified
+      # number of milliseconds before timing out.
+      #
+      # For a Receiver to be returned, it must have a capacity > 0 and have
+      # Messages locally queued.
+      #
+      # If no Receiver is found within the time out period, then a MessageError
+      # is raised.
       #
       # ==== Arguments
       #
-      # * timeout - time to wait for a +Receiver+ before timing out
+      # * +timeout+ - the duration
       #
       # ==== Examples
       #
-      #   recv = session.next_receiver # wait forever for the next +Receiver+
-      #   # execute a block on the next receiver
-      #   session.next_receiver do |recv|
-      #     msg = recv.get
-      #     puts "Received message: #{msg.content}"
+      #   loop do
+      #
+      #     begin
+      #       # wait a maximum of one minute for the next receiver to be ready
+      #       recv = session.next_receiver Qpid::Messaging::Duration::MINUTE
+      #
+      #       # get and dispatch the message
+      #       msg = recv.get
+      #       dispatch_message msg
+      #
+      #     rescue
+      #       puts "No receivers were returned"
+      #     end
+      #
       #   end
       def next_receiver(timeout = Qpid::Messaging::Duration::FOREVER, &block)
         receiver_impl = @session_impl.nextReceiver(timeout.duration_impl)
@@ -237,10 +237,6 @@ module Qpid
       end
 
       # Returns true if there were exceptions on this session.
-      #
-      # ==== Examples
-      #
-      #   puts "There were session errors." if @session.errors?
       def errors?; @session_impl.hasError; end
 
       # If the +Session+ has been rendered invalid due to some exception,
@@ -250,6 +246,7 @@ module Qpid
       #
       # ==== Examples
       #
+      #   # show any errors that occurred during the Session
       #   if @session.errors?
       #     begin
       #       @session.errors

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/address_spec.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/address_spec.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/address_spec.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/address_spec.rb Mon Feb 18 10:18:24 2013
@@ -26,7 +26,7 @@ module Qpid
     describe Address do
 
       before(:each) do
-        @address = Qpid::Messaging::Address.new "my-name", "my-subject", :create => :always
+        @address = Qpid::Messaging::Address.new "my-name/my-subject;{create:always}"
       end
 
       it "stores the name, subject and options when created" do
@@ -72,7 +72,7 @@ module Qpid
       end
 
       it "can return a string representation" do
-        address = Qpid::Messaging::Address.new "foo", "bar", :create => :always, :link => :durable
+        address = Qpid::Messaging::Address.new "foo/bar:{create:always,link:durable}"
         result = address.to_s
 
         result.should =~ /foo\/bar/

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/connection_spec.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/connection_spec.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/connection_spec.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/connection_spec.rb Mon Feb 18 10:18:24 2013
@@ -37,7 +37,7 @@ module Qpid
           connection = Qpid::Messaging::Connection.new :options => {:username => "foo"}
 
           connection.options.should include("username")
-        }.should_not raise_error
+        }.to_not raise_error
       end
 
       it "returns the underlying implementation" do

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/message_spec.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/message_spec.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/message_spec.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/message_spec.rb Mon Feb 18 10:18:24 2013
@@ -36,7 +36,7 @@ module Qpid
       end
 
       it "can set the reply to address" do
-        address = Qpid::Messaging::Address.new "my-queue", ""
+        address = Qpid::Messaging::Address.new "my-queue;{create:always}"
 
         @message.reply_to = address
 
@@ -45,6 +45,19 @@ module Qpid
         reply_to.name.should == address.name
       end
 
+      it "can set the reply to from an address string" do
+        name = "my-queue"
+        subject = "responses"
+        address = "#{name}/#{subject}"
+
+        @message.reply_to = address
+
+        reply_to = @message.reply_to
+
+        reply_to.name.should == name
+        reply_to.subject.should == subject
+      end
+
       it "should store the content when created" do
         content = @message.content
 

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/session_spec.rb
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/session_spec.rb?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/session_spec.rb (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/qpid/ruby/spec/qpid_messaging/session_spec.rb Mon Feb 18 10:18:24 2013
@@ -46,7 +46,7 @@ module Qpid
       end
 
       it "creates a Sender from an Address" do
-        address = Qpid::Messaging::Address.new "my-queu", "", :create => :always
+        address = Qpid::Messaging::Address.new "my-queue;{create:always}"
 
         @session_impl.should_receive(:createSender).
           with(address.address_impl).

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/swig_perl_typemaps.i
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/swig_perl_typemaps.i?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/swig_perl_typemaps.i (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/bindings/swig_perl_typemaps.i Mon Feb 18 10:18:24 2013
@@ -49,7 +49,11 @@
             else if (SvPOK(value)) {
                 STRLEN len;
                 char *ptr = SvPV(value, len);
-                return qpid::types::Variant(std::string(ptr, len));
+                qpid::types::Variant v =  qpid::types::Variant(std::string(ptr,len));
+                if (SvUTF8(value)) {
+                    v.setEncoding("utf8");
+                }
+                return v;
             }
         }
         return qpid::types::Variant();
@@ -98,6 +102,9 @@
             case qpid::types::VAR_STRING : {
                 const std::string val(v->asString());
                 result = newSVpvn(val.c_str(), val.size());
+                if( v->getEncoding() == "utf8" ) {
+                    SvUTF8_on(result);
+                }
                 break;
             }
             case qpid::types::VAR_MAP : {
@@ -119,28 +126,24 @@
     }
 
     SV* MapToPerl(const qpid::types::Variant::Map* map) {
-        SV *result = newSV(0);
-        HV *hv = (HV *)sv_2mortal((SV *)newHV());
+        HV *hv = newHV();
         qpid::types::Variant::Map::const_iterator iter;
         for (iter = map->begin(); iter != map->end(); iter++) {
             const std::string key(iter->first);
             SV* perlval = VariantToPerl(&(iter->second));
             hv_store(hv, key.c_str(), key.size(), perlval, 0);
         }
-        SvSetSV(result, newRV_noinc((SV *)hv));
-        return result;
+        return sv_2mortal(newRV_noinc((SV *)hv));
     }
 
     SV* ListToPerl(const qpid::types::Variant::List* list) {
-        SV* result = newSV(0);
-        AV* av  = (AV *)sv_2mortal((SV *)newAV());
+        AV* av = newAV();
         qpid::types::Variant::List::const_iterator iter;
         for (iter = list->begin(); iter != list->end(); iter++) {
             SV* perlval = VariantToPerl(&(*iter));
             av_push(av, perlval);
         }
-        SvSetSV(result, newRV_noinc((SV *)av));
-        return result;
+        return sv_2mortal(newRV_noinc((SV *)av));
     }
 
     void PerlToMap(SV* hash, qpid::types::Variant::Map* map) {

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/docs/api/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/docs/api:r1438054-1446845

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/examples/messaging/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/examples/messaging/CMakeLists.txt?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/examples/messaging/CMakeLists.txt (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/examples/messaging/CMakeLists.txt Mon Feb 18 10:18:24 2013
@@ -17,6 +17,51 @@
 # under the License.
 #
 
+# drain and spout have explicit Boost.program_options usage in them, so be
+# sure that lib is linked in.
+
+macro(add_messaging_example example)
+  add_executable(${example} ${example}.cpp OptionParser.cpp)
+  set_target_properties(${example} PROPERTIES OUTPUT_NAME ${example})
+  target_link_libraries(${example} qpidmessaging ${_boost_libs_needed})
+  # For installs, don't install the built example; that would be pointless.
+  # Install the things a user needs to build the example on-site.
+  install (FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/OptionParser.h
+    ${CMAKE_CURRENT_SOURCE_DIR}/OptionParser.cpp
+    DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/messaging
+    COMPONENT ${QPID_COMPONENT_EXAMPLES})
+
+  if (MSVC)
+    install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/messaging_${example}.vcproj
+             DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/messaging
+             COMPONENT ${QPID_COMPONENT_EXAMPLES})
+  endif (MSVC)
+
+endmacro(add_messaging_example)
+
+add_messaging_example(drain)
+add_messaging_example(spout)
+
+add_messaging_example(map_receiver)
+add_messaging_example(map_sender)
+
+add_messaging_example(client)
+add_messaging_example(server)
+
+# These don't need Boost or OptionParser
+add_executable(hello_world hello_world.cpp)
+set_target_properties(hello_world PROPERTIES OUTPUT_NAME hello_world)
+target_link_libraries(hello_world qpidmessaging)
+install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/hello_world.cpp
+           DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/messaging
+           COMPONENT ${QPID_COMPONENT_EXAMPLES})
+
+add_executable(hello_xml hello_xml.cpp)
+set_target_properties(hello_xml PROPERTIES OUTPUT_NAME hello_xml)
+target_link_libraries(hello_xml qpidmessaging)
+
 install (FILES
            ${CMAKE_CURRENT_SOURCE_DIR}/extra_dist/CMakeLists.txt
            ${CMAKE_CURRENT_SOURCE_DIR}/OptionParser.cpp

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_publisher.vcproj
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/examples/old_api/tradedemo/tradedemo_topic_publisher.vcproj:r1438054-1446845

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qmf/engine/Agent.h
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/include/qmf/engine/Agent.h:r1438054-1446845

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qmf/engine/Console.h
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/include/qmf/engine/Console.h:r1438054-1446845

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/client/FailoverManager.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/client/FailoverManager.h?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/client/FailoverManager.h (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/client/FailoverManager.h Mon Feb 18 10:18:24 2013
@@ -87,6 +87,7 @@ class QPID_CLIENT_CLASS_EXTERN FailoverM
      * attempted
      */
     QPID_CLIENT_EXTERN FailoverManager(const ConnectionSettings& settings, ReconnectionStrategy* strategy = 0);
+	QPID_CLIENT_EXTERN ~FailoverManager();
     /**
      * Return the current connection if open or attept to reconnect to
      * the specified list of urls. If no list is specified the list of

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/log/Logger.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/log/Logger.h?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/log/Logger.h (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/include/qpid/log/Logger.h Mon Feb 18 10:18:24 2013
@@ -95,6 +95,11 @@ class QPID_COMMON_CLASS_EXTERN Logger : 
     /** Get the options used to configure the logger. */
     QPID_COMMON_INLINE_EXTERN const Options& getOptions() const { return options; }
 
+    /** Get the hires timestamp setting */
+    QPID_COMMON_EXTERN bool getHiresTimestamp();
+
+    /** Set the hires timestamp setting */
+    QPID_COMMON_EXTERN void setHiresTimestamp(bool setting);
 
   private:
     typedef boost::ptr_vector<Output> Outputs;

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/src:r1438054-1446845

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/CMakeLists.txt?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/CMakeLists.txt (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/CMakeLists.txt Mon Feb 18 10:18:24 2013
@@ -319,7 +319,7 @@ if (NOT DEFINED Boost_ADDITIONAL_VERSION
   set (Boost_ADDITIONAL_VERSIONS 
         "1.45" "1.45.0" "1.46" "1.46.0" "1.47" "1.47.0"
         "1.48" "1.48.0" "1.49" "1.49.0" "1.50" "1.50.0"
-        "1.51" "1.51.0" "1.52" "1.52.0")
+        "1.51" "1.51.0" "1.52" "1.52.0" "1.53" "1.53.0")
 endif (NOT DEFINED Boost_ADDITIONAL_VERSIONS)
 
 find_package(Boost 1.33 REQUIRED COMPONENTS ${Boost_components})

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/CMakeLists.txt
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/src/CMakeLists.txt:r1438054-1446845

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qmf/engine/Agent.cpp
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/src/qmf/engine/Agent.cpp:r1438054-1446845

Propchange: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/cpp/src/qpid/acl:r1438054-1446845

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/Acl.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/Acl.cpp?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/Acl.cpp (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/Acl.cpp Mon Feb 18 10:18:24 2013
@@ -24,6 +24,7 @@
 #include "qpid/sys/Mutex.h"
 
 #include "qpid/broker/Broker.h"
+#include "qpid/broker/Connection.h"
 #include "qpid/Plugin.h"
 #include "qpid/Options.h"
 #include "qpid/log/Logger.h"
@@ -56,6 +57,15 @@ Acl::Acl (AclValues& av, Broker& b): acl
     connectionCounter(new ConnectionCounter(*this, aclValues.aclMaxConnectPerUser, aclValues.aclMaxConnectPerIp, aclValues.aclMaxConnectTotal)),
     resourceCounter(new ResourceCounter(*this, aclValues.aclMaxQueuesPerUser)){
 
+    if (aclValues.aclMaxConnectPerUser > AclData::getConnectMaxSpec())
+        throw Exception("--connection-limit-per-user switch cannot be larger than " + AclData::getMaxConnectSpecStr());
+    if (aclValues.aclMaxConnectPerIp > AclData::getConnectMaxSpec())
+        throw Exception("--connection-limit-per-ip switch cannot be larger than " + AclData::getMaxConnectSpecStr());
+    if (aclValues.aclMaxConnectTotal > AclData::getConnectMaxSpec())
+        throw Exception("--max-connections switch cannot be larger than " + AclData::getMaxConnectSpecStr());
+    if (aclValues.aclMaxQueuesPerUser > AclData::getConnectMaxSpec())
+        throw Exception("--max-queues-per-user switch cannot be larger than " + AclData::getMaxConnectSpecStr());
+
     agent = broker->getManagementAgent();
 
     if (agent != 0){
@@ -138,7 +148,18 @@ bool Acl::authorise(
 
 bool Acl::approveConnection(const qpid::broker::Connection& conn)
 {
-    return connectionCounter->approveConnection(conn);
+    const std::string& userName(conn.getUserId());
+    uint16_t connectionLimit(0);
+
+    boost::shared_ptr<AclData> dataLocal;
+    {
+        Mutex::ScopedLock locker(dataLock);
+        dataLocal = data;  //rcu copy
+    }
+
+    bool enforcingConnQuotas = dataLocal->getConnQuotaForUser(userName, &connectionLimit);
+
+    return connectionCounter->approveConnection(conn, enforcingConnQuotas, connectionLimit);
 }
 
 bool Acl::approveCreateQueue(const std::string& userId, const std::string& queueName)
@@ -207,7 +228,7 @@ bool Acl::readAclFile(std::string& error
 
 bool Acl::readAclFile(std::string& aclFile, std::string& errorText) {
     boost::shared_ptr<AclData> d(new AclData);
-    AclReader ar;
+    AclReader ar(aclValues.aclMaxConnectPerUser);
     if (ar.read(aclFile, d)){
         agent->raiseEvent(_qmf::EventFileLoadFailed("", ar.getError()));
         errorText = ar.getError();
@@ -228,6 +249,10 @@ bool Acl::readAclFile(std::string& aclFi
         QPID_LOG(debug,"ACL: Transfer ACL is Enabled!");
     }
 
+    if (data->enforcingConnectionQuotas()){
+        QPID_LOG(debug, "ACL: Connection quotas are Enabled.");
+    }
+
     data->aclSource = aclFile;
     if (mgmtObject!=0){
         mgmtObject->set_transferAcl(transferAcl?1:0);

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.cpp Mon Feb 18 10:18:24 2013
@@ -85,32 +85,32 @@ bool ConnectionCounter::limitApproveLH(
 //
 // countConnectionLH
 //
-// Increment the name's count in map and return a comparison against the limit.
-// called with dataLock already taken
+// Increment the name's count in map and return an optional comparison
+//  against a connection limit.
+// Called with dataLock already taken.
 //
 bool ConnectionCounter::countConnectionLH(
     connectCountsMap_t& theMap,
     const std::string& theName,
     uint16_t theLimit,
-    bool emitLog) {
+    bool emitLog,
+    bool enforceLimit) {
 
     bool result(true);
     uint16_t count(0);
-    if (theLimit > 0) {
-        connectCountsMap_t::iterator eRef = theMap.find(theName);
-        if (eRef != theMap.end()) {
-            count = (uint16_t)(*eRef).second + 1;
-            (*eRef).second = count;
-            result = count <= theLimit;
-        } else {
-            theMap[theName] = count = 1;
-        }
-        if (emitLog) {
-            QPID_LOG(trace, "ACL ConnectionApprover user=" << theName
-                << " limit=" << theLimit
-                << " curValue=" << count
-                << " result=" << (result ? "allow" : "deny"));
-        }
+    connectCountsMap_t::iterator eRef = theMap.find(theName);
+    if (eRef != theMap.end()) {
+        count = (uint16_t)(*eRef).second + 1;
+        (*eRef).second = count;
+        result = (enforceLimit ? count <= theLimit : true);
+    } else {
+        theMap[theName] = count = 1;
+    }
+    if (emitLog) {
+        QPID_LOG(trace, "ACL ConnectionApprover user=" << theName
+            << " limit=" << theLimit
+            << " curValue=" << count
+            << " result=" << (result ? "allow" : "deny"));
     }
     return result;
 }
@@ -123,23 +123,21 @@ bool ConnectionCounter::countConnectionL
 // called with dataLock already taken
 //
 void ConnectionCounter::releaseLH(
-    connectCountsMap_t& theMap, const std::string& theName, uint16_t theLimit) {
+    connectCountsMap_t& theMap, const std::string& theName) {
 
-    if (theLimit > 0) {
-        connectCountsMap_t::iterator eRef = theMap.find(theName);
-        if (eRef != theMap.end()) {
-            uint16_t count = (uint16_t) (*eRef).second;
-            assert (count > 0);
-            if (1 == count) {
-                theMap.erase (eRef);
-            } else {
-                (*eRef).second = count - 1;
-            }
+    connectCountsMap_t::iterator eRef = theMap.find(theName);
+    if (eRef != theMap.end()) {
+        uint16_t count = (uint16_t) (*eRef).second;
+        assert (count > 0);
+        if (1 == count) {
+            theMap.erase (eRef);
         } else {
-            // User had no connections.
-            QPID_LOG(notice, "ACL ConnectionCounter Connection for '" << theName
-                << "' not found in connection count pool");
+            (*eRef).second = count - 1;
         }
+    } else {
+        // User had no connections.
+        QPID_LOG(notice, "ACL ConnectionCounter Connection for '" << theName
+            << "' not found in connection count pool");
     }
 }
 
@@ -161,7 +159,7 @@ void ConnectionCounter::connection(broke
     connectProgressMap[connection.getMgmtId()] = C_CREATED;
 
     // Count the connection from this host.
-    (void) countConnectionLH(connectByHostMap, hostName, hostLimit, false);
+    (void) countConnectionLH(connectByHostMap, hostName, hostLimit, false, false);
 }
 
 
@@ -180,8 +178,7 @@ void ConnectionCounter::closed(broker::C
             // Normal case: connection was created and opened.
             // Decrement user in-use counts
             releaseLH(connectByNameMap,
-                      connection.getUserId(),
-                      nameLimit);
+                      connection.getUserId());
         } else {
             // Connection was created but not opened.
             // Don't decrement user count.
@@ -189,8 +186,7 @@ void ConnectionCounter::closed(broker::C
 
         // Decrement host in-use count.
         releaseLH(connectByHostMap,
-                  getClientHost(connection.getMgmtId()),
-                  hostLimit);
+                  getClientHost(connection.getMgmtId()));
 
         // destroy connection progress indicator
         connectProgressMap.erase(eRef);
@@ -211,7 +207,10 @@ void ConnectionCounter::closed(broker::C
 //  check total connections, connections from IP, connections by user and
 //  disallow if over any limit
 //
-bool ConnectionCounter::approveConnection(const broker::Connection& connection)
+bool ConnectionCounter::approveConnection(
+        const broker::Connection& connection,
+        bool enforcingConnectionQuotas,
+        uint16_t connectionUserQuota )
 {
     const std::string& hostName(getClientHost(connection.getMgmtId()));
     const std::string& userName(              connection.getUserId());
@@ -220,7 +219,7 @@ bool ConnectionCounter::approveConnectio
 
     // Bump state from CREATED to OPENED
     (void) countConnectionLH(connectProgressMap, connection.getMgmtId(),
-                             C_OPENED, false);
+                             C_OPENED, false, false);
 
     // Approve total connections
     bool okTotal  = true;
@@ -235,7 +234,9 @@ bool ConnectionCounter::approveConnectio
     bool okByIP   = limitApproveLH(connectByHostMap, hostName, hostLimit, true);
 
     // Count and Approve the connection by the user
-    bool okByUser = countConnectionLH(connectByNameMap, userName, nameLimit, true);
+    bool okByUser = countConnectionLH(connectByNameMap, userName,
+                                      connectionUserQuota, true,
+                                      enforcingConnectionQuotas);
 
     // Emit separate log for each disapproval
     if (!okTotal) {
@@ -252,7 +253,7 @@ bool ConnectionCounter::approveConnectio
     }
     if (!okByUser) {
         QPID_LOG(error, "Client max per-user connection count limit of "
-                 << nameLimit << " exceeded by '"
+                 << connectionUserQuota << " exceeded by '"
                  << connection.getMgmtId() << "', user: '"
                  << userName << "'. Connection refused.");
     }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.h
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.h?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.h (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclConnectionCounter.h Mon Feb 18 10:18:24 2013
@@ -77,12 +77,12 @@ private:
     bool countConnectionLH(connectCountsMap_t& theMap,
                            const std::string& theName,
                            uint16_t theLimit,
-                           bool emitLog);
+                           bool emitLog,
+                           bool enforceLimit);
 
     /** Release a connection */
     void releaseLH(connectCountsMap_t& theMap,
-                   const std::string& theName,
-                   uint16_t theLimit);
+                   const std::string& theName);
 
 public:
     ConnectionCounter(Acl& acl, uint16_t nl, uint16_t hl, uint16_t tl);
@@ -93,7 +93,9 @@ public:
     void     closed(broker::Connection& connection);
 
     // Connection counting
-    bool approveConnection(const broker::Connection& conn);
+    bool approveConnection(const broker::Connection& conn,
+                           bool enforcingConnectionQuotas,
+                           uint16_t connectionLimit );
 };
 
 }} // namespace qpid::ha

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclData.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclData.cpp?rev=1447183&r1=1447182&r2=1447183&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclData.cpp (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/cpp/src/qpid/acl/AclData.cpp Mon Feb 18 10:18:24 2013
@@ -25,11 +25,19 @@ namespace qpid {
 namespace acl {
 
     //
-    // Instantiate the substitution keyword string
+    // Instantiate the keyword strings
     //
-    const std::string AclData::USER_SUBSTITUTION_KEYWORD       = "${user}";
-    const std::string AclData::DOMAIN_SUBSTITUTION_KEYWORD     = "${domain}";
-    const std::string AclData::USERDOMAIN_SUBSTITUTION_KEYWORD = "${userdomain}";
+    const std::string AclData::ACL_KEYWORD_USER_SUBST        = "${user}";
+    const std::string AclData::ACL_KEYWORD_DOMAIN_SUBST      = "${domain}";
+    const std::string AclData::ACL_KEYWORD_USERDOMAIN_SUBST  = "${userdomain}";
+    const std::string AclData::ACL_KEYWORD_ALL               = "all";
+    const std::string AclData::ACL_KEYWORD_ACL               = "acl";
+    const std::string AclData::ACL_KEYWORD_GROUP             = "group";
+    const std::string AclData::ACL_KEYWORD_QUOTA             = "quota";
+    const std::string AclData::ACL_KEYWORD_QUOTA_CONNECTIONS = "connections";
+    const char        AclData::ACL_SYMBOL_WILDCARD           = '*';
+    const std::string AclData::ACL_KEYWORD_WILDCARD          = "*";
+    const char        AclData::ACL_SYMBOL_LINE_CONTINUATION  = '\\';
 
     //
     // constructor
@@ -37,7 +45,9 @@ namespace acl {
     AclData::AclData():
         decisionMode(qpid::acl::DENY),
         transferAcl(false),
-        aclSource("UNKNOWN")
+        aclSource("UNKNOWN"),
+        connQuotaRulesExist(false),
+        connQuotaRuleSettings(new quotaRuleSet)
     {
         for (unsigned int cnt=0; cnt< qpid::acl::ACTIONSIZE; cnt++)
         {
@@ -60,6 +70,9 @@ namespace acl {
             }
             delete[] actionList[cnt];
         }
+        transferAcl = false;
+        connQuotaRulesExist = false;
+        connQuotaRuleSettings->clear();
     }
 
 
@@ -73,7 +86,7 @@ namespace acl {
                             const std::string& lookupStr)
     {
         // allow wildcard on the end of rule strings...
-        if (ruleStr.data()[ruleStr.size()-1]=='*')
+        if (ruleStr.data()[ruleStr.size()-1]==ACL_SYMBOL_WILDCARD)
         {
             return ruleStr.compare(0,
                                    ruleStr.size()-1,
@@ -124,7 +137,7 @@ namespace acl {
 
             // If individual actorId not found then find a rule set for '*'.
             if (itrRule == actionList[action][objType]->end())
-                itrRule = actionList[action][objType]->find("*");
+                itrRule = actionList[action][objType]->find(ACL_KEYWORD_WILDCARD);
 
             if (itrRule != actionList[action][objType]->end())
             {
@@ -390,7 +403,7 @@ namespace acl {
             AclData::actObjItr itrRule = actionList[action][objType]->find(id);
 
             if (itrRule == actionList[action][objType]->end())
-                itrRule = actionList[action][objType]->find("*");
+                itrRule = actionList[action][objType]->find(ACL_KEYWORD_WILDCARD);
 
             if (itrRule != actionList[action][objType]->end() )
             {
@@ -436,9 +449,9 @@ namespace acl {
 
                     if (match && rsItr->pubRoutingKeyInRule)
                     {
-                        if ((routingKey.find(USER_SUBSTITUTION_KEYWORD, 0)       != std::string::npos) ||
-                            (routingKey.find(DOMAIN_SUBSTITUTION_KEYWORD, 0)     != std::string::npos) ||
-                            (routingKey.find(USERDOMAIN_SUBSTITUTION_KEYWORD, 0) != std::string::npos))
+                        if ((routingKey.find(ACL_KEYWORD_USER_SUBST, 0)       != std::string::npos) ||
+                            (routingKey.find(ACL_KEYWORD_DOMAIN_SUBST, 0)     != std::string::npos) ||
+                            (routingKey.find(ACL_KEYWORD_USERDOMAIN_SUBST, 0) != std::string::npos))
                         {
                             // The user is not allowed to present a routing key with the substitution key in it
                             QPID_LOG(debug, "ACL: Rule: " << rsItr->rawRuleNum <<
@@ -489,6 +502,62 @@ namespace acl {
     }
 
 
+
+    //
+    //
+    //
+    void AclData::setConnQuotaRuleSettings (
+                bool rulesExist, boost::shared_ptr<quotaRuleSet> quotaPtr)
+    {
+        connQuotaRulesExist = rulesExist;
+        connQuotaRuleSettings = quotaPtr;
+    }
+
+
+    //
+    // getConnQuotaForUser
+    //
+    // Return the true or false value of connQuotaRulesExist,
+    //  indicating whether any kind of lookup was done or not.
+    //
+    // When lookups are performed return the result value of
+    //  1. The user's setting else
+    //  2. The 'all' user setting else
+    //  3. Zero
+    // When lookups are not performed then return a result value of Zero.
+    //
+    bool AclData::getConnQuotaForUser(const std::string& theUserName,
+                                      uint16_t* theResult) const {
+        if (connQuotaRulesExist) {
+            // look for this user explicitly
+            quotaRuleSetItr nameItr = (*connQuotaRuleSettings).find(theUserName);
+            if (nameItr != (*connQuotaRuleSettings).end()) {
+                QPID_LOG(trace, "ACL: Connection quota for user " << theUserName
+                    << " explicitly set to : " << (*nameItr).second);
+                *theResult = (*nameItr).second;
+            } else {
+                // Look for the 'all' user
+                nameItr = (*connQuotaRuleSettings).find(ACL_KEYWORD_ALL);
+                if (nameItr != (*connQuotaRuleSettings).end()) {
+                    QPID_LOG(trace, "ACL: Connection quota for user " << theUserName
+                        << " chosen through value for 'all' : " << (*nameItr).second);
+                    *theResult = (*nameItr).second;
+                } else {
+                    // Neither userName nor "all" found.
+                    QPID_LOG(trace, "ACL: Connection quota for user " << theUserName
+                        << " absent in quota settings. Return value : 0");
+                    *theResult = 0;
+                }
+            }
+        } else {
+            // Rules do not exist
+            QPID_LOG(trace, "ACL: Connection quota for user " << theUserName
+                << " unavailable; quota settings are not specified. Return value : 0");
+            *theResult = 0;
+        }
+        return connQuotaRulesExist;
+    }
+
     //
     //
     //
@@ -656,9 +725,9 @@ namespace acl {
             domain = normalizeUserId(userId.substr(locDomSeparator+1));
         }
 
-        substituteString(ruleString, USER_SUBSTITUTION_KEYWORD,       user);
-        substituteString(ruleString, DOMAIN_SUBSTITUTION_KEYWORD,     domain);
-        substituteString(ruleString, USERDOMAIN_SUBSTITUTION_KEYWORD, userdomain);
+        substituteString(ruleString, ACL_KEYWORD_USER_SUBST,       user);
+        substituteString(ruleString, ACL_KEYWORD_DOMAIN_SUBST,     domain);
+        substituteString(ruleString, ACL_KEYWORD_USERDOMAIN_SUBST, userdomain);
     }
 
 
@@ -689,8 +758,8 @@ namespace acl {
             domain = normalizeUserId(userId.substr(locDomSeparator+1));
         }
         std::string oRule(ruleString);
-        substituteString(ruleString, userdomain, USERDOMAIN_SUBSTITUTION_KEYWORD);
-        substituteString(ruleString, user,       USER_SUBSTITUTION_KEYWORD);
-        substituteString(ruleString, domain,     DOMAIN_SUBSTITUTION_KEYWORD);
+        substituteString(ruleString, userdomain, ACL_KEYWORD_USERDOMAIN_SUBST);
+        substituteString(ruleString, user,       ACL_KEYWORD_USER_SUBST);
+        substituteString(ruleString, domain,     ACL_KEYWORD_DOMAIN_SUBST);
     }
 }}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org