diff options
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/bindings/qpid/ruby/ChangeLog | 1 | ||||
| -rw-r--r-- | cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb | 25 | ||||
| -rw-r--r-- | cpp/bindings/qpid/ruby/lib/qpid_messaging/errors.rb | 33 | ||||
| -rw-r--r-- | cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb | 29 |
4 files changed, 22 insertions, 66 deletions
diff --git a/cpp/bindings/qpid/ruby/ChangeLog b/cpp/bindings/qpid/ruby/ChangeLog index 722d2d8509..03813053d2 100644 --- a/cpp/bindings/qpid/ruby/ChangeLog +++ b/cpp/bindings/qpid/ruby/ChangeLog @@ -1,3 +1,4 @@ Verison 0.22: * Qpid::Messaging::Address can use an address string on creation. * Qpid::Messaging::Message can use an address string for reply_to. + * Removed errors.rb and the KeyError and SessionNameException errors. diff --git a/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb b/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb index f7217bac60..be11e95dfd 100644 --- a/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb +++ b/cpp/bindings/qpid/ruby/lib/qpid_messaging/connection.rb @@ -119,23 +119,26 @@ module Qpid end end - # Returns a session for the specified session name. + # Returns a Session with the given name. # - # ==== Examples + # If no such Session exists then a MessagingException is raised. + # == Options + # + # * +name+ - the session name # + # == Examples + # + # # retrieve a session named 'mysession' from the current connection + # name = "my-session" # 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. diff --git a/cpp/bindings/qpid/ruby/lib/qpid_messaging/errors.rb b/cpp/bindings/qpid/ruby/lib/qpid_messaging/errors.rb deleted file mode 100644 index db42cbb0c5..0000000000 --- a/cpp/bindings/qpid/ruby/lib/qpid_messaging/errors.rb +++ /dev/null @@ -1,33 +0,0 @@ -#-- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -#++ - -module Qpid - - module Messaging - - class KeyError < RuntimeError; end - - class SessionNameException < Exception - def initialize(msg); super(msg); end - end - - end - -end - diff --git a/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb b/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb index c2dbdb8516..2be89dc5b6 100644 --- a/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb +++ b/cpp/bindings/qpid/ruby/lib/qpid_messaging/session.rb @@ -27,8 +27,6 @@ module Qpid def initialize(connection, session) # :nodoc: @connection = connection @session_impl = session - @senders = Hash.new - @receivers = Hash.new end def session_impl # :nodoc: @@ -63,15 +61,12 @@ 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. # - # The +Sender+ must have been previously created using - # the +create_sender+ method. + # Raises an exception when no such Sender exists. # # ==== Arguments # @@ -82,9 +77,7 @@ module Qpid # sender = session.sender "my-queue" # 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. @@ -111,17 +104,11 @@ 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 # @@ -132,9 +119,7 @@ module Qpid # receiver = session.receiver "my-queue" # 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. |
