You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2017/01/10 15:58:38 UTC
[17/55] [partial] qpid-proton-j git commit: PROTON-1385: retain
proton-j content only, the rest remains in the other repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton.git
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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
deleted file mode 100644
index 9ba5dc8..0000000
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ /dev/null
@@ -1,411 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton
-
- # A transport is used by a connection to interface with the network.
- #
- # A transport is associated with, at most, one Connection.
- #
- # == Client And Server Mode
- #
- # Initially, a transport is configured to be a client tranpsort. It can be
- # configured to act as a server when it is created.
- #
- # A client transport initiates outgoing connections.
- #
- # A client transport must be configured with the protocol layers to use and
- # cannot configure itself automatically.
- #
- # A server transport accepts incoming connections. It can automatically
- # configure itself to include the various protocol layers depending on the
- # incoming protocol headers.
- #
- # == Tracing Data
- #
- # Data can be traced into and out of the transport programmatically by setting
- # the #trace level to one of the defined trace values (TRACE_RAW, TRACE_FRM or
- # TRACE_DRV). Tracing can also be turned off programmatically by setting the
- # #trace level to TRACE_OFF.
- #
- # @example
- #
- # # turns on frame tracing
- # @transport.trace = Qpid::Proton::Transport::TRACE_FRM
- #
- # # ... do something where the frames are of interest, such as debugging
- #
- # # turn tracing off again
- # @transport.trace = Qpid::Proton::Transport::TRACE_NONE
- #
- # Tracing can also be enabled from the command line by defining the similarly
- # named environment variable before starting a Proton application:
- #
- # @example
- #
- # # enable tracing from the command line
- # PN_TRACE_FRM=1 ruby my_proton_app.rb
- #
- class Transport
-
- # @private
- include Util::Engine
-
- # Turn logging off entirely.
- TRACE_OFF = Cproton::PN_TRACE_OFF
- # Log raw binary data into/out of the transport.
- TRACE_RAW = Cproton::PN_TRACE_RAW
- # Log frames into/out of the transport.
- TRACE_FRM = Cproton::PN_TRACE_FRM
- # Log driver related events; i.e., initialization, end of stream, etc.
- TRACE_DRV = Cproton::PN_TRACE_DRV
-
- # @private
- CLIENT = 1
- # @private
- SERVER = 2
-
- # @private
- include Util::SwigHelper
-
- # @private
- PROTON_METHOD_PREFIX = "pn_transport"
-
- # @!attribute channel_max
- #
- # @return [Fixnum] The maximum allowed channel.
- #
- proton_accessor :channel_max
-
- # @!attribute [r] remote_channel_max
- #
- # @return [Fixnum] The maximum allowed channel of a transport's remote peer.
- #
- proton_caller :remote_channel_max
-
- # @!attribute max_frame_size
- #
- # @return [Fixnum] The maximum frame size.
- #
- proton_accessor :max_frame_size
-
- # @!attribute [r] remote_max_frame_size
- #
- # @return [Fixnum] The maximum frame size of the transport's remote peer.
- #
- proton_reader :remote_max_frame_size
-
- # @!attribute idle_timeout
- #
- # @return [Fixnum] The idle timeout.
- #
- proton_accessor :idle_timeout
-
- # @!attribute [r] remote_idle_timeout
- #
- # @return [Fixnum] The idle timeout for the transport's remote peer.
- #
- proton_accessor :remote_idle_timeout
-
- # @!attribute [r] capacity
- #
- # If the engine is in an exception state such as encountering an error
- # condition or reaching the end of stream state, a negative value will
- # be returned indicating the condition.
- #
- # If an error is indicated, further deteails can be obtained from
- # #error.
- #
- # Calls to #process may alter the value of this value. See #process for
- # more details
- #
- # @return [Fixnum] The amount of free space for input following the
- # transport's tail pointer.
- #
- proton_caller :capacity
-
- # @!attribute [r] head
- #
- # This referneces queued output data. It reports the bytes of output data.
- #
- # Calls to #pop may alter this attribute, and any data it references.
- #
- # @return [String] The transport's head pointer.
- #
- proton_caller :head
-
- # @!attribute [r] tail
- #
- # The amount of free space following this data is reported by #capacity.
- #
- # Calls to #process may alter the value of this attribute.
- #
- # @return [String] The transport's tail pointer.
- #
- proton_caller :tail
-
- # @!attribute [r] pending
- #
- # If the ending is in an exceptional state, such as encountering an error
- # condition or reachign the end of the stream state, a negative value will
- # be returned indicating the condition.
- #
- # If an error is indicated, further details can be obtained from #error.
- #
- # Calls to #pop may alter the value of this pointer as well.
- #
- # @return [Fixnum] The number of pending output bytes following the header
- # pointer.
- #
- # @raise [TransportError] If any error other than an end of stream occurs.
- #
- proton_caller :pending
-
- # @!attribute [r] closed?
- #
- # A transport is defined to be closed when both the tail and the head are
- # closed. In other words, when both #capacity < 0 and #pending < 0.
- #
- # @return [Boolean] Returns true if the tranpsort is closed.
- #
- proton_caller :closed?
-
- # @!attribute [r] frames_output
- #
- # @return [Fixnum] The number of frames output by a transport.
- #
- proton_reader :frames_output
-
- # @!attribute [r] frames_input
- #
- # @return [Fixnum] The number of frames input by a transport.
- #
- proton_reader :frames_input
-
- # @private
- include Util::ErrorHandler
-
- can_raise_error :process, :error_class => TransportError
- can_raise_error :close_tail, :error_class => TransportError
- can_raise_error :pending, :error_class => TransportError, :below => Error::EOS
- can_raise_error :close_head, :error_class => TransportError
-
- # @private
- include Util::Wrapper
-
- # @private
- def self.wrap(impl)
- return nil if impl.nil?
-
- self.fetch_instance(impl, :pn_transport_attachments) || Transport.new(nil, impl)
- end
-
- # Creates a new transport instance.
- #
- # @param mode [Fixnum] The transport mode, either CLIENT or SERVER
- # @param impl [pn_transport_t] Should not be used.
- #
- # @raise [TransportError] If the mode is invalid.
- #
- def initialize(mode = nil, impl = Cproton.pn_transport)
- @impl = impl
- if mode == SERVER
- Cproton.pn_transport_set_server(@impl)
- elsif (!mode.nil? && mode != CLIENT)
- raise TransportError.new("cannot create transport for mode: #{mode}")
- end
- self.class.store_instance(self, :pn_transport_attachments)
- end
-
- # Returns whether the transport has any buffered data.
- #
- # @return [Boolean] True if the transport has no buffered data.
- #
- def quiesced?
- Cproton.pn_transport_quiesced(@impl)
- end
-
- # Returns additional information about the condition of the transport.
- #
- # When a TRANSPORT_ERROR event occurs, this operaiton can be used to
- # access the details of the error condition.
- #
- # The object returned is valid until the Transport is discarded.
- #
- def condition
- condition_to_object Cproton.pn_transport_condition(@impl)
- end
-
- # Binds to the given connection.
- #
- # @param connection [Connection] The connection.
- #
- def bind(connection)
- Cproton.pn_transport_bind(@impl, connection.impl)
- end
-
- # Unbinds from the previous connection.
- #
- def unbind
- Cproton.pn_transport_unbind(@impl)
- end
-
- # Updates the transports trace flags.
- #
- # @param level [Fixnum] The trace level.
- #
- # @see TRACE_OFF
- # @see TRACE_RAW
- # @see TRACE_FRM
- # @see TRACE_DRV
- #
- def trace(level)
- Cproton.pn_transport_trace(@impl, level)
- end
-
- # Return the AMQP connection associated with the transport.
- #
- # @return [Connection, nil] The bound connection, or nil.
- #
- def connection
- Connection.wrap(Cproton.pn_transport_connection(@impl))
- end
-
- # Log a message to the transport's logging mechanism.
- #
- # This can be using in a debugging scenario as the message will be
- # prepended with the transport's identifier.
- #
- # @param message [String] The message to be logged.
- #
- def log(message)
- Cproton.pn_transport_log(@impl, message)
- end
-
- # Pushes the supplied bytes into the tail of the transport.
- #
- # @param data [String] The bytes to be pushed.
- #
- # @return [Fixnum] The number of bytes pushed.
- #
- def push(data)
- Cproton.pn_transport_push(@impl, data, data.length)
- end
-
- # Process input data following the tail pointer.
- #
- # Calling this function will cause the transport to consume the specified
- # number of bytes of input occupying the free space following the tail
- # pointer. It may also change the value for #tail, as well as the amount of
- # free space reported by #capacity.
- #
- # @param size [Fixnum] The number of bytes to process.
- #
- # @raise [TransportError] If an error occurs.
- #
- def process(size)
- Cproton.pn_transport_process(@impl, size)
- end
-
- # Indicate that the input has reached EOS (end of stream).
- #
- # This tells the transport that no more input will be forthcoming.
- #
- # @raise [TransportError] If an error occurs.
- #
- def close_tail
- Cproton.pn_transport_close_tail(@impl)
- end
-
- # Returns the specified number of bytes from the transport's buffers.
- #
- # @param size [Fixnum] The number of bytes to return.
- #
- # @return [String] The data peeked.
- #
- # @raise [TransportError] If an error occurs.
- #
- def peek(size)
- cd, out = Cproton.pn_transport_peek(@impl, size)
- return nil if cd == Qpid::Proton::Error::EOS
- raise TransportError.new if cd < -1
- out
- end
-
- # Removes the specified number of bytes from the pending output queue
- # following the transport's head pointer.
- #
- # @param size [Fixnum] The number of bytes to remove.
- #
- def pop(size)
- Cproton.pn_transport_pop(@impl, size)
- end
-
- # Indicate that the output has closed.
- #
- # Tells the transport that no more output will be popped.
- #
- # @raise [TransportError] If an error occurs.
- #
- def close_head
- Cproton.pn_transport_close_head(@impl)
- end
-
- # Process any pending transport timer events.
- #
- # This method should be called after all pending input has been
- # processed by the transport (see #input), and before generating
- # output (see #output).
- #
- # It returns the deadline for the next pending timer event, if any
- # art present.
- #
- # @param now [Time] The timestamp.
- #
- # @return [Fixnum] If non-zero, the expiration time of the next pending
- # timer event for the transport. The caller must invoke #tick again at
- # least once at or before this deadline occurs.
- #
- def tick(now)
- Cproton.pn_transport_tick(@impl, now)
- end
-
- def sasl
- SASL.new(self)
- end
-
- # Creates, or returns an existing, SSL object for the transport.
- #
- # @param domain [SSLDomain] The SSL domain.
- # @param session_details [SSLDetails] The SSL session details.
- #
- # @return [SSL] The SSL object.
- #
- def ssl(domain = nil, session_details = nil)
- @ssl ||= SSL.create(self, domain, session_details) if @ssl.nil?
- end
-
- # @private
- def ssl?
- !@ssl.nil?
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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
deleted file mode 100644
index 1fa1222..0000000
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton
-
- class URL
-
- attr_reader :scheme
- attr_reader :username
- attr_reader :password
- attr_reader :host
- attr_reader :port
- attr_reader :path
-
- def initialize(url = nil, options = {})
- options[:defaults] = true
-
- if url
- @url = Cproton.pn_url_parse(url)
- if @url.nil?
- raise ::ArgumentError.new("invalid url: #{url}")
- end
- else
- @url = Cproton.pn_url
- end
- @scheme = Cproton.pn_url_get_scheme(@url)
- @username = Cproton.pn_url_get_username(@url)
- @password = Cproton.pn_url_get_password(@url)
- @host = Cproton.pn_url_get_host(@url)
- @port = Cproton.pn_url_get_port(@url)
- @path = Cproton.pn_url_get_path(@url)
- defaults
- end
-
- def port=(port)
- if port.nil?
- Cproton.pn_url_set_port(@url, nil)
- else
- Cproton.pn_url_set_port(@url, port)
- end
- end
-
- def port
- Cproton.pn_url_get_port(@url).to_i
- end
-
- def to_s
- "#{@scheme}://#{@username.nil? ? '' : @username}#{@password.nil? ? '' : '@' + @password + ':'}#{@host}:#{@port}/#{@path}"
- end
-
- private
-
- def defaults
- @scheme = @scheme || "ampq"
- @host = @host || "0.0.0.0"
- @port = @port || 5672
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/event/collector.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/event/collector.rb b/proton-c/bindings/ruby/lib/event/collector.rb
deleted file mode 100644
index c86b0f2..0000000
--- a/proton-c/bindings/ruby/lib/event/collector.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Event
-
- # A Collector is used to register interest in events produced by one
- # or more Connection objects.
- #
- # == Events
- #
- # @see Qpid::Proton::Event The list of predefined events.
- #
- # @example
- #
- # conn = Qpid::Proton::Connection.new
- # coll = Qpid::Proton::Event::Collector.new
- # conn.collect(coll)
- #
- # # transport setup not included here for brevity
- #
- # loop do
- #
- # # wait for an event and then perform the following
- #
- # event = collector.peek
- #
- # unless event.nil?
- # case event.type
- #
- # when Qpid::Proton::Event::CONNECTION_REMOTE_CLOSE
- # conn = event.context # the context here is the connection
- # # the remote connection closed, so only close our side if it's
- # # still open
- # if !(conn.state & Qpid::Proton::Endpoint::LOCAL_CLOSED)
- # conn.close
- # end
- #
- # when Qpid::proton::Event::SESSION_REMOTE_OPEN
- # session = event.session # the context here is the session
- # # the remote session is now open, so if the local session is
- # # uninitialized, then open it
- # if session.state & Qpid::Proton::Endpoint::LOCAL_UNINIT
- # session.incoming_capacity = 1000000
- # session.open
- # end
- #
- # end
- #
- # # remove the processed event and get the next event
- # # the loop will exit when we have no more events to process
- # collector.pop
- # event = collector.peek
- #
- # end
- #
- class Collector
-
- # @private
- attr_reader :impl
-
- # Creates a new Collector.
- #
- def initialize
- @impl = Cproton.pn_collector
- ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
- end
-
- # @private
- def self.finalize!(impl)
- proc {
- Cproton.pn_collector_free(impl)
- }
- end
-
- # Releases the collector.
- #
- # Once in a released state, a collector will drain any internally queued
- # events, shrink its memory footprint to a minimu, and discard any newly
- # created events.
- #
- def release
- Cproton.pn_collector_release(@impl)
- end
-
- # Place a new event on the collector.
- #
- # This operation will create a new event of the given type and context
- # and return a new Event instance. In some cases an event of a given
- # type can be elided. When this happens, this operation will return
- # nil.
- #
- # @param context [Object] The event context.
- # @param event_type [EventType] The event type.
- #
- # @return [Event] the event if it was queued
- # @return [nil] if it was elided
- #
- def put(context, event_type)
- Cproton.pn_collector_put(@impl, Cproton.pn_rb2void(context), event_type.type_code)
- end
-
- # Access the head event.
- #
- # This operation will continue to return the same event until it is
- # cleared by using #pop. The pointer return by this operation will be
- # valid until ::pn_collector_pop is invoked or #free is called, whichever
- # happens sooner.
- #
- # @return [Event] the head event
- # @return [nil] if there are no events
- #
- # @see #pop
- # @see #put
- #
- def peek
- Event.wrap(Cproton.pn_collector_peek(@impl))
- end
-
- # Clear the head event.
- #
- # @return [Boolean] true if an event was removed
- #
- # @see #release
- # @see #peek
- #
- def pop
- Cproton.pn_collector_pop(@impl)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/event/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb
deleted file mode 100644
index e839f63..0000000
--- a/proton-c/bindings/ruby/lib/event/event.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton
-
- module Event
-
- # @private
- def self.event_type(const_name, method_name = nil) # :nodoc:
- unless Cproton.const_defined?(const_name)
- raise RuntimeError.new("no such constant: #{const_name}")
- end
-
- const_value = Cproton.const_get(const_name)
- method_name = "on_#{const_name.to_s[3..-1]}".downcase if method_name.nil?
-
- EventType.new(const_value, method_name)
- end
-
- # Defined as a programming convenience. No even of this type will ever
- # be generated.
- NONE = event_type(:PN_EVENT_NONE)
-
- # A reactor has been started.
- REACTOR_INIT = event_type(:PN_REACTOR_INIT)
- # A reactor has no more events to process.
- REACTOR_QUIESCED = event_type(:PN_REACTOR_QUIESCED)
- # A reactor has been stopred.
- REACTOR_FINAL = event_type(:PN_REACTOR_FINAL)
-
- # A timer event has occurred.
- TIMER_TASK = event_type(:PN_TIMER_TASK)
-
- # A connection has been created. This is the first even that will ever
- # be issued for a connection.
- CONNECTION_INIT = event_type(:PN_CONNECTION_INIT)
- # A conneciton has been bound toa transport.
- CONNECTION_BOUND = event_type(:PN_CONNECTION_BOUND)
- # A connection has been unbound from its transport.
- CONNECTION_UNBOUND = event_type(:PN_CONNECTION_UNBOUND)
- # A local connection endpoint has been opened.
- CONNECTION_LOCAL_OPEN = event_type(:PN_CONNECTION_LOCAL_OPEN)
- # A local connection endpoint has been closed.
- CONNECTION_LOCAL_CLOSE = event_type(:PN_CONNECTION_LOCAL_CLOSE)
- # A remote endpoint has opened its connection.
- CONNECTION_REMOTE_OPEN = event_type(:PN_CONNECTION_REMOTE_OPEN)
- # A remote endpoint has closed its connection.
- CONNECTION_REMOTE_CLOSE = event_type(:PN_CONNECTION_REMOTE_CLOSE)
- # A connection has been freed and any outstanding processing has been
- # completed. This is the final event htat will ever be issued for a
- # connection
- CONNECTION_FINAL = event_type(:PN_CONNECTION_FINAL)
-
- # A session has been created. This is the first event that will ever be
- # issues for a session.
- SESSION_INIT = event_type(:PN_SESSION_INIT)
- # A local session endpoint has been opened.
- SESSION_LOCAL_OPEN = event_type(:PN_SESSION_LOCAL_OPEN)
- # A local session endpoint has been closed.
- SESSION_LOCAL_CLOSE = event_type(:PN_SESSION_LOCAL_CLOSE)
- # A remote endpoint has opened its session.
- SESSION_REMOTE_OPEN = event_type(:PN_SESSION_REMOTE_OPEN)
- # A remote endpoint has closed its session.
- SESSION_REMOTE_CLOSE = event_type(:PN_SESSION_REMOTE_CLOSE)
- # A session has been freed and any outstanding processing has been
- # completed. This is the final event that will ever be issued for a
- # session
- SESSION_FINAL = event_type(:PN_SESSION_FINAL)
-
- # A link has been created. This is the first event that will ever be
- # issued for a link.
- LINK_INIT = event_type(:PN_LINK_INIT)
- # A local link endpoint has been opened.
- LINK_LOCAL_OPEN = event_type(:PN_LINK_LOCAL_OPEN)
- # A local link endpoint has been closed.
- LINK_LOCAL_CLOSE = event_type(:PN_LINK_LOCAL_CLOSE)
- # A local link endpoint has been detached.
- LINK_LOCAL_DETACH = event_type(:PN_LINK_LOCAL_DETACH)
- # A remote endpoint has opened its link.
- LINK_REMOTE_OPEN = event_type(:PN_LINK_REMOTE_OPEN)
- # A remote endpoint has closed its link.
- LINK_REMOTE_CLOSE = event_type(:PN_LINK_REMOTE_CLOSE)
- # A remote endpoint has detached its link.
- LINK_REMOTE_DETACH = event_type(:PN_LINK_REMOTE_DETACH)
- # The flow control state for a link has changed.
- LINK_FLOW = event_type(:PN_LINK_FLOW)
- # A link has been freed and any outstanding processing has been completed.
- # This is the final event htat will ever be issued for a link.
- LINK_FINAL = event_type(:PN_LINK_FINAL)
-
- # A delivery has been created or updated.
- DELIVERY = event_type(:PN_DELIVERY)
-
- # A transport has new data to read and/or write.
- TRANSPORT = event_type(:PN_TRANSPORT)
- # Indicates that a transport error has occurred.
- # @see Transport#condition To access the details of the error.
- TRANSPORT_ERROR = event_type(:PN_TRANSPORT_ERROR)
- # Indicates that the head of a transport has been closed. This means the
- # transport will never produce more bytes for output to the network.
- TRANSPORT_HEAD_CLOSED = event_type(:PN_TRANSPORT_HEAD_CLOSED)
- # Indicates that the trail of a transport has been closed. This means the
- # transport will never be able to process more bytes from the network.
- TRANSPORT_TAIL_CLOSED = event_type(:PN_TRANSPORT_TAIL_CLOSED)
- # Indicates that both the head and tail of a transport are closed.
- TRANSPORT_CLOSED = event_type(:PN_TRANSPORT_CLOSED)
-
- SELECTABLE_INIT = event_type(:PN_SELECTABLE_INIT)
- SELECTABLE_UPDATED = event_type(:PN_SELECTABLE_UPDATED)
- SELECTABLE_READABLE = event_type(:PN_SELECTABLE_READABLE)
- SELECTABLE_WRITABLE = event_type(:PN_SELECTABLE_WRITABLE)
- SELECTABLE_EXPIRED = event_type(:PN_SELECTABLE_EXPIRED)
- SELECTABLE_ERROR = event_type(:PN_SELECTABLE_ERROR)
- SELECTABLE_FINAL = event_type(:PN_SELECTABLE_FINAL)
-
- # An Event provides notification of a state change within the protocol
- # engine.
- #
- # Every event has a type that identifies what sort of state change has
- # occurred, along with a pointer to the object whose state has changed,
- # and also any associated objects.
- #
- # For more details on working with Event, please refer to Collector.
- #
- # @see Qpid::Proton::Event The list of predefined events.
- #
- class Event < EventBase
-
- # @private
- include Qpid::Proton::Util::ClassWrapper
- # @private
- include Qpid::Proton::Util::Wrapper
-
- # Creates a Ruby object for the given pn_event_t.
- #
- # @private
- def self.wrap(impl, number = nil)
- return nil if impl.nil?
-
- result = self.fetch_instance(impl, :pn_event_attachments)
- return result unless result.nil?
- number = Cproton.pn_event_type(impl) if number.nil?
- event = Event.new(impl, number)
- return event.context if event.context.is_a? EventBase
- return event
- end
-
- # @private
- def initialize(impl, number)
- @impl = impl
- class_name = Cproton.pn_class_name(Cproton.pn_event_class(impl))
- context = class_wrapper(class_name, Cproton.pn_event_context(impl))
- event_type = EventType.by_type(Cproton.pn_event_type(impl))
- super(class_name, context, event_type)
- @type = EventType.by_type(number)
- self.class.store_instance(self, :pn_event_attachments)
- end
-
- # Notifies the handler(s) of this event.
- #
- # If a handler responds to the event's method then that method is invoked
- # and passed the event. Otherwise, if the handler defines the
- # +on_unhandled+ method, then that will be invoked instead.
- #
- # If the handler defines a +handlers+ method then that will be invoked and
- # passed the event afterward.
- #
- # @example
- #
- # class FallbackEventHandler
- #
- # # since it now defines a handlers method, any event will iterate
- # # through them and invoke the +dispatch+ method on each
- # attr_accessor handlers
- #
- # def initialize
- # @handlers = []
- # end
- #
- # # invoked for any event not otherwise handled
- # def on_unhandled(event)
- # puts "Unable to invoke #{event.type.method} on #{event.context}."
- # end
- #
- # end
- #
- # @param handler [Object] An object which implements either the event's
- # handler method or else responds to :handlers with an array of other
- # handlers.
- #
- def dispatch(handler, type = nil)
- type = @type if type.nil?
- if handler.is_a?(Qpid::Proton::Handler::WrappedHandler)
- Cproton.pn_handler_dispatch(handler.impl, @impl, type.number)
- else
- result = Qpid::Proton::Event.dispatch(handler, type.method, self)
- if (result != "DELEGATED") && handler.respond_to?(:handlers)
- handler.handlers.each do |hndlr|
- self.dispatch(hndlr)
- end
- end
- end
- end
-
- # Returns the reactor for this event.
- #
- # @return [Reactor, nil] The reactor.
- #
- def reactor
- impl = Cproton.pn_event_reactor(@impl)
- Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl)
- end
-
- def container
- impl = Cproton.pn_event_reactor(@impl)
- Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl)
- end
-
- # Returns the transport for this event.
- #
- # @return [Transport, nil] The transport.
- #
- def transport
- Qpid::Proton::Transport.wrap(Cproton.pn_event_transport(@impl))
- end
-
- # Returns the Connection for this event.
- #
- # @return [Connection, nil] The connection.
- #
- def connection
- Qpid::Proton::Connection.wrap(Cproton.pn_event_connection(@impl))
- end
-
- # Returns the Session for this event.
- #
- # @return [Session, nil] The session
- #
- def session
- Qpid::Proton::Session.wrap(Cproton.pn_event_session(@impl))
- end
-
- # Returns the Link for this event.
- #
- # @return [Link, nil] The link.
- #
- def link
- Qpid::Proton::Link.wrap(Cproton.pn_event_link(@impl))
- end
-
- # Returns the Sender, or nil if there is no Link, associated with this
- # event if that link is a sender.
- #
- # @return [Sender, nil] The sender.
- #
- def sender
- return self.link if !self.link.nil? && self.link.sender?
- end
-
- # Returns the Receiver, or nil if there is no Link, associated with this
- # event if that link is a receiver.
- #
- # @return [Receiver, nil] The receiver.
- #
- def receiver
- return self.link if !self.link.nil? && self.link.receiver?
- end
-
- # Returns the Delivery associated with this event.
- #
- # @return [Delivery, nil] The delivery.
- #
- def delivery
- Qpid::Proton::Delivery.wrap(Cproton.pn_event_delivery(@impl))
- end
-
- # Sets the message.
- #
- # @param message [Qpid::Proton::Message] The message
- #
- def message=(message)
- @message = message
- end
-
- # Returns the message.
- #
- # @return [Qpid::Proton::Message] The message.
- #
- def message
- @message
- end
-
- # @private
- def to_s
- "#{self.type}(#{self.context})"
- end
-
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/event/event_base.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/event/event_base.rb b/proton-c/bindings/ruby/lib/event/event_base.rb
deleted file mode 100644
index 6ae6959..0000000
--- a/proton-c/bindings/ruby/lib/event/event_base.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Event
-
- # @private
- def self.dispatch(handler, method, *args)
- args = args.last unless args.nil?
- if handler.respond_to? method.to_sym
- return handler.__send__(method, args)
- elsif handler.respond_to? :on_unhandled
- return handler.__send__(:on_unhandled, method, args)
- end
- end
-
- # EventBase is the foundation for creating application-specific events.
- #
- # @example
- #
- # # SCENARIO: A continuation of the example in EventType.
- # #
- # # An Event class is defined to handle receiving encrypted
- # # data from a remote endpoint.
- #
- # class EncryptedDataEvent < EventBase
- # def initialize(message)
- # super(EncryptedDataEvent, message,
- # Qpid::Proton::Event::ENCRYPTED_RECV)
- # end
- # end
- #
- # # at another point, when encrypted data is received
- # msg = Qpid::Proton::Message.new
- # msg.decode(link.receive(link.pending))
- # if encrypted?(msg)
- # collector.put(EncryptedDataEvent.new(msg)
- # end
- #
- # @see EventType The EventType class for how ENCRYPTED_RECV was defined.
- #
- class EventBase
-
- # Returns the name for the class associated with this event.
- attr_reader :class_name
-
- # Returns the associated context object for the event.
- attr_reader :context
-
- # Returns the type of the event.
- attr_reader :type
-
- # Creates a new event with the specific class_name and context of the
- # specified type.
- #
- # @param class_name [String] The name of the class.
- # @param context [Object] The event context.
- # @param type [EventType] The event type.
- #
- def initialize(class_name, context, type)
- @class_name = class_name
- @context = context
- @type = type
- end
-
- # Invokes the type-specific method on the provided handler.
- #
- # @param handler [Object] The handler to be notified of this event.
- #
- def dispatch(handler)
- Qpid::Proton.dispatch(handler, @type.method, self)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/event/event_type.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/event/event_type.rb b/proton-c/bindings/ruby/lib/event/event_type.rb
deleted file mode 100644
index aa5944d..0000000
--- a/proton-c/bindings/ruby/lib/event/event_type.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Event
-
- # Manages the association between an Event and the method which should
- # process on the context object associated with an occurance of the event.
- #
- # Each type is identified by a unique #type value.
- #
- # @example
- #
- # # SCENARIO: A part of an application handles extracting and decrypting
- # # data received from a remote endpoint.
- # #
- # # An EventType is created to notify handlers that such a
- # # situation has occurred.
- #
- # ENCRYPTED_RECV = 10000 # the unique constant value for the event
- #
- # # create a new event type which, when it occurs, invokes a method
- # # named :on_encrypted_data when a handler is notified of its occurrance
- # Qpid::Proton::Event::ENCRYPTED_RECV =
- # Qpid::Proton::Event::EventType.new(ENCRYPTED_RECV, :on_encrypted_data)
- #
- # @see EventBase EventBase for the rest of this example.
- # @see Qpid::Proton::Event::Event The Event class for more details on events.
- #
- class EventType
-
- # The method to invoke on any potential handler.
- attr_reader :method
- attr_reader :number
-
- def initialize(number, method)
- @number = number
- @name = Cproton.pn_event_type_name(@number)
- @method = method
- @@types ||= {}
- @@types[number] = self
- end
-
- # @private
- def to_s
- @name
- end
-
- # @private
- def self.by_type(type) # :nodoc:
- @@types[type]
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/acking.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/acking.rb b/proton-c/bindings/ruby/lib/handler/acking.rb
deleted file mode 100644
index 2c94cfe..0000000
--- a/proton-c/bindings/ruby/lib/handler/acking.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # Mixing that provides methods for acknowledging a delivery.
- #
- module Acking
-
- # Accept the receivered message.
- #
- # @param delivery [Qpid::Proton::Delivery] The delivery.
- #
- def accept(delivery)
- self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED)
- end
-
- # Rejects a received message that is considered invalid or unprocessable.
- #
- # @param delivery [Qpid::Proton::Delivery] The delivery.
- #
- def reject(delivery)
- self.settle(delivery, Qpid::Proton::Delivery::REJECTED)
- end
-
- # Releases a received message, making it available at the source for any
- # other interested receiver.
- #
- # @param delivery [Qpid::Proton::Delivery] The delivery
- # @param delivered [Boolean] True if this was considered a delivery
- # attempt.
- #
- def release(delivery, delivered = true)
- if delivered
- self.settle(delivery, Qpid::Proton::Delivery::MODIFIED)
- else
- self.settle(delivery, Qpid::Proton::Delivery::RELEASED)
- end
- end
-
- # Settles the specified delivery. Updates the delivery state if a state
- # is specified.
- #
- # @param delivery [Qpid::Proton::Delivery] The delivery.
- # @param state [Fixnum] The delivery state.
- #
- def settle(delivery, state = nil)
- delivery.update(state) unless state.nil?
- delivery.settle
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/c_adaptor.rb b/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
deleted file mode 100644
index ef4852e..0000000
--- a/proton-c/bindings/ruby/lib/handler/c_adaptor.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # @private
- class CAdaptor
-
- def initialize(handler, on_error = nil)
- @handler = handler
- @on_error = on_error
- end
-
- def dispatch(cevent, ctype)
- event = Qpid::Proton::Event::Event.wrap(cevent, ctype)
- # TODO add a variable to enable this programmatically
- # print "EVENT: #{event} going to #{@handler}\n"
- event.dispatch(@handler)
- end
-
- def exception(error)
- if @on_error.nil?
- raise error
- else
- @on_error.call(error)
- end
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
deleted file mode 100644
index 377cc2f..0000000
--- a/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # @private
- class CFlowController < Qpid::Proton::Handler::WrappedHandler
-
- include Qpid::Proton::Util::Wrapper
-
- def initialize(window = 1024)
- super(Cproton.pn_flowcontroller(window))
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
deleted file mode 100644
index 727a20b..0000000
--- a/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb
+++ /dev/null
@@ -1,217 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # A utility that exposes endpoint events; i.e., the open/close of a link,
- # session or connection, in a more intuitive manner.
- #
- # A XXX_opened method will be called when both local and remote peers have
- # opened the link, session or connection. This can be used to confirm a
- # locally initiated action for example.
- #
- # A XXX_opening method will be called when the remote peer has requested
- # an open that was not initiated locally. By default this will simply open
- # locally, which then trigtgers the XXX_opened called.
- #
- # The same applies to close.
- #
- class EndpointStateHandler < Qpid::Proton::BaseHandler
-
- def initialize(peer_close_is_error = false, delegate = nil)
- @delegate = delegate
- @peer_close_is_error = peer_close_is_error
- end
-
- def self.print_error(endpoint, endpoint_type)
- if !endpoint.remote_condition.nil?
- elsif self.local_endpoint?(endpoint) && endpoint.remote_closed?
- logging.error("#{endpoint_type} closed by peer")
- end
- end
-
- def on_link_remote_close(event)
- if !event.link.remote_condition.nil?
- self.on_link_error(event)
- elsif event.link.local_closed?
- self.on_link_closed(event)
- else
- self.on_link_closing(event)
- end
- event.link.close
- end
-
- def on_session_remote_close(event)
- if !event.session.remote_condition.nil?
- self.on_session_error(event)
- elsif event.session.local_closed?
- self.on_session_closed(event)
- else
- self.on_session_closing(event)
- end
- event.session.close
- end
-
- def on_connection_remote_close(event)
- if !event.connection.remote_condition.nil?
- self.on_connection_error(event)
- elsif event.connection.local_closed?
- self.on_connection_closed(event)
- else
- self.on_connection_closing(event)
- end
- event.connection.close
- end
-
- def on_connection_local_open(event)
- self.on_connection_opened(event) if event.connection.remote_active?
- end
-
- def on_connection_remote_open(event)
- if !(event.connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
- self.on_connection_opened(event)
- elsif event.connection.local_uninit?
- self.on_connection_opening(event)
- event.connection.open
- end
- end
-
- def on_session_local_open(event)
- self.on_session_opened(event) if event.session.remote_active?
- end
-
- def on_session_remote_open(event)
- if !(event.session.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
- self.on_session_opened(event)
- elsif event.session.local_uninit?
- self.on_session_opening(event)
- event.session.open
- end
- end
-
- def on_link_local_open(event)
- self.on_link_opened(event) if event.link.remote_active?
- end
-
- def on_link_remote_open(event)
- if !(event.link.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
- self.on_link_opened(event)
- elsif event.link.local_uninit?
- self.on_link_opening(event)
- event.link.open
- end
- end
-
- def on_connection_opened(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
- end
-
- def on_session_opened(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
- end
-
- def on_link_opened(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_link_opened, event) if !@delegate.nil?
- end
-
- def on_connection_opening(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_opening, event) if !@delegate.nil?
- end
-
- def on_session_opening(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_session_opening, event) if !@delegate.nil?
- end
-
- def on_link_opening(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_link_opening, event) if !@delegate.nil?
- end
-
- def on_connection_error(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_error, event)
- else
- self.log_error(event.connection, "connection")
- end
- end
-
- def on_session_error(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_session_error, event)
- else
- self.log_error(event.session, "session")
- event.connection.close
- end
- end
-
- def on_link_error(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_link_error, event)
- else
- self.log_error(event.link, "link")
- event.conneciton.close
- end
- end
-
- def on_connection_closed(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_closed, event) if !@delegate.nil?
- end
-
- def on_session_closed(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_session_closed, event) if !@delegate.nil?
- end
-
- def on_link_closed(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_link_closed, event) if !@delegate.nil?
- end
-
- def on_connection_closing(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_closing, event)
- elsif @peer_close_is_error
- self.on_connection_error(event)
- end
- end
-
- def on_session_closing(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_session_closing, event)
- elsif @peer_close_is_error
- self.on_session_error(event)
- end
- end
-
- def on_link_closing(event)
- if !@delegate.nil?
- Qpid::Proton::Event.dispatch(@delegate, :on_link_closing, event)
- elsif @peer_close_is_error
- self.on_link_error(event)
- end
- end
-
- def on_transport_tail_closed(event)
- self.on_transport_closed(event)
- end
-
- def on_transport_closed(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_disconnected, event) if !@delegate.nil?
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb b/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
deleted file mode 100644
index ced84a2..0000000
--- a/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # A utility for simpler and more intuitive handling of delivery events
- # related to incoming messages.
- #
- class IncomingMessageHandler < Qpid::Proton::BaseHandler
-
- include Acking
-
- def initialize(auto_accept = true, delegate = nil)
- @delegate = delegate
- @auto_accept = auto_accept
- end
-
- def on_delivery(event)
- delivery = event.delivery
- return unless delivery.link.receiver?
- if delivery.readable? && !delivery.partial?
- event.message = Qpid::Proton::Util::Engine.receive_message(delivery)
- if event.link.local_closed?
- if @auto_accept
- delivery.update(Qpid::Proton::Disposition::RELEASED)
- delivery.settle
- end
- else
- begin
- self.on_message(event)
- if @auto_accept
- delivery.update(Qpid::Proton::Disposition::ACCEPTED)
- delivery.settle
- end
- rescue Qpid::Proton::Reject
- delivery.update(Qpid::Proton::Disposition::REJECTED)
- delivery.settle
- rescue Qpid::Proton::Release
- delivery.update(Qpid::Proton::Disposition::MODIFIED)
- delivery.settle
- end
- end
- elsif delivery.updated? && delivery.settled?
- self.on_settled(event)
- end
- end
-
- def on_message(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_message, event) if !@delegate.nil?
- end
-
- def on_settled(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/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
deleted file mode 100644
index b4a0bcf..0000000
--- a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
+++ /dev/null
@@ -1,218 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # A general purpose handler that simplifies processing events.
- #
- # @example
- #
- class MessagingHandler < Qpid::Proton::BaseHandler
-
- attr_reader :handlers
-
- # Creates a new instance.
- #
- # @param [Fixnum] prefetch
- # @param [Boolean] auto_accept
- # @param [Boolean] auto_settle
- # @param [Boolean] peer_close_is_error
- #
- def initialize(prefetch = 10, auto_accept = true, auto_settle = true, peer_close_is_error = false)
- @handlers = Array.new
- @handlers << CFlowController.new(prefetch) unless prefetch.zero?
- @handlers << EndpointStateHandler.new(peer_close_is_error, self)
- @handlers << IncomingMessageHandler.new(auto_accept, self)
- @handlers << OutgoingMessageHandler.new(auto_settle,self)
- end
-
- # Called when the peer closes the connection with an error condition.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_connection_error(event)
- EndpointStateHandler.print_error(event.connection, "connection")
- end
-
- # Called when the peer closes the session with an error condition.
- #
- # @param event [Qpid:Proton::Event::Event] The event.
- #
- def on_session_error(event)
- EndpointStateHandler.print_error(event.session, "session")
- event.connection.close
- end
-
- # Called when the peer closes the link with an error condition.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_link_error(event)
- EndpointStateHandler.print_error(event.link, "link")
- event.connection.close
- end
-
- # Called when the event loop starts.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_reactor_init(event)
- self.on_start(event)
- end
-
- # Called when the event loop starts.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_start(event)
- end
-
- # Called when the connection is closed.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_connection_closed(event)
- end
-
- # Called when the session is closed.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_session_closed(event)
- end
-
- # Called when the link is closed.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_link_closed(event)
- end
-
- # Called when the peer initiates the closing of the connection.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_connection_closing(event)
- end
-
- # Called when the peer initiates the closing of the session.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_session_closing(event)
- end
-
- # Called when the peer initiates the closing of the link.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_link_closing(event)
- end
-
- # Called when the socket is disconnected.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_disconnected(event)
- end
-
- # Called when the sender link has credit and messages can therefore
- # be transferred.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_sendable(event)
- end
-
- # Called when the remote peer accepts an outgoing message.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_accepted(event)
- end
-
- # Called when the remote peer rejects an outgoing message.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_rejected(event)
- end
-
- # Called when the remote peer releases an outgoing message.
- #
- # Note that this may be in response to either the RELEASE or
- # MODIFIED state as defined by the AMPQ specification.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_released(event)
- end
-
- # Called when the remote peer has settled hte outgoing message.
- #
- # This is the point at which it should never be retransmitted.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_settled(event)
- end
-
- # Called when a message is received.
- #
- # The message itself can be obtained as a property on the event. For
- # the purpose of referring to this message in further actions, such as
- # explicitly accepting it) the delivery should be used. This is also
- # obtainable vi a property on the event.
- #
- # This method needs to be overridden.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_message(event)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
deleted file mode 100644
index 3f1f3f3..0000000
--- a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- # A utility for simpler and more intuitive handling of delivery events
- # related to outgoing messages.
- #
- class OutgoingMessageHandler < Qpid::Proton::BaseHandler
-
- def initialize(auto_settle = true, delegate = nil)
- @auto_settle = auto_settle
- @delegate = delegate
- end
-
- def on_link_flow(event)
- self.on_sendable(event) if event.link.sender? && event.link.credit > 0 &&
- (event.link.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE) &&
- (event.link.state & Qpid::Proton::Endpoint::REMOTE_ACTIVE)
- end
-
- def on_delivery(event)
- delivery = event.delivery
- if delivery.link.sender? && delivery.updated?
- if delivery.remote_accepted?
- self.on_accepted(event)
- elsif delivery.remote_rejected?
- self.on_rejected(event)
- elsif delivery.remote_released? || delivery.remote_modified?
- self.on_released(event)
- end
- self.on_settled(event) if delivery.settled?
- delivery.settle if @auto_settle
- end
- end
-
- # Called when the sender link has credit and messages and be transferred.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_sendable(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil?
- end
-
- # Called when the remote peer accepts a sent message.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_accepted(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil?
- end
-
- # Called when the remote peer rejects a sent message.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_rejected(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil?
- end
-
- # Called when the remote peer releases an outgoing message.
- #
- # Note that this may be in resposnse to either the REELAASE or MODIFIED
- # state as defined by the AMQP specification.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_released(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil?
- end
-
- # Called when the remote peer has settled the outgoing message.
- #
- # This is the point at which it should never be retransmitted.
- #
- # @param event [Qpid::Proton::Event::Event] The event.
- #
- def on_settled(event)
- Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb b/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
deleted file mode 100644
index 6d55dee..0000000
--- a/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Qpid::Proton::Handler
-
- class WrappedHandler
-
- # @private
- include Qpid::Proton::Util::Wrapper
-
- def self.wrap(impl, on_error = nil)
- return nil if impl.nil?
-
- result = self.fetch_instance(impl) || WrappedHandler.new(impl)
- result.on_error = on_error
- return result
- end
-
- include Qpid::Proton::Util::Handler
-
- def initialize(impl_or_constructor)
- if impl_or_constructor.is_a?(Method)
- @impl = impl_or_constructor.call
- else
- @impl = impl_or_constructor
- Cproton.pn_incref(@impl)
- end
- @on_error = nil
- self.class.store_instance(self)
- end
-
- def add(handler)
- return if handler.nil?
-
- impl = chandler(handler, self.method(:_on_error))
- Cproton.pn_handler_add(@impl, impl)
- Cproton.pn_decref(impl)
- end
-
- def clear
- Cproton.pn_handler_clear(@impl)
- end
-
- def on_error=(on_error)
- @on_error = on_error
- end
-
- private
-
- def _on_error(info)
- if self.has?['on_error']
- self['on_error'].call(info)
- else
- raise info
- end
- end
-
- end
-
-end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org