Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E45412009C6 for ; Tue, 17 May 2016 05:45:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E2C8F160A19; Tue, 17 May 2016 03:45:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BE860160A16 for ; Tue, 17 May 2016 05:45:27 +0200 (CEST) Received: (qmail 5562 invoked by uid 500); 17 May 2016 03:45:26 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 5552 invoked by uid 99); 17 May 2016 03:45:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 May 2016 03:45:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A91BDDFB79; Tue, 17 May 2016 03:45:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jross@apache.org To: commits@qpid.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: qpid-proton git commit: PROTON-1200: Rename handler to messaging_handler, to avoid the suggestion that it is a base class or interface for the other types of handlers, and for consistency with other bindings Date: Tue, 17 May 2016 03:45:26 +0000 (UTC) archived-at: Tue, 17 May 2016 03:45:30 -0000 Repository: qpid-proton Updated Branches: refs/heads/master 2dc4afe08 -> 1b43731d6 PROTON-1200: Rename handler to messaging_handler, to avoid the suggestion that it is a base class or interface for the other types of handlers, and for consistency with other bindings Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1b43731d Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1b43731d Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1b43731d Branch: refs/heads/master Commit: 1b43731d6be1b8812fc69a744c2d9106da357c97 Parents: 2dc4afe Author: Justin Ross Authored: Mon May 16 20:45:08 2016 -0700 Committer: Justin Ross Committed: Mon May 16 20:45:08 2016 -0700 ---------------------------------------------------------------------- examples/cpp/broker.cpp | 9 +- examples/cpp/broker.hpp | 6 +- examples/cpp/client.cpp | 4 +- examples/cpp/connection_options.cpp | 6 +- examples/cpp/direct_recv.cpp | 4 +- examples/cpp/direct_send.cpp | 4 +- examples/cpp/flow_control.cpp | 8 +- examples/cpp/helloworld.cpp | 4 +- examples/cpp/helloworld_direct.cpp | 4 +- examples/cpp/mt/broker.cpp | 4 +- examples/cpp/queue_browser.cpp | 4 +- examples/cpp/selected_recv.cpp | 4 +- examples/cpp/server.cpp | 4 +- examples/cpp/server_direct.cpp | 4 +- examples/cpp/simple_recv.cpp | 4 +- examples/cpp/simple_send.cpp | 4 +- examples/cpp/ssl.cpp | 6 +- examples/cpp/ssl_client_cert.cpp | 6 +- examples/cpp/tutorial.dox | 64 ++++--- .../bindings/cpp/include/proton/connection.hpp | 2 +- .../cpp/include/proton/connection_options.hpp | 6 +- .../bindings/cpp/include/proton/container.hpp | 12 +- .../cpp/include/proton/default_container.hpp | 8 +- .../bindings/cpp/include/proton/handler.hpp | 177 ------------------- .../cpp/include/proton/io/connection_engine.hpp | 18 +- .../cpp/include/proton/listen_handler.hpp | 4 +- .../cpp/include/proton/messaging_handler.hpp | 177 +++++++++++++++++++ .../cpp/include/proton/receiver_options.hpp | 6 +- .../cpp/include/proton/sender_options.hpp | 10 +- .../bindings/cpp/include/proton/session.hpp | 2 +- .../cpp/include/proton/session_options.hpp | 6 +- .../bindings/cpp/include/proton/thread_safe.hpp | 2 +- .../bindings/cpp/src/connection_options.cpp | 6 +- proton-c/bindings/cpp/src/container_impl.cpp | 4 +- proton-c/bindings/cpp/src/container_impl.hpp | 4 +- proton-c/bindings/cpp/src/container_test.cpp | 4 +- proton-c/bindings/cpp/src/engine_test.cpp | 4 +- proton-c/bindings/cpp/src/handler.cpp | 58 +++--- proton-c/bindings/cpp/src/messaging_adapter.cpp | 2 +- proton-c/bindings/cpp/src/messaging_adapter.hpp | 8 +- proton-c/bindings/cpp/src/proton_handler.hpp | 2 +- proton-c/bindings/cpp/src/reactor.hpp | 2 +- proton-c/bindings/cpp/src/receiver_options.cpp | 4 +- proton-c/bindings/cpp/src/sender_options.cpp | 4 +- proton-c/bindings/cpp/src/session_options.cpp | 2 +- tests/tools/apps/cpp/reactor_send.cpp | 4 +- 46 files changed, 348 insertions(+), 343 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/broker.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp index 86e5683..87d9949 100644 --- a/examples/cpp/broker.cpp +++ b/examples/cpp/broker.cpp @@ -19,13 +19,13 @@ * */ -#include +#include "proton/config.hpp" #include "options.hpp" #include "proton/connection.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/message.hpp" #include "proton/receiver_options.hpp" #include "proton/sender.hpp" @@ -150,7 +150,7 @@ class queues { }; // A handler to implement broker logic -class broker_handler : public proton::handler { +class broker_handler : public proton::messaging_handler { public: broker_handler(queues& qs) : queues_(qs) {} @@ -231,7 +231,7 @@ class broker { public: broker(const std::string& url) : handler_(url, queues_) {} - proton::handler& handler() { return handler_; } + proton::messaging_handler& handler() { return handler_; } private: class my_handler : public broker_handler { @@ -252,7 +252,6 @@ class broker { my_handler handler_; }; - int main(int argc, char **argv) { std::string url("0.0.0.0"); example::options opts(argc, argv); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/broker.hpp ---------------------------------------------------------------------- diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp index 844f9d6..c8e4ae2 100644 --- a/examples/cpp/broker.hpp +++ b/examples/cpp/broker.hpp @@ -29,7 +29,7 @@ #include "proton/connection.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/message.hpp" #include "proton/sasl.hpp" #include "proton/sender.hpp" @@ -154,10 +154,10 @@ class queues { uint64_t next_id_; // Use to generate unique queue IDs. }; -#include +#include "proton/config.hpp" /** Common handler logic for brokers. */ -class broker_handler : public proton::handler { +class broker_handler : public proton::messaging_handler { public: broker_handler(queues& qs) : queues_(qs) {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/client.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp index ab6ae12..95a504c 100644 --- a/examples/cpp/client.cpp +++ b/examples/cpp/client.cpp @@ -22,7 +22,7 @@ #include "options.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/connection.hpp" #include "proton/tracker.hpp" #include "proton/source_options.hpp" @@ -35,7 +35,7 @@ using proton::receiver_options; using proton::source_options; -class client : public proton::handler { +class client : public proton::messaging_handler { private: std::string url; std::vector requests; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/connection_options.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp index d9f7768..e615602 100644 --- a/examples/cpp/connection_options.cpp +++ b/examples/cpp/connection_options.cpp @@ -22,7 +22,7 @@ #include "proton/connection.hpp" #include "proton/connection_options.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/transport.hpp" #include @@ -31,7 +31,7 @@ using proton::connection_options; #include -class handler_2 : public proton::handler { +class handler_2 : public proton::messaging_handler { void on_connection_open(proton::connection &c) PN_CPP_OVERRIDE { std::cout << "connection events going to handler_2" << std::endl; std::cout << "connection max_frame_size: " << c.max_frame_size() << @@ -40,7 +40,7 @@ class handler_2 : public proton::handler { } }; -class main_handler : public proton::handler { +class main_handler : public proton::messaging_handler { private: std::string url; handler_2 conn_handler; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/direct_recv.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp index cfd8ee7..1142c9e 100644 --- a/examples/cpp/direct_recv.cpp +++ b/examples/cpp/direct_recv.cpp @@ -24,7 +24,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/link.hpp" #include "proton/value.hpp" @@ -33,7 +33,7 @@ #include -class direct_recv : public proton::handler { +class direct_recv : public proton::messaging_handler { private: std::string url; proton::listener listener; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/direct_send.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp index ccbe009..5f3e68a 100644 --- a/examples/cpp/direct_send.cpp +++ b/examples/cpp/direct_send.cpp @@ -23,7 +23,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/value.hpp" #include "proton/tracker.hpp" @@ -32,7 +32,7 @@ #include -class simple_send : public proton::handler { +class simple_send : public proton::messaging_handler { private: std::string url; proton::listener listener; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/flow_control.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/flow_control.cpp b/examples/cpp/flow_control.cpp index d40f15b..8be9777 100644 --- a/examples/cpp/flow_control.cpp +++ b/examples/cpp/flow_control.cpp @@ -23,7 +23,7 @@ #include "proton/connection.hpp" #include "proton/connection_options.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/sender.hpp" #include "proton/tracker.hpp" #include "proton/delivery.hpp" @@ -49,7 +49,7 @@ void verify(bool success, const std::string &msg) { } // flow_sender manages the incoming connection and acts as the message sender. -class flow_sender : public proton::handler { +class flow_sender : public proton::messaging_handler { private: int available; // Number of messages the sender may send assuming sufficient credit. int sequence; @@ -83,7 +83,7 @@ class flow_sender : public proton::handler { void set_available(int n) { available = n; } }; -class flow_receiver : public proton::handler { +class flow_receiver : public proton::messaging_handler { public: int stage; int received; @@ -185,7 +185,7 @@ class flow_receiver : public proton::handler { }; -class flow_control : public proton::handler { +class flow_control : public proton::messaging_handler { private: std::string url; proton::listener listener; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/helloworld.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp index f14863f..4e94713 100644 --- a/examples/cpp/helloworld.cpp +++ b/examples/cpp/helloworld.cpp @@ -22,7 +22,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/tracker.hpp" #include "proton/url.hpp" @@ -30,7 +30,7 @@ #include -class hello_world : public proton::handler { +class hello_world : public proton::messaging_handler { private: proton::url url; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/helloworld_direct.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp index 5ea2261..5f7de40 100644 --- a/examples/cpp/helloworld_direct.cpp +++ b/examples/cpp/helloworld_direct.cpp @@ -21,7 +21,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/sender.hpp" #include "proton/tracker.hpp" @@ -29,7 +29,7 @@ #include -class hello_world_direct : public proton::handler { +class hello_world_direct : public proton::messaging_handler { private: std::string url; proton::listener listener; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/mt/broker.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/mt/broker.cpp b/examples/cpp/mt/broker.cpp index 36fefd3..97d7cbf 100644 --- a/examples/cpp/mt/broker.cpp +++ b/examples/cpp/mt/broker.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -121,7 +121,7 @@ class queues { /// FIXME aconway 2016-05-10: doc - point out queue/sender interaction as /// example of communication via event_loop::inject() /// -class broker_connection_handler : public proton::handler { +class broker_connection_handler : public proton::messaging_handler { public: broker_connection_handler(queues& qs) : queues_(qs) {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/queue_browser.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/queue_browser.cpp b/examples/cpp/queue_browser.cpp index 9f52a9d..c1f650d 100644 --- a/examples/cpp/queue_browser.cpp +++ b/examples/cpp/queue_browser.cpp @@ -22,7 +22,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/receiver_options.hpp" #include "proton/source_options.hpp" #include "proton/url.hpp" @@ -33,7 +33,7 @@ using proton::source_options; -class browser : public proton::handler { +class browser : public proton::messaging_handler { private: proton::url url; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/selected_recv.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/selected_recv.cpp b/examples/cpp/selected_recv.cpp index 3c57905..25fdd36 100644 --- a/examples/cpp/selected_recv.cpp +++ b/examples/cpp/selected_recv.cpp @@ -21,7 +21,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/receiver_options.hpp" #include "proton/source_options.hpp" #include "proton/url.hpp" @@ -53,7 +53,7 @@ namespace { } -class selected_recv : public proton::handler { +class selected_recv : public proton::messaging_handler { private: proton::url url; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/server.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/server.cpp b/examples/cpp/server.cpp index 332fb1b..d803b5d 100644 --- a/examples/cpp/server.cpp +++ b/examples/cpp/server.cpp @@ -23,7 +23,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/tracker.hpp" #include "proton/url.hpp" @@ -34,7 +34,7 @@ #include -class server : public proton::handler { +class server : public proton::messaging_handler { private: typedef std::map sender_map; proton::url url; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/server_direct.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp index 74dcfd9..0c7a76b 100644 --- a/examples/cpp/server_direct.cpp +++ b/examples/cpp/server_direct.cpp @@ -22,7 +22,7 @@ #include "options.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/sender.hpp" #include "proton/source_options.hpp" #include "proton/tracker.hpp" @@ -35,7 +35,7 @@ #include -class server : public proton::handler { +class server : public proton::messaging_handler { private: typedef std::map sender_map; std::string url; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/simple_recv.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp index b1578ec..aa7cd1d 100644 --- a/examples/cpp/simple_recv.cpp +++ b/examples/cpp/simple_recv.cpp @@ -24,7 +24,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/link.hpp" #include "proton/message_id.hpp" #include "proton/value.hpp" @@ -34,7 +34,7 @@ #include -class simple_recv : public proton::handler { +class simple_recv : public proton::messaging_handler { private: std::string url; proton::receiver receiver; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/simple_send.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp index 921bb95..1ae71f3 100644 --- a/examples/cpp/simple_send.cpp +++ b/examples/cpp/simple_send.cpp @@ -23,7 +23,7 @@ #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/tracker.hpp" #include "proton/value.hpp" @@ -32,7 +32,7 @@ #include -class simple_send : public proton::handler { +class simple_send : public proton::messaging_handler { private: std::string url; proton::sender sender; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/ssl.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp index 379c95b..a4ca46a 100644 --- a/examples/cpp/ssl.cpp +++ b/examples/cpp/ssl.cpp @@ -22,7 +22,7 @@ #include "proton/connection_options.hpp" #include "proton/connection.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/ssl.hpp" #include "proton/tracker.hpp" #include "proton/transport.hpp" @@ -44,7 +44,7 @@ static std::string cert_directory; std::string find_CN(const std::string &); -struct server_handler : public proton::handler { +struct server_handler : public proton::messaging_handler { std::string url; void on_connection_open(proton::connection &c) PN_CPP_OVERRIDE { @@ -59,7 +59,7 @@ struct server_handler : public proton::handler { }; -class hello_world_direct : public proton::handler { +class hello_world_direct : public proton::messaging_handler { private: std::string url; server_handler s_handler; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/ssl_client_cert.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp index b16aad4..e150255 100644 --- a/examples/cpp/ssl_client_cert.cpp +++ b/examples/cpp/ssl_client_cert.cpp @@ -22,7 +22,7 @@ #include "proton/connection.hpp" #include "proton/connection_options.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/sasl.hpp" #include "proton/ssl.hpp" #include "proton/tracker.hpp" @@ -46,7 +46,7 @@ static std::string cert_directory; static std::string find_CN(const std::string &); -struct server_handler : public proton::handler { +struct server_handler : public proton::messaging_handler { proton::listener listener; void on_connection_open(proton::connection &c) PN_CPP_OVERRIDE { @@ -69,7 +69,7 @@ struct server_handler : public proton::handler { }; -class hello_world_direct : public proton::handler { +class hello_world_direct : public proton::messaging_handler { private: std::string url; server_handler s_handler; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/examples/cpp/tutorial.dox ---------------------------------------------------------------------- diff --git a/examples/cpp/tutorial.dox b/examples/cpp/tutorial.dox index ab46a1d..468c4f7 100644 --- a/examples/cpp/tutorial.dox +++ b/examples/cpp/tutorial.dox @@ -10,9 +10,10 @@ This is a brief tutorial that will walk you through the fundamentals of building messaging applications in incremental steps. There are further examples, in addition the ones mentioned in the tutorial. -Proton provides an "event-driven" programming model, where you implement a -subclass of `proton::handler` and override functions that react to various AMQP -events (connections opening and closing, messages being delivered and so on.) +Proton provides an "event-driven" programming model, where you +implement a subclass of `proton::messaging_handler` and override +functions that react to various AMQP events (connections opening and +closing, messages being delivered and so on.) The examples below show how to implement handlers for clients and servers and how to run them using the `proton::container`, a portable, easy-to-use way to @@ -50,24 +51,28 @@ to a broker and the receives the same message back to demonstrate sending and receiving. In a realistic system the sender and receiver would normally be in different processes. The complete example is @ref helloworld.cpp -We will include the following classes: `proton::container` runs an event loop -which dispatches events to a `proton::handler`. This allows a *reactive* -style of programming which is well suited to messaging applications. `proton::url` is a simple parser for the URL format mentioned above. +We will include the following classes: `proton::container` runs an +event loop which dispatches events to a +`proton::messaging_handler`. This allows a *reactive* style of +programming which is well suited to messaging +applications. `proton::url` is a simple parser for the URL format +mentioned above. \skip proton/container \until proton/url We will define a class `hello_world` which is a subclass of -`proton::handler` and over-rides functions to handle the events -of interest in sending and receiving a message. +`proton::messaging_handler` and over-rides functions to handle the +events of interest in sending and receiving a message. \skip class hello_world \until {} -`on_start()` is called when the event loop first starts. We handle that by -establishing a connection and creating a sender and a receiver. +`on_container_start()` is called when the event loop first starts. We +handle that by establishing a connection and creating a sender and a +receiver. -\skip on_start +\skip on_container_start \until } `on_sendable()` is called when message can be transferred over the associated @@ -88,11 +93,12 @@ the message and close the connection, as we only want one message The message body is a `proton::value`, see the documentation for more on how to extract the message body as type-safe C++ values. -Our `main` function creates an instance of the `hello_world` handler and a -proton::container using that handler. Calling `proton::container::run` sets -things in motion and returns when we close the connection as there is nothing -further to do. It may throw an exception, which will be a subclass of -`proton::error`. That in turn is a subclass of `std::exception`. +Our `main` function creates an instance of the `hello_world` handler +and a `proton::container` using that handler. Calling +`proton::container::run` sets things in motion and returns when we +close the connection as there is nothing further to do. It may throw +an exception, which will be a subclass of `proton::error`. That in +turn is a subclass of `std::exception`. \skip main \until } @@ -115,7 +121,7 @@ The first difference, is that rather than creating a receiver on the same connection as our sender, we listen for incoming connections by invoking the `proton::container::listen()` method on the container. -\skip on_start +\skip on_container_start \until } As we only need then to initiate one link, the sender, we can do that by @@ -178,10 +184,10 @@ send. \skip class simple_send \until total -As before, we use the `on_start()` event to establish our sender link over which +As before, we use the `on_container_start()` event to establish our sender link over which we will transfer messages. -\skip on_start +\skip on_container_start \until } AMQP defines a credit-based flow control mechanism. Flow control allows @@ -234,10 +240,10 @@ a `received` variable to count how many we have received so far. \skip class simple_recv \until received -We handle `on_start()` by creating our receiver, much like we -did for the sender. +We handle `on_container_start()` by creating our receiver, much like +we did for the sender. -\skip on_start +\skip on_container_start \until } We also handle the `on_message()` event for received messages and print the @@ -264,7 +270,7 @@ There are only two differences here. Instead of initiating a link (and implicitly a connection), we listen for incoming connections. -\skip on_start +\skip on_container_start \until } When we have received all the expected messages, we then stop listening for @@ -289,7 +295,7 @@ in @ref direct_send.cpp. Again that just requires two modifications: As with the modified receiver, instead of initiating establishment of a link, we listen for incoming connections. -\skip on_start +\skip on_container_start \until } When we have received confirmation of all the messages we sent, we call @@ -336,12 +342,12 @@ Our client takes a list of strings to send as requests \skipline client( -Since we will be sending and receiving, we create a sender and a receiver in -`on_start`. Our receiver has a blank address and sets the `dynamic` flag to -true, which means we expect the remote end (broker or server) to assign a unique -address for us. +Since we will be sending and receiving, we create a sender and a +receiver in `on_container_start`. Our receiver has a blank address +and sets the `dynamic` flag to true, which means we expect the remote +end (broker or server) to assign a unique address for us. -\skip on_start +\skip on_container_start \until } Now a function to send the next request from our list of requests. We set the http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/connection.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/connection.hpp b/proton-c/bindings/cpp/include/proton/connection.hpp index bfe4000..a504954 100644 --- a/proton-c/bindings/cpp/include/proton/connection.hpp +++ b/proton-c/bindings/cpp/include/proton/connection.hpp @@ -35,7 +35,7 @@ struct pn_connection_t; namespace proton { -class handler; +class messaging_handler; class connection_options; class sender; class sender_options; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/connection_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/connection_options.hpp b/proton-c/bindings/cpp/include/proton/connection_options.hpp index 5d80548..54c1848 100644 --- a/proton-c/bindings/cpp/include/proton/connection_options.hpp +++ b/proton-c/bindings/cpp/include/proton/connection_options.hpp @@ -70,7 +70,7 @@ class connection_options { PN_CPP_EXTERN connection_options(); /// Shorthand for connection_options().handler(h) - PN_CPP_EXTERN connection_options(class handler& h); + PN_CPP_EXTERN connection_options(class messaging_handler& h); /// Copy options. PN_CPP_EXTERN connection_options(const connection_options&); @@ -84,8 +84,8 @@ class connection_options { /// Set a connection handler. /// - /// The handler must not be deleted until handler::on_transport_close() is called. - PN_CPP_EXTERN connection_options& handler(class handler&); + /// The handler must not be deleted until messaging_handler::on_transport_close() is called. + PN_CPP_EXTERN connection_options& handler(class messaging_handler&); /// Set the maximum frame size. PN_CPP_EXTERN connection_options& max_frame_size(uint32_t max); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/container.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp index f72ea76..7e9807a 100644 --- a/proton-c/bindings/cpp/include/proton/container.hpp +++ b/proton-c/bindings/cpp/include/proton/container.hpp @@ -37,7 +37,7 @@ namespace proton { class connection; class connection_options; class container_impl; -class handler; +class messaging_handler; class listen_handler; class receiver; class receiver_options; @@ -71,7 +71,7 @@ class PN_CPP_CLASS_EXTERN container { /// 2. options passed to connect() /// /// The handler in the composed options is used to call - /// proton::handler::on_connection_open() when the remote peer's + /// proton::messaging_handler::on_connection_open() when the remote peer's /// open response is received. virtual returned connect(const std::string& url, const connection_options &) = 0; @@ -167,7 +167,7 @@ class PN_CPP_CLASS_EXTERN container { /// Connection options that will be to outgoing connections. These /// are applied first and overriden by options provided in - /// connect() and handler::on_connection_open(). + /// connect() and messaging_handler::on_connection_open(). virtual void client_connection_options(const connection_options &) = 0; /// @copydoc client_connection_options @@ -176,14 +176,14 @@ class PN_CPP_CLASS_EXTERN container { /// Connection options that will be applied to incoming /// connections. These are applied first and overridden by options /// provided in listen(), listen_handler::on_accept() and - /// handler::on_connection_open(). + /// messaging_handler::on_connection_open(). virtual void server_connection_options(const connection_options &) = 0; /// @copydoc server_connection_options virtual connection_options server_connection_options() const = 0; /// Sender options applied to senders created by this - /// container. They are applied before handler::on_sender_open() + /// container. They are applied before messaging_handler::on_sender_open() /// and can be overridden. virtual void sender_options(const sender_options &) = 0; @@ -191,7 +191,7 @@ class PN_CPP_CLASS_EXTERN container { virtual class sender_options sender_options() const = 0; /// Receiver options applied to receivers created by this - /// container. They are applied before handler::on_receiver_open() + /// container. They are applied before messaging_handler::on_receiver_open() /// and can be overridden. virtual void receiver_options(const receiver_options &) = 0; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/default_container.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/default_container.hpp b/proton-c/bindings/cpp/include/proton/default_container.hpp index 06ed37b..8b18304 100644 --- a/proton-c/bindings/cpp/include/proton/default_container.hpp +++ b/proton-c/bindings/cpp/include/proton/default_container.hpp @@ -33,13 +33,13 @@ namespace proton { /// A single-threaded container. class PN_CPP_CLASS_EXTERN default_container : public container { public: - /// Create a default, single-threaded container with a handler. - /// The handler will be called for all events on all connections in the container. + /// Create a default, single-threaded container with a messaging_handler. + /// The messaging_handler will be called for all events on all connections in the container. /// /// Container ID should be unique within your system. If empty a random UUID is generated. - PN_CPP_EXTERN explicit default_container(proton::handler& h, const std::string& id = ""); + PN_CPP_EXTERN explicit default_container(proton::messaging_handler& h, const std::string& id = ""); - /// Create a default, single-threaded container without a handler. + /// Create a default, single-threaded container without a messaging_handler. /// /// Connections get their handlesr via proton::connection_options. /// Container-wide defaults are set with client_connection_options() and http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp deleted file mode 100644 index d367fd4..0000000 --- a/proton-c/bindings/cpp/include/proton/handler.hpp +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef PROTON_HANDLER_HPP -#define PROTON_HANDLER_HPP - -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "proton/export.hpp" -#include "proton/internal/pn_unique_ptr.hpp" - -namespace proton { - -class error_condition; -class container; -class event; -class transport; -class connection; -class session; -class sender; -class receiver; -class tracker; -class delivery; -class message; -class messaging_adapter; - -namespace io { -class connection_engine; -} - -/// A handler for Proton messaging events. -/// -/// Subclass and override the event-handling member functions. -/// -/// #### Close and error handling -/// -/// There are several objects that have `on_X_close` and `on_X_error` -/// functions. They are called as follows: -/// -/// - If `X` is closed cleanly, with no error status, then `on_X_close` -/// is called. -/// - If `X` is closed with an error, then `on_X_error` is called, -/// followed by `on_X_close`. The error condition is also available -/// in `on_X_close` from `X::condition()`. -/// -/// By default, if you do not implement `on_X_error`, it will call -/// `on_error`. If you do not implement `on_error` it will throw a -/// @ref proton::error exception, which may not be what you want but -/// does help to identify forgotten error handling quickly. -/// -/// #### Resource cleanup -/// -/// Every `on_X_open` event is paired with an `on_X_close` event which -/// can clean up any resources created by the open handler. In -/// particular this is still true if an error is reported with an -/// `on_X_error` event. The error-handling logic doesn't have to -/// manage resource clean up. It can assume that the close event will -/// be along to handle it. -class -PN_CPP_CLASS_EXTERN handler { - public: - PN_CPP_EXTERN handler(); - PN_CPP_EXTERN virtual ~handler(); - - /// The container event loop is starting. - PN_CPP_EXTERN virtual void on_container_start(container &c); - - /// A message is received. - PN_CPP_EXTERN virtual void on_message(delivery &d, message &m); - - /// A message can be sent. - PN_CPP_EXTERN virtual void on_sendable(sender &s); - - /// The underlying network transport is open - PN_CPP_EXTERN virtual void on_transport_open(transport &t); - - /// The underlying network transport has closed. - PN_CPP_EXTERN virtual void on_transport_close(transport &t); - - /// The underlying network transport has closed with an error - /// condition. - PN_CPP_EXTERN virtual void on_transport_error(transport &t); - - /// The remote peer opened the connection. - PN_CPP_EXTERN virtual void on_connection_open(connection &c); - - /// The remote peer closed the connection. - PN_CPP_EXTERN virtual void on_connection_close(connection &c); - - /// The remote peer closed the connection with an error condition. - PN_CPP_EXTERN virtual void on_connection_error(connection &c); - - /// The remote peer opened the session. - PN_CPP_EXTERN virtual void on_session_open(session &s); - - /// The remote peer closed the session. - PN_CPP_EXTERN virtual void on_session_close(session &s); - - /// The remote peer closed the session with an error condition. - PN_CPP_EXTERN virtual void on_session_error(session &s); - - /// The remote peer opened the link. - PN_CPP_EXTERN virtual void on_receiver_open(receiver& l); - - /// The remote peer closed the link. - PN_CPP_EXTERN virtual void on_receiver_close(receiver& l); - - /// The remote peer closed the link with an error condition. - PN_CPP_EXTERN virtual void on_receiver_error(receiver& l); - - /// The remote peer opened the link. - PN_CPP_EXTERN virtual void on_sender_open(sender& l); - - /// The remote peer closed the link. - PN_CPP_EXTERN virtual void on_sender_close(sender& l); - - /// The remote peer closed the link with an error condition. - PN_CPP_EXTERN virtual void on_sender_error(sender& l); - - /// The receiving peer accepted a transfer. - PN_CPP_EXTERN virtual void on_tracker_accept(tracker &d); - - /// The receiving peer rejected a transfer. - PN_CPP_EXTERN virtual void on_tracker_reject(tracker &d); - - /// The receiving peer released a transfer. - PN_CPP_EXTERN virtual void on_tracker_release(tracker &d); - - /// The receiving peer settled a transfer. - PN_CPP_EXTERN virtual void on_tracker_settle(tracker &d); - - /// The sending peer settled a transfer. - PN_CPP_EXTERN virtual void on_delivery_settle(delivery &d); - - /// The receiving peer has requested a drain of remaining credit. - PN_CPP_EXTERN virtual void on_sender_drain_start(sender &s); - - /// The credit outstanding at the time of the call to - /// receiver::drain has been consumed or returned. - PN_CPP_EXTERN virtual void on_receiver_drain_finish(receiver &r); - - /// Fallback error handling. - PN_CPP_EXTERN virtual void on_error(const error_condition &c); - - private: - internal::pn_unique_ptr messaging_adapter_; - - /// @cond INTERNAL - friend class container; - friend class container_impl; - friend class io::connection_engine; - friend class connection_options; - friend class receiver_options; - friend class sender_options; - friend class session_options; - /// @endcond -}; - -} // proton - -#endif // PROTON_HANDLER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp index c66db5e..13584da 100644 --- a/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp +++ b/proton-c/bindings/cpp/include/proton/io/connection_engine.hpp @@ -74,7 +74,7 @@ struct const_buffer { /// any IO or concurrency framework. /// /// io::connection_engine manages a single proton::connection and dispatches -/// events to a proton::handler. It does no IO of its own, but allows you to +/// events to a proton::messaging_handler. It does no IO of its own, but allows you to /// integrate AMQP protocol handling into any IO or concurrency framework. /// /// The application is coded the same way as for the @@ -86,7 +86,7 @@ struct const_buffer { /// /// You need to write the IO code to read AMQP data to the /// read_buffer(). The engine parses the AMQP frames. dispatch() calls -/// the appropriate functions on the applications proton::handler. You +/// the appropriate functions on the applications proton::messaging_handler. You /// write output data from the engine's write_buffer() to your IO. /// /// The engine is not safe for concurrent use, but you can process @@ -102,13 +102,13 @@ struct const_buffer { class PN_CPP_CLASS_EXTERN connection_engine { public: - /// Create a connection engine. opts must contain a handler. + /// Create a connection engine. opts must contain a messaging_handler. /// Takes ownership of loop, will be deleted only when the proton::connection is. PN_CPP_EXTERN connection_engine(proton::container&, link_namer&, event_loop* loop = 0); PN_CPP_EXTERN ~connection_engine(); - /// Configure a connection by applying exactly the options in opts (including proton::handler) + /// Configure a connection by applying exactly the options in opts (including proton::messaging_handler) /// Does not apply any default options, to apply container defaults use connect() or accept() /// instead. void configure(const connection_options& opts=connection_options()); @@ -120,8 +120,8 @@ PN_CPP_CLASS_EXTERN connection_engine { /// Call configure() with server options. /// Options applied: container::id(), container::server_connection_options(), opts. /// - /// Note this does not call connection::open(). If there is a handler in the - /// composed options it will receive handler::on_connection_open() and can + /// Note this does not call connection::open(). If there is a messaging_handler in the + /// composed options it will receive messaging_handler::on_connection_open() and can /// respond with connection::open() or connection::close() PN_CPP_EXTERN void accept(const connection_options& opts); @@ -157,16 +157,16 @@ PN_CPP_CLASS_EXTERN connection_engine { /// /// This calls read_close(), write_close(), sets the transport().error() and /// queues an `on_transport_error` event. You must call dispatch() one more - /// time to dispatch the handler::on_transport_error() call and other final + /// time to dispatch the messaging_handler::on_transport_error() call and other final /// events. /// - /// Note this does not close the connection() so that a proton::handler can + /// Note this does not close the connection() so that a proton::messaging_handler can /// distinguish between a connection close error sent by the remote peer and /// a transport failure. /// PN_CPP_EXTERN void disconnected(const error_condition& = error_condition()); - /// Dispatch all available events and call the corresponding \ref handler methods. + /// Dispatch all available events and call the corresponding \ref messaging_handler methods. /// /// Returns true if the engine is still active, false if it is finished and /// can be destroyed. The engine is finished when all events are dispatched http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/listen_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/listen_handler.hpp b/proton-c/bindings/cpp/include/proton/listen_handler.hpp index fc2c49e..acd7d4c 100644 --- a/proton-c/bindings/cpp/include/proton/listen_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/listen_handler.hpp @@ -35,8 +35,8 @@ class listen_handler { /// Called for each accepted connection. /// - /// Returns connection_options to apply, including a proton::handler for - /// the connection. handler::on_connection_open() will be called with + /// Returns connection_options to apply, including a proton::messaging_handler for + /// the connection. messaging_handler::on_connection_open() will be called with /// the proton::connection, it can call connection::open() to accept or /// connection::close() to reject the connection. virtual connection_options on_accept()= 0; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/messaging_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp new file mode 100644 index 0000000..b6e4b12 --- /dev/null +++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp @@ -0,0 +1,177 @@ +#ifndef PROTON_MESSAGING_HANDLER_HPP +#define PROTON_MESSAGING_HANDLER_HPP + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "proton/export.hpp" +#include "proton/internal/pn_unique_ptr.hpp" + +namespace proton { + +class error_condition; +class container; +class event; +class transport; +class connection; +class session; +class sender; +class receiver; +class tracker; +class delivery; +class message; +class messaging_adapter; + +namespace io { +class connection_engine; +} + +/// A handler for Proton messaging events. +/// +/// Subclass and override the event-handling member functions. +/// +/// #### Close and error handling +/// +/// There are several objects that have `on_X_close` and `on_X_error` +/// functions. They are called as follows: +/// +/// - If `X` is closed cleanly, with no error status, then `on_X_close` +/// is called. +/// - If `X` is closed with an error, then `on_X_error` is called, +/// followed by `on_X_close`. The error condition is also available +/// in `on_X_close` from `X::condition()`. +/// +/// By default, if you do not implement `on_X_error`, it will call +/// `on_error`. If you do not implement `on_error` it will throw a +/// @ref proton::error exception, which may not be what you want but +/// does help to identify forgotten error handling quickly. +/// +/// #### Resource cleanup +/// +/// Every `on_X_open` event is paired with an `on_X_close` event which +/// can clean up any resources created by the open handler. In +/// particular this is still true if an error is reported with an +/// `on_X_error` event. The error-handling logic doesn't have to +/// manage resource clean up. It can assume that the close event will +/// be along to handle it. +class +PN_CPP_CLASS_EXTERN messaging_handler { + public: + PN_CPP_EXTERN messaging_handler(); + PN_CPP_EXTERN virtual ~messaging_handler(); + + /// The container event loop is starting. + PN_CPP_EXTERN virtual void on_container_start(container &c); + + /// A message is received. + PN_CPP_EXTERN virtual void on_message(delivery &d, message &m); + + /// A message can be sent. + PN_CPP_EXTERN virtual void on_sendable(sender &s); + + /// The underlying network transport is open + PN_CPP_EXTERN virtual void on_transport_open(transport &t); + + /// The underlying network transport has closed. + PN_CPP_EXTERN virtual void on_transport_close(transport &t); + + /// The underlying network transport has closed with an error + /// condition. + PN_CPP_EXTERN virtual void on_transport_error(transport &t); + + /// The remote peer opened the connection. + PN_CPP_EXTERN virtual void on_connection_open(connection &c); + + /// The remote peer closed the connection. + PN_CPP_EXTERN virtual void on_connection_close(connection &c); + + /// The remote peer closed the connection with an error condition. + PN_CPP_EXTERN virtual void on_connection_error(connection &c); + + /// The remote peer opened the session. + PN_CPP_EXTERN virtual void on_session_open(session &s); + + /// The remote peer closed the session. + PN_CPP_EXTERN virtual void on_session_close(session &s); + + /// The remote peer closed the session with an error condition. + PN_CPP_EXTERN virtual void on_session_error(session &s); + + /// The remote peer opened the link. + PN_CPP_EXTERN virtual void on_receiver_open(receiver& l); + + /// The remote peer closed the link. + PN_CPP_EXTERN virtual void on_receiver_close(receiver& l); + + /// The remote peer closed the link with an error condition. + PN_CPP_EXTERN virtual void on_receiver_error(receiver& l); + + /// The remote peer opened the link. + PN_CPP_EXTERN virtual void on_sender_open(sender& l); + + /// The remote peer closed the link. + PN_CPP_EXTERN virtual void on_sender_close(sender& l); + + /// The remote peer closed the link with an error condition. + PN_CPP_EXTERN virtual void on_sender_error(sender& l); + + /// The receiving peer accepted a transfer. + PN_CPP_EXTERN virtual void on_tracker_accept(tracker &d); + + /// The receiving peer rejected a transfer. + PN_CPP_EXTERN virtual void on_tracker_reject(tracker &d); + + /// The receiving peer released a transfer. + PN_CPP_EXTERN virtual void on_tracker_release(tracker &d); + + /// The receiving peer settled a transfer. + PN_CPP_EXTERN virtual void on_tracker_settle(tracker &d); + + /// The sending peer settled a transfer. + PN_CPP_EXTERN virtual void on_delivery_settle(delivery &d); + + /// The receiving peer has requested a drain of remaining credit. + PN_CPP_EXTERN virtual void on_sender_drain_start(sender &s); + + /// The credit outstanding at the time of the call to + /// receiver::drain has been consumed or returned. + PN_CPP_EXTERN virtual void on_receiver_drain_finish(receiver &r); + + /// Fallback error handling. + PN_CPP_EXTERN virtual void on_error(const error_condition &c); + + private: + internal::pn_unique_ptr messaging_adapter_; + + /// @cond INTERNAL + friend class container; + friend class container_impl; + friend class io::connection_engine; + friend class connection_options; + friend class receiver_options; + friend class sender_options; + friend class session_options; + /// @endcond +}; + +} // proton + +#endif // PROTON_MESSAGING_HANDLER_HPP http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/receiver_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/receiver_options.hpp b/proton-c/bindings/cpp/include/proton/receiver_options.hpp index 6621232..39d40f7 100644 --- a/proton-c/bindings/cpp/include/proton/receiver_options.hpp +++ b/proton-c/bindings/cpp/include/proton/receiver_options.hpp @@ -75,9 +75,9 @@ class receiver_options { /// Merge with another option set PN_CPP_EXTERN void update(const receiver_options& other); - /// Set a handler for receiver events only. - /// The handler is no longer in use when handler::on_receiver_close() is called. - PN_CPP_EXTERN receiver_options& handler(class handler&); + /// Set a messaging_handler for receiver events only. + /// The handler is no longer in use when messaging_handler::on_receiver_close() is called. + PN_CPP_EXTERN receiver_options& handler(class messaging_handler&); /// Set the delivery mode on the receiver. PN_CPP_EXTERN receiver_options& delivery_mode(delivery_mode); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/sender_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/sender_options.hpp b/proton-c/bindings/cpp/include/proton/sender_options.hpp index b3f1f4c..0a2e4e0 100644 --- a/proton-c/bindings/cpp/include/proton/sender_options.hpp +++ b/proton-c/bindings/cpp/include/proton/sender_options.hpp @@ -77,11 +77,11 @@ class sender_options { /// Merge with another option set PN_CPP_EXTERN void update(const sender_options& other); - /// Set a handler for sender events only. - /// The handler is no longer in use when handler::on_sender_close() is called. - /// handler::on_sender_close() may not be called if a connection is aborted, - /// in that case it should be cleaned up in its connection's handler::on_transport_close() - PN_CPP_EXTERN sender_options& handler(class handler&); + /// Set a messaging_handler for sender events only. + /// The handler is no longer in use when messaging_handler::on_sender_close() is called. + /// messaging_handler::on_sender_close() may not be called if a connection is aborted, + /// in that case it should be cleaned up in its connection's messaging_handler::on_transport_close() + PN_CPP_EXTERN sender_options& handler(class messaging_handler&); /// Set the delivery mode on the sender. PN_CPP_EXTERN sender_options& delivery_mode(delivery_mode); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/session.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/session.hpp b/proton-c/bindings/cpp/include/proton/session.hpp index 164a5bd..1814b95 100644 --- a/proton-c/bindings/cpp/include/proton/session.hpp +++ b/proton-c/bindings/cpp/include/proton/session.hpp @@ -39,7 +39,7 @@ struct pn_session_t; namespace proton { class container; -class handler; +class messaging_handler; template class thread_safe; /// A container of senders and receivers. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/session_options.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/session_options.hpp b/proton-c/bindings/cpp/include/proton/session_options.hpp index bf88f51..7b7565b 100644 --- a/proton-c/bindings/cpp/include/proton/session_options.hpp +++ b/proton-c/bindings/cpp/include/proton/session_options.hpp @@ -29,7 +29,7 @@ namespace proton { -class handler; +class messaging_handler; class session; /// Options for creating a session. @@ -52,8 +52,8 @@ class session_options { /// Copy options. PN_CPP_EXTERN session_options& operator=(const session_options&); - /// Set a handler for the session. - PN_CPP_EXTERN session_options& handler(class handler *); + /// Set a messaging_handler for the session. + PN_CPP_EXTERN session_options& handler(class messaging_handler *); /// @cond INTERNAL // Other useful session configuration TBD. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/include/proton/thread_safe.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/thread_safe.hpp b/proton-c/bindings/cpp/include/proton/thread_safe.hpp index 4ba06de..1da669c 100644 --- a/proton-c/bindings/cpp/include/proton/thread_safe.hpp +++ b/proton-c/bindings/cpp/include/proton/thread_safe.hpp @@ -55,7 +55,7 @@ template class returned; /// **Experimental** - A thread-safe object wrapper. /// /// Events for each proton::connection are processed sequentially in -/// an event_loop. proton::handler functions for a single connection +/// an event_loop. proton::messaging_handler functions for a single connection /// are never called concurrently. inject() lets you add user-defined /// function calls to be processed in the event loop sequence. /// http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/connection_options.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/connection_options.cpp b/proton-c/bindings/cpp/src/connection_options.cpp index cbcc5f8..3087f4b 100644 --- a/proton-c/bindings/cpp/src/connection_options.cpp +++ b/proton-c/bindings/cpp/src/connection_options.cpp @@ -19,7 +19,7 @@ * */ #include "proton/connection_options.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/reconnect_timer.hpp" #include "proton/transport.hpp" #include "proton/ssl.hpp" @@ -146,7 +146,7 @@ class connection_options::impl { connection_options::connection_options() : impl_(new impl()) {} -connection_options::connection_options(class handler& h) : impl_(new impl()) { handler(h); } +connection_options::connection_options(class messaging_handler& h) : impl_(new impl()) { handler(h); } connection_options::connection_options(const connection_options& x) : impl_(new impl()) { *this = x; @@ -164,7 +164,7 @@ connection_options& connection_options::update(const connection_options& x) { return *this; } -connection_options& connection_options::handler(class handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } +connection_options& connection_options::handler(class messaging_handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } connection_options& connection_options::max_frame_size(uint32_t n) { impl_->max_frame_size = n; return *this; } connection_options& connection_options::max_sessions(uint16_t n) { impl_->max_sessions = n; return *this; } connection_options& connection_options::idle_timeout(duration t) { impl_->idle_timeout = t; return *this; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/container_impl.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp index e448fe3..6fed9c4 100644 --- a/proton-c/bindings/cpp/src/container_impl.cpp +++ b/proton-c/bindings/cpp/src/container_impl.cpp @@ -119,7 +119,7 @@ internal::pn_ptr container_impl::cpp_handler(proton_handler *h) { return internal::take_ownership(handler); } -container_impl::container_impl(const std::string& id, handler *h) : +container_impl::container_impl(const std::string& id, messaging_handler *h) : reactor_(reactor::create()), handler_(h ? h->messaging_adapter_.get() : 0), id_(id.empty() ? uuid::random().str() : id), id_gen_(), auto_stop_(true) @@ -269,7 +269,7 @@ void container_impl::auto_stop(bool set) { } -default_container::default_container(handler& h, const std::string& id) : impl_(new container_impl(id, &h)) {} +default_container::default_container(messaging_handler& h, const std::string& id) : impl_(new container_impl(id, &h)) {} default_container::default_container(const std::string& id) : impl_(new container_impl(id)) {} returned default_container::connect(const std::string& url, const connection_options &o) { return impl_->connect(url, o); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/container_impl.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/container_impl.hpp b/proton-c/bindings/cpp/src/container_impl.hpp index dbd1c79..db60a84 100644 --- a/proton-c/bindings/cpp/src/container_impl.hpp +++ b/proton-c/bindings/cpp/src/container_impl.hpp @@ -29,7 +29,7 @@ #include "proton/connection_options.hpp" #include "proton/duration.hpp" #include "proton/export.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/sender.hpp" #include "proton/receiver.hpp" #include "proton/reactor.h" @@ -52,7 +52,7 @@ class listen_handler; class container_impl : public container { public: - container_impl(const std::string& id, handler* = 0); + container_impl(const std::string& id, messaging_handler* = 0); ~container_impl(); std::string id() const PN_CPP_OVERRIDE { return id_; } returned connect(const std::string&, const connection_options&) PN_CPP_OVERRIDE; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/container_test.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/container_test.cpp b/proton-c/bindings/cpp/src/container_test.cpp index 9725a34..b8ab40a 100644 --- a/proton-c/bindings/cpp/src/container_test.cpp +++ b/proton-c/bindings/cpp/src/container_test.cpp @@ -22,7 +22,7 @@ #include "proton/connection.hpp" #include "proton/connection_options.hpp" #include "proton/default_container.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/listener.hpp" #include @@ -42,7 +42,7 @@ static std::string int2string(int n) { return strm.str(); } -class test_handler : public proton::handler { +class test_handler : public proton::messaging_handler { public: const std::string host; proton::connection_options opts; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/engine_test.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/engine_test.cpp b/proton-c/bindings/cpp/src/engine_test.cpp index 1f5dbad..1fed4b7 100644 --- a/proton-c/bindings/cpp/src/engine_test.cpp +++ b/proton-c/bindings/cpp/src/engine_test.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -113,7 +113,7 @@ template typename S::value_type quick_pop(S& s) { } /// A handler that records incoming endpoints, errors etc. -struct record_handler : public handler { +struct record_handler : public messaging_handler { std::deque receivers; std::deque senders; std::deque sessions; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/handler.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp index 1f89225..9b34e2d 100644 --- a/proton-c/bindings/cpp/src/handler.cpp +++ b/proton-c/bindings/cpp/src/handler.cpp @@ -18,7 +18,7 @@ * under the License. * */ -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/connection.hpp" #include "proton/receiver.hpp" @@ -35,36 +35,36 @@ namespace proton { -handler::handler() : messaging_adapter_(new messaging_adapter(*this)) {} +messaging_handler::messaging_handler() : messaging_adapter_(new messaging_adapter(*this)) {} -handler::~handler(){} +messaging_handler::~messaging_handler(){} -void handler::on_container_start(container &) {} -void handler::on_message(delivery &, message &) {} -void handler::on_sendable(sender &) {} -void handler::on_transport_close(transport &) {} -void handler::on_transport_error(transport &t) { on_error(t.error()); } -void handler::on_transport_open(transport &) {} -void handler::on_connection_close(connection &) {} -void handler::on_connection_error(connection &c) { on_error(c.error()); } -void handler::on_connection_open(connection &) {} -void handler::on_session_close(session &) {} -void handler::on_session_error(session &s) { on_error(s.error()); } -void handler::on_session_open(session &) {} -void handler::on_receiver_close(receiver &) {} -void handler::on_receiver_error(receiver &l) { on_error(l.error()); } -void handler::on_receiver_open(receiver &) {} -void handler::on_sender_close(sender &) {} -void handler::on_sender_error(sender &l) { on_error(l.error()); } -void handler::on_sender_open(sender &) {} -void handler::on_tracker_accept(tracker &) {} -void handler::on_tracker_reject(tracker &) {} -void handler::on_tracker_release(tracker &) {} -void handler::on_tracker_settle(tracker &) {} -void handler::on_delivery_settle(delivery &) {} -void handler::on_sender_drain_start(sender &) {} -void handler::on_receiver_drain_finish(receiver &) {} +void messaging_handler::on_container_start(container &) {} +void messaging_handler::on_message(delivery &, message &) {} +void messaging_handler::on_sendable(sender &) {} +void messaging_handler::on_transport_close(transport &) {} +void messaging_handler::on_transport_error(transport &t) { on_error(t.error()); } +void messaging_handler::on_transport_open(transport &) {} +void messaging_handler::on_connection_close(connection &) {} +void messaging_handler::on_connection_error(connection &c) { on_error(c.error()); } +void messaging_handler::on_connection_open(connection &) {} +void messaging_handler::on_session_close(session &) {} +void messaging_handler::on_session_error(session &s) { on_error(s.error()); } +void messaging_handler::on_session_open(session &) {} +void messaging_handler::on_receiver_close(receiver &) {} +void messaging_handler::on_receiver_error(receiver &l) { on_error(l.error()); } +void messaging_handler::on_receiver_open(receiver &) {} +void messaging_handler::on_sender_close(sender &) {} +void messaging_handler::on_sender_error(sender &l) { on_error(l.error()); } +void messaging_handler::on_sender_open(sender &) {} +void messaging_handler::on_tracker_accept(tracker &) {} +void messaging_handler::on_tracker_reject(tracker &) {} +void messaging_handler::on_tracker_release(tracker &) {} +void messaging_handler::on_tracker_settle(tracker &) {} +void messaging_handler::on_delivery_settle(delivery &) {} +void messaging_handler::on_sender_drain_start(sender &) {} +void messaging_handler::on_receiver_drain_finish(receiver &) {} -void handler::on_error(const error_condition& c) { throw proton::error(c.what()); } +void messaging_handler::on_error(const error_condition& c) { throw proton::error(c.what()); } } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/messaging_adapter.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp index 7f62082..4963b3c 100644 --- a/proton-c/bindings/cpp/src/messaging_adapter.cpp +++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp @@ -55,7 +55,7 @@ void credit_topup(pn_link_t *link) { } } -messaging_adapter::messaging_adapter(handler &delegate) : delegate_(delegate) {} +messaging_adapter::messaging_adapter(messaging_handler &delegate) : delegate_(delegate) {} messaging_adapter::~messaging_adapter(){} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/messaging_adapter.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp index 1a33630..7905f6e 100644 --- a/proton-c/bindings/cpp/src/messaging_adapter.hpp +++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp @@ -22,7 +22,7 @@ * */ -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton_handler.hpp" @@ -33,11 +33,11 @@ namespace proton { -/// Convert the low level proton-c events to the higher level proton::handler calls +/// Convert the low level proton-c events to the higher level proton::messaging_handler calls class messaging_adapter : public proton_handler { public: - messaging_adapter(handler &delegate); + messaging_adapter(messaging_handler &delegate); virtual ~messaging_adapter(); void on_reactor_init(proton_event &e); @@ -53,7 +53,7 @@ class messaging_adapter : public proton_handler void on_transport_tail_closed(proton_event &e); private: - handler &delegate_; // The handler for generated messaging_event's + messaging_handler &delegate_; // The handler for generated messaging_event's }; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/proton_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/proton_handler.hpp b/proton-c/bindings/cpp/src/proton_handler.hpp index 3b601e2..32d370d 100644 --- a/proton-c/bindings/cpp/src/proton_handler.hpp +++ b/proton-c/bindings/cpp/src/proton_handler.hpp @@ -23,7 +23,7 @@ */ #include "proton/export.hpp" -#include "proton/object.hpp" +#include "proton/internal/object.hpp" #include http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/reactor.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/reactor.hpp b/proton-c/bindings/cpp/src/reactor.hpp index ec5f120..c7ab915 100644 --- a/proton-c/bindings/cpp/src/reactor.hpp +++ b/proton-c/bindings/cpp/src/reactor.hpp @@ -37,7 +37,7 @@ class connection; class container; class acceptor; class url; -class handler; +class messaging_handler; class task; class reactor : public internal::object { http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/receiver_options.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/receiver_options.cpp b/proton-c/bindings/cpp/src/receiver_options.cpp index 26a78a0..4e34422 100644 --- a/proton-c/bindings/cpp/src/receiver_options.cpp +++ b/proton-c/bindings/cpp/src/receiver_options.cpp @@ -20,7 +20,7 @@ */ #include "proton/receiver_options.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/source_options.hpp" #include "proton/target_options.hpp" @@ -125,7 +125,7 @@ receiver_options& receiver_options::operator=(const receiver_options& x) { void receiver_options::update(const receiver_options& x) { impl_->update(*x.impl_); } -receiver_options& receiver_options::handler(class handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } +receiver_options& receiver_options::handler(class messaging_handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } receiver_options& receiver_options::delivery_mode(proton::delivery_mode m) {impl_->delivery_mode = m; return *this; } receiver_options& receiver_options::auto_accept(bool b) {impl_->auto_accept = b; return *this; } receiver_options& receiver_options::auto_settle(bool b) {impl_->auto_settle = b; return *this; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/sender_options.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/sender_options.cpp b/proton-c/bindings/cpp/src/sender_options.cpp index 2922157..ce98d64 100644 --- a/proton-c/bindings/cpp/src/sender_options.cpp +++ b/proton-c/bindings/cpp/src/sender_options.cpp @@ -20,7 +20,7 @@ */ #include "proton/sender_options.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/source_options.hpp" #include "proton/target_options.hpp" @@ -113,7 +113,7 @@ sender_options& sender_options::operator=(const sender_options& x) { void sender_options::update(const sender_options& x) { impl_->update(*x.impl_); } -sender_options& sender_options::handler(class handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } +sender_options& sender_options::handler(class messaging_handler &h) { impl_->handler = h.messaging_adapter_.get(); return *this; } sender_options& sender_options::delivery_mode(proton::delivery_mode m) {impl_->delivery_mode = m; return *this; } sender_options& sender_options::auto_settle(bool b) {impl_->auto_settle = b; return *this; } sender_options& sender_options::source(source_options &s) {impl_->source = s; return *this; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/proton-c/bindings/cpp/src/session_options.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/session_options.cpp b/proton-c/bindings/cpp/src/session_options.cpp index 71b5b8d..ca66891 100644 --- a/proton-c/bindings/cpp/src/session_options.cpp +++ b/proton-c/bindings/cpp/src/session_options.cpp @@ -70,7 +70,7 @@ session_options& session_options::operator=(const session_options& x) { return *this; } -session_options& session_options::handler(class handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; } +session_options& session_options::handler(class messaging_handler *h) { impl_->handler = h->messaging_adapter_.get(); return *this; } void session_options::apply(session& s) const { impl_->apply(s); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b43731d/tests/tools/apps/cpp/reactor_send.cpp ---------------------------------------------------------------------- diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp index 05e6417..481a305 100644 --- a/tests/tools/apps/cpp/reactor_send.cpp +++ b/tests/tools/apps/cpp/reactor_send.cpp @@ -26,7 +26,7 @@ #include "proton/default_container.hpp" #include "proton/codec/decoder.hpp" #include "proton/delivery.hpp" -#include "proton/handler.hpp" +#include "proton/messaging_handler.hpp" #include "proton/tracker.hpp" #include "proton/value.hpp" @@ -36,7 +36,7 @@ #include #include -class reactor_send : public proton::handler { +class reactor_send : public proton::messaging_handler { private: std::string url_; proton::message message_; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org