PROTON-964: integrate proton-j redispatch with python
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/69fa53ba Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/69fa53ba Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/69fa53ba Branch: refs/heads/proton-go Commit: 69fa53bae84a923f7e28420a95500c7879281d92 Parents: b2f2fcd Author: Bozo Dragojevic <[email protected]> Authored: Mon Sep 28 10:08:43 2015 +0200 Committer: Bozo Dragojevic <[email protected]> Committed: Mon Sep 28 12:42:33 2015 +0200 ---------------------------------------------------------------------- proton-c/bindings/python/proton/__init__.py | 15 ++++++++++++--- proton-j/src/main/resources/cengine.py | 11 ++++++++++- proton-j/src/main/resources/creactor.py | 5 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69fa53ba/proton-c/bindings/python/proton/__init__.py ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py index fc26264..dcc2be7 100644 --- a/proton-c/bindings/python/proton/__init__.py +++ b/proton-c/bindings/python/proton/__init__.py @@ -3629,10 +3629,20 @@ class Collector: pn_collector_free(self._impl) del self._impl +if "TypeExtender" not in globals(): + class TypeExtender: + def __init__(self, number): + self.number = number + def next(self): + try: + return self.number + finally: + self.number += 1 + class EventType(object): _lock = threading.Lock() - _extended = 10000 + _extended = TypeExtender(10000) TYPES = {} def __init__(self, name=None, number=None, method=None): @@ -3644,8 +3654,7 @@ class EventType(object): name = pn_event_type_name(number) if number is None: - number = EventType._extended - EventType._extended += 1 + number = self._extended.next() if method is None: method = "on_%s" % name http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69fa53ba/proton-j/src/main/resources/cengine.py ---------------------------------------------------------------------- diff --git a/proton-j/src/main/resources/cengine.py b/proton-j/src/main/resources/cengine.py index 9287f0e..319740e 100644 --- a/proton-j/src/main/resources/cengine.py +++ b/proton-j/src/main/resources/cengine.py @@ -25,7 +25,7 @@ from org.apache.qpid.proton.amqp.transaction import Coordinator from org.apache.qpid.proton.amqp.transport import ErrorCondition, \ SenderSettleMode, ReceiverSettleMode from org.apache.qpid.proton.engine import EndpointState, Sender, \ - Receiver, Transport as _Transport, TransportException + Receiver, Transport as _Transport, TransportException, EventType from java.util import EnumSet from compat import array, zeros @@ -1125,3 +1125,12 @@ def pn_event_attachments(event): def pn_event_copy(event): return event.copy() + +class TypeExtender: + def __init__(self, number): + pass + def next(self): + class CustomEvent(EventType): + def isValid(self): + return True + return CustomEvent() http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/69fa53ba/proton-j/src/main/resources/creactor.py ---------------------------------------------------------------------- diff --git a/proton-j/src/main/resources/creactor.py b/proton-j/src/main/resources/creactor.py index ffb17d3..51f7cdc 100644 --- a/proton-j/src/main/resources/creactor.py +++ b/proton-j/src/main/resources/creactor.py @@ -77,7 +77,10 @@ def peel_handler_exception(meth): def pn_handler_add(h, c): h.add(c) def pn_handler_dispatch(h, ev, et): - ev.impl.dispatch(h) + if et != None and et != ev.impl.type: + ev.impl.redispatch(et, h) + else: + ev.impl.dispatch(h) def pn_record_set_handler(r, h): BaseHandler.setHandler(r, h) def pn_record_get_handler(r): --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
