You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/12/13 20:37:08 UTC
[9/9] qpid-proton git commit: PROTON-1537: [ruby] add deprecation
warnings and aliases
PROTON-1537: [ruby] add deprecation warnings and aliases
Fixed a few uses of deprecated APIs internall.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5d7dd4af
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5d7dd4af
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5d7dd4af
Branch: refs/heads/master
Commit: 5d7dd4af1cd861e3d0b107f073ef8436dbc9ab7f
Parents: a13bc2b
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 13 15:01:29 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 15:30:35 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 7 +-
proton-c/bindings/ruby/lib/core/delivery.rb | 2 +-
proton-c/bindings/ruby/lib/core/disposition.rb | 4 +-
proton-c/bindings/ruby/lib/core/endpoint.rb | 3 +-
proton-c/bindings/ruby/lib/core/event.rb | 11 ++-
proton-c/bindings/ruby/lib/core/link.rb | 2 +-
proton-c/bindings/ruby/lib/core/message.rb | 3 +
proton-c/bindings/ruby/lib/core/sasl.rb | 80 ++++++++++----------
proton-c/bindings/ruby/lib/core/sender.rb | 19 ++---
proton-c/bindings/ruby/lib/core/session.rb | 11 ++-
proton-c/bindings/ruby/lib/core/ssl.rb | 2 +-
proton-c/bindings/ruby/lib/core/transfer.rb | 5 +-
proton-c/bindings/ruby/lib/core/transport.rb | 2 +
proton-c/bindings/ruby/lib/core/url.rb | 3 +-
.../ruby/lib/handler/messaging_adapter.rb | 2 +-
.../ruby/lib/handler/messaging_handler.rb | 5 +-
.../lib/handler/reactor_messaging_adapter.rb | 2 +-
.../bindings/ruby/lib/messenger/messenger.rb | 3 +-
proton-c/bindings/ruby/lib/qpid_proton.rb | 8 +-
proton-c/bindings/ruby/lib/reactor/container.rb | 5 +-
proton-c/bindings/ruby/lib/types/array.rb | 15 ++--
proton-c/bindings/ruby/lib/types/hash.rb | 6 +-
proton-c/bindings/ruby/lib/util/deprecation.rb | 42 ++++++++++
23 files changed, 151 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb
index dcbae1f..3ec7c26 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -20,6 +20,7 @@ module Qpid::Proton
# An AMQP connection.
class Connection < Endpoint
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_connection"
@@ -58,10 +59,10 @@ module Qpid::Proton
public
# @deprecated no replacement
- def overrides?() Qpid.deprecated __method__; false; end
+ def overrides?() deprecated __method__; false; end
# @deprecated no replacement
- def session_policy?() Qpid.deprecated __method__; false; end
+ def session_policy?() deprecated __method__; false; end
# @return [Connection] self
def connection() self; end
@@ -179,7 +180,7 @@ module Qpid::Proton
end
# @deprecated use #default_session()
- alias session default_session
+ deprecated_alias :session, :default_session
# Open a new session on this connection.
def open_session
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/delivery.rb b/proton-c/bindings/ruby/lib/core/delivery.rb
index e86a06e..fd5c43a 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -64,7 +64,7 @@ module Qpid::Proton
# @deprecated use {#release} with modification options
def modify()
- Qpid.deprecated __method__, "#release"
+ deprecated __method__, "release(modification_options)"
release failed=>true
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/disposition.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/disposition.rb b/proton-c/bindings/ruby/lib/core/disposition.rb
index 9cecf69..bca787e 100644
--- a/proton-c/bindings/ruby/lib/core/disposition.rb
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -20,6 +20,8 @@ module Qpid::Proton
# @deprecated use {Delivery}
class Disposition
+ include Util::Deprecation
+
# @private
PROTON_METHOD_PREFIX = "pn_disposition"
# @private
@@ -36,7 +38,7 @@ module Qpid::Proton
# @private
def initialize(impl, local)
- Qpid.deprecated self.class, Delivery
+ deprecated self.class, Delivery
@impl = impl
@local = local
@data = nil
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/endpoint.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb
index bd66f7a..86d8efe 100644
--- a/proton-c/bindings/ruby/lib/core/endpoint.rb
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -30,9 +30,10 @@ module Qpid::Proton
# puts "Remote connection flags: #{conn.state || Qpid::Proton::Endpoint::REMOTE_MASK}"
#
class Endpoint
+ include Util::Deprecation
# The local connection is uninitialized.
- LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT
+ LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT
# The local connection is active.
LOCAL_ACTIVE = Cproton::PN_LOCAL_ACTIVE
# The local connection is closed.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index 079d1bd..ee0fc02 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -17,12 +17,11 @@
module Qpid::Proton
- # AMQP protocol event.
- #
- # Includes a method name to call when the event is dispatched, and the context
- # objects relevant to the event.
+
+ # @deprecated Only used with the deprecated {Handler::MessagingHandler} API.
class Event
private
+ include Util::Deprecation
PROTON_METHOD_PREFIX = "pn_disposition"
include Util::Wrapper
@@ -150,9 +149,9 @@ module Qpid::Proton
end
# @deprecated use {#container}
- def reactor() Qpid.deprecated __method__, :container; container; end
+ deprecated_alias :reactor, :container
- # @deprecated use {Qpid::Proton::Event}
+ # @private
Event = self
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/link.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/link.rb b/proton-c/bindings/ruby/lib/core/link.rb
index 209d018..88c0e52 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -286,7 +286,7 @@ module Qpid::Proton
# @deprecated use {Sender#send}
def delivery(tag)
- Qpid.deprecated __method__, "Sender#send"
+ deprecated __method__, "Sender#send"
Delivery.new(Cproton.pn_delivery(@impl, tag))
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/message.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb
index 7041d04..8b13de2 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -31,6 +31,7 @@ module Qpid::Proton
# msg.body = Qpid::Proton::BinaryString.new(File.binread("/home/qpid/binfile.tar.gz"))
#
class Message
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_message"
@@ -364,11 +365,13 @@ module Qpid::Proton
# @deprecated use {#body=}
def content=(content)
+ deprecated __method__, "body="
Cproton.pn_message_load(@impl, content)
end
# @deprecated use {#body}
def content
+ deprecated __method__, "body"
size = 16
loop do
result = Cproton.pn_message_save(@impl, size)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/sasl.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/sasl.rb b/proton-c/bindings/ruby/lib/core/sasl.rb
index 08b5e4e..14ab238 100644
--- a/proton-c/bindings/ruby/lib/core/sasl.rb
+++ b/proton-c/bindings/ruby/lib/core/sasl.rb
@@ -29,6 +29,7 @@ module Qpid::Proton
#
# @note Do not instantiate directly, use {Transport#sasl} to create a SASL object.
class SASL
+ include Util::Deprecation
# Negotation has not completed.
NONE = Cproton::PN_SASL_NONE
@@ -65,9 +66,7 @@ module Qpid::Proton
end
# @deprecated use {#allowed_mechs=}
- def mechanisms(m)
- self.allowed_mechs = m
- end
+ deprecated_alias :mechanisms, :allowed_mechs=
# True if extended SASL negotiation is supported
#
@@ -82,44 +81,43 @@ module Qpid::Proton
Cproton.pn_sasl_extended()
end
- # Set the sasl configuration path
- #
- # This is used to tell SASL where to look for the configuration file.
- # In the current implementation it can be a colon separated list of directories.
- #
- # The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
- # but if both methods are used then this pn_sasl_config_path() will take precedence.
- #
- # If not set the underlying implementation default will be used.
- #
- # @param path the configuration path
- #
- def self.config_path=(path)
- Cproton.pn_sasl_config_path(nil, path)
- path
- end
-
- # @deprecated use {config_path=}
- def self.config_path(path)
- self.config_path = path
- end
-
- # Set the configuration file name, without extension
- #
- # The name with an a ".conf" extension will be searched for in the
- # configuration path. If not set, it defaults to "proton-server" or
- # "proton-client" for a server (incoming) or client (outgoing) connection
- # respectively.
- #
- # @param name the configuration file name without extension
- #
- def self.config_name=(name)
- Cproton.pn_sasl_config_name(nil, name)
- end
-
- # @deprecated use {config_name=}
- def self.config_name(name)
- self.config_name = name
+ class << self
+ include Util::Deprecation
+
+ # Set the sasl configuration path
+ #
+ # This is used to tell SASL where to look for the configuration file.
+ # In the current implementation it can be a colon separated list of directories.
+ #
+ # The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
+ # but if both methods are used then this pn_sasl_config_path() will take precedence.
+ #
+ # If not set the underlying implementation default will be used.
+ #
+ # @param path the configuration path
+ #
+ def config_path=(path)
+ Cproton.pn_sasl_config_path(nil, path)
+ path
+ end
+
+ # Set the configuration file name, without extension
+ #
+ # The name with an a ".conf" extension will be searched for in the
+ # configuration path. If not set, it defaults to "proton-server" or
+ # "proton-client" for a server (incoming) or client (outgoing) connection
+ # respectively.
+ #
+ # @param name the configuration file name without extension
+ #
+ def config_name=(name)
+ Cproton.pn_sasl_config_name(nil, name)
+ end
+
+ # @deprecated use {config_path=}
+ deprecated_alias :config_path, :config_path=
+ # @deprecated use {config_name=}
+ deprecated_alias :config_name, :config_name=
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/sender.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/sender.rb b/proton-c/bindings/ruby/lib/core/sender.rb
index bef3460..4c7324c 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -50,7 +50,7 @@ module Qpid::Proton
raise ArgumentError("too many arguments") if args.size > 1
tag = args[0]
end
- tag ||= delivery_tag
+ tag ||= next_tag
t = Tracker.new(Cproton.pn_delivery(@impl, tag))
Cproton.pn_link_send(@impl, message.encode)
Cproton.pn_link_advance(@impl)
@@ -58,19 +58,20 @@ module Qpid::Proton
return t
end
- # @deprecated internal use only
+ # @deprecated use {#send}
def stream(bytes)
+ deprecated __method__, "send"
Cproton.pn_link_send(@impl, bytes)
end
# @deprecated internal use only
- def delivery_tag
- @tag_count ||= 0
- result = @tag_count.succ
- @tag_count = result
- return result.to_s(32) # Base 32 compactness
- end
+ def delivery_tag() deprecated(__method__); next_tag; end
- end
+ private
+ def initialize(*arg) super; @tag_count = 0; end
+ def next_tag() (@tag_count += 1).to_s(32); end
+ end
end
+
+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/session.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/session.rb b/proton-c/bindings/ruby/lib/core/session.rb
index 26a7a2f..14f1a67 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -23,6 +23,7 @@ module Qpid::Proton
# A Session has a single parent Qpid::Proton::Connection instance.
#
class Session < Endpoint
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_session"
@@ -112,10 +113,16 @@ module Qpid::Proton
end
# @deprecated use {#open_sender}
- def sender(name) Sender.new(Cproton.pn_sender(@impl, name)); end
+ def sender(name)
+ deprecated __method__, "open_sender"
+ Sender.new(Cproton.pn_sender(@impl, name));
+ end
# @deprecated use {#open_receiver}
- def receiver(name) Receiver.new(Cproton.pn_receiver(@impl, name)); end
+ def receiver(name)
+ deprecated __method__, "open_receiver"
+ Receiver.new(Cproton.pn_receiver(@impl, name))
+ end
# TODO aconway 2016-01-04: doc options or target param, move option handling to Link.
def open_receiver(opts=nil)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/ssl.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb
index 11db54d..ec4f14d 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -51,7 +51,7 @@ module Qpid::Proton
# @see #resume_status
#
class SSL
-
+
# Session resume state is unkonnwn or not supported.
RESUME_UNKNOWN = Cproton::PN_SSL_RESUME_UNKNOWN
# Session renegotiated and not resumed.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index f9c67f5..17f3b82 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# Status of a message transfer on a {Link}
# Common base class for {Tracker} and {Delivery}.
class Transfer
+ include Util::Deprecation
# @!private
PROTON_METHOD_PREFIX = "pn_delivery"
@@ -66,7 +67,7 @@ module Qpid::Proton
def id() Cproton.pn_delivery_tag(@impl); end
# @deprecated use {#id}
- alias tag id
+ deprecated_alias :tag, :id
# @return [Boolean] True if the transfer has is remotely settled.
proton_caller :settled?
@@ -105,7 +106,7 @@ module Qpid::Proton
# @deprecated internal use only
def local_state() Cproton.pn_delivery_local_state(@impl); end
# @deprecated use {#state}
- def remote_state() Cproton.pn_delivery_remote_state(@impl); end
+ deprecated_alias :remote_state, :state
# @deprecated internal use only
def settle(state = nil)
update(state) unless state.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/transport.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb
index f840f3f..64a8011 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -62,6 +62,8 @@ module Qpid::Proton
# PN_TRACE_FRM=1 ruby my_proton_app.rb
#
class Transport
+ include Util::Deprecation
+
# @private
PROTON_METHOD_PREFIX = "pn_transport"
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/url.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/url.rb b/proton-c/bindings/ruby/lib/core/url.rb
index 48f295c..1103e06 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -20,6 +20,7 @@ module Qpid::Proton
# @deprecated use {URI} or {String}
class URL
+ include Util::Deprecation
attr_reader :scheme
attr_reader :username
@@ -32,7 +33,7 @@ module Qpid::Proton
# Parse a string, return a new URL
# @param url [#to_s] the URL string
def initialize(url = nil)
- Qpid.deprecated self.class, 'URI or String'
+ deprecated self.class, 'URI or String'
if url
@url = Cproton.pn_url_parse(url.to_s)
if @url.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
index 4f24d09..92dbba4 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
@@ -97,7 +97,7 @@ module Qpid::Proton
add_credit(event.receiver)
else # Outgoing message
t = event.tracker
- case t.remote_state
+ case t.state
when Delivery::ACCEPTED then delegate(:on_tracker_accept, t)
when Delivery::REJECTED then delegate(:on_tracker_reject, t)
when Delivery::RELEASED then delegate(:on_tracker_release, t)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
index e4e5e12..d01ea1e 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::MessagingHandler}
class MessagingHandler
+ include Util::Deprecation
# @private
def proton_adapter_class() Handler::ReactorMessagingAdapter; end
@@ -48,9 +49,9 @@ module Qpid::Proton
# the set the local error condition {Condition}("error", "unexpected peer close")
#
# @overload initialize(prefetch=10, auto_accept=true, auto_settle=true, peer_close_is_error=false)
- # @deprecated use +initialize(opts)+ overload
+ # @deprecated use +initialize(opts)+ overload
def initialize(*args)
- Qpid.deprecated MessagingHandler, Qpid::Proton::MessagingHandler
+ deprecated MessagingHandler, Qpid::Proton::MessagingHandler
@options = {}
if args.size == 1 && args[0].is_a?(Hash)
@options.replace(args[0])
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
index 7acbbae..3466ef1 100644
--- a/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
@@ -128,7 +128,7 @@ module Qpid::Proton
else # Outgoing message
t = event.tracker
if t.updated?
- case t.remote_state
+ case t.state
when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index 0c39429..7b992e2 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -56,6 +56,7 @@ module Qpid::Proton::Messenger
class Messenger
include Qpid::Proton::Util::ErrorHandler
+ include Qpid::Proton::Util::Deprecation
can_raise_error [:send, :receive, :password=, :start, :stop,
:perform_put, :perform_get, :interrupt,
@@ -72,7 +73,7 @@ module Qpid::Proton::Messenger
# * name - the name (def. nil)
#
def initialize(name = nil)
- Qpid.deprecated 'Qpid::Proton::Messenger', 'Qpid::Proton::Container'
+ deprecated Qpid::Proton::Messenger, Qpid::Proton::Container
@impl = Cproton.pn_messenger(name)
@selectables = {}
ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 922504f..79c8cb7 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -29,15 +29,10 @@ end
# Qpid is the top level module for the Qpid project http://qpid.apache.org
# Definitions for this library are in module {Qpid::Proton}
module Qpid
- # @private
- def self.deprecated(old, new=nil)
- repl = new ? "use `#{new}`" : "internal use only"
- warn "[DEPRECATION] `#{old}` is deprecated, #{repl} (called from #{caller(2).first})"
- end
-
# Proton is a ruby API for sending and receiving AMQP messages in clients or servers.
# See the {overview}[../file.README.html] for more.
module Proton
+ # Only opened here for module doc comment
end
end
@@ -45,6 +40,7 @@ end
require "core/exceptions"
# Utility classes
+require "util/deprecation"
require "util/version"
require "util/error_handler"
require "util/wrapper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/reactor/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/container.rb b/proton-c/bindings/ruby/lib/reactor/container.rb
index a900d9e..22cb0e8 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::Container}
class Container < Qpid::Proton::Container
+ include Util::Deprecation
private
alias super_connect connect # Access to superclass method
@@ -29,7 +30,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::Container}
def initialize(handlers, opts=nil)
- Qpid.deprecated self.class, "Qpid::Proton::Container"
+ deprecated Qpid::Proton::Reactor::Container, Qpid::Proton::Container
h = handlers || (opts && opts[:global_handler])
id = opts && opts[:container_id]
super(h, id)
@@ -44,7 +45,6 @@ module Qpid::Proton
super(url, opts)
end
- # @deprecated use {#connect} then {Connection#open_sender}
def create_sender(context, opts=nil)
c = context if context.is_a? Qpid::Proton::Connection
unless c
@@ -56,7 +56,6 @@ module Qpid::Proton
c.open_sender opts
end
- # @deprecated use {#connect} then {Connection#open_receiver}
def create_receiver(context, opts=nil)
c = context if context.is_a? Qpid::Proton::Connection
unless c
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/types/array.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/array.rb b/proton-c/bindings/ruby/lib/types/array.rb
index 4ea1d70..7a20adb 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -26,7 +26,10 @@ module Qpid::Proton
# @deprecated use {UniformArray}
class ArrayHeader
- def initialize(type, descriptor = nil) @type, @descriptor = Codec::Mapping[type], descriptor; end
+ def initialize(type, descriptor = nil)
+ Util::Deprecation.deprecated ArrayHeader, "UniformArray"
+ @type, @descriptor = Codec::Mapping[type], descriptor
+ end
attr_reader :type, :descriptor
def described?() !@descriptor.nil?; end
def <=>(x) [@type, @descriptor] <=> [x.type, x.descriptor]; end
@@ -72,25 +75,25 @@ end
class ::Array
# @deprecated use {UniformArray}
def proton_array_header
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header
end
# @deprecated use {UniformArray}
def proton_array_header=(h)
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header= h
end
# @deprecated use {UniformArray}
def proton_described?()
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header && @proton_array_header.described?
end
# @deprecated
def proton_put(data)
- Qpid.deprecated __method__, "Codec::Data#array=, Codec::Data#list="
+ Qpid::Proton::Util::Deprecation.deprecated __method__, "Codec::Data#array=, Codec::Data#list="
raise TypeError, "nil data" unless data
if @proton_array_header && @proton_array_header.type
data.array = self
@@ -101,7 +104,7 @@ class ::Array
# @deprecated
def self.proton_get(data)
- Qpid.deprecated __method__, "Codec::Data#list"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, "Codec::Data#list"
data.list
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index f70cbdb..2d78f74 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -23,15 +23,17 @@
# @private
class Hash # :nodoc:
+
+
# @deprecated
def proton_data_put(data)
- Qpid.deprecated(__method__, "Codec::Data#map=")
+ Qpid::Proton::Util::Deprecation.deprecated(__method__, "Codec::Data#map=")
data.map = self
end
# @deprecated
def self.proton_data_get(data)
- Qpid.deprecated(__method__, "Codec::Data#map")
+ Qpid::Proton::Util::Deprecation.deprecated(__method__, "Codec::Data#map")
data.map
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
new file mode 100644
index 0000000..2e83783
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -0,0 +1,42 @@
+# 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::Proton::Util
+ # @private
+ module Deprecation
+ def self.deprecated(old, new=nil, skip=2)
+ replace = new ? "use `#{new}`" : "internal use only"
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from\n #{caller(skip).first}"
+ end
+
+ def deprecated(*arg) Deprecation.deprecated(*arg); end
+
+ module ClassMethods
+ def deprecated_alias(bad, good)
+ bad, good = bad.to_sym, good.to_sym
+ define_method(bad) do |*args, &block|
+ self.deprecated bad, good, 3
+ self.__send__(good, *args, &block)
+ end
+ end
+ end
+
+ def self.included(other)
+ other.__send__ :extend, ClassMethods
+ end
+ end
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org