Author: rhs Date: Thu Jun 19 17:22:51 2014 New Revision: 1603956 URL: http://svn.apache.org/r1603956 Log: changed EventImpl to use a single context
Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java?rev=1603956&r1=1603955&r2=1603956&view=diff ============================================================================== --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java Thu Jun 19 17:22:51 2014 @@ -129,9 +129,12 @@ public abstract class EndpointImpl imple if (emit) { ConnectionImpl conn = getConnectionImpl(); - EventImpl ev = conn.put(Event.Type.TRANSPORT); - if (ev != null) { - ev.init(conn); + TransportImpl trans = conn.getTransport(); + if (trans != null) { + EventImpl ev = conn.put(Event.Type.TRANSPORT); + if (ev != null) { + ev.init(trans); + } } } } Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java?rev=1603956&r1=1603955&r2=1603956&view=diff ============================================================================== --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java Thu Jun 19 17:22:51 2014 @@ -36,11 +36,7 @@ class EventImpl implements Event { Type type; - Connection connection; - Session session; - Link link; - Delivery delivery; - Transport transport; + Object context; EventImpl next; EventImpl(Type type) @@ -51,11 +47,7 @@ class EventImpl implements Event void clear() { type = null; - connection = null; - session = null; - link = null; - delivery = null; - transport = null; + context = null; } public Category getCategory() @@ -68,70 +60,91 @@ class EventImpl implements Event return type; } + public Object getContext() + { + return context; + } + public Connection getConnection() { - return connection; + switch (type) { + case CONNECTION_REMOTE_STATE: + case CONNECTION_LOCAL_STATE: + return (Connection) context; + case TRANSPORT: + Transport transport = getTransport(); + if (transport == null) { + return null; + } + return ((TransportImpl) transport).getConnectionImpl(); + default: + Session ssn = getSession(); + if (ssn == null) { + return null; + } + return ssn.getConnection(); + } } public Session getSession() { - return session; + switch (type) { + case SESSION_REMOTE_STATE: + case SESSION_LOCAL_STATE: + return (Session) context; + default: + Link link = getLink(); + if (link == null) { + return null; + } + return link.getSession(); + } } public Link getLink() { - return link; + switch (type) { + case LINK_REMOTE_STATE: + case LINK_LOCAL_STATE: + case LINK_FLOW: + return (Link) context; + default: + Delivery dlv = getDelivery(); + if (dlv == null) { + return null; + } + return dlv.getLink(); + } } public Delivery getDelivery() { - return delivery; + switch (type) { + case DELIVERY: + return (Delivery) context; + default: + return null; + } } public Transport getTransport() { - return transport; - } - - void init(Transport transport) - { - this.transport = transport; - } - - void init(Connection connection) - { - this.connection = connection; - init(((ConnectionImpl) connection).getTransport()); - } - - void init(Session session) - { - this.session = session; - init(session.getConnection()); - } - - void init(Link link) - { - this.link = link; - init(link.getSession()); + switch (type) { + case TRANSPORT: + return (Transport) context; + default: + return null; + } } - void init(Delivery delivery) + void init(Object context) { - this.delivery = delivery; - init(delivery.getLink()); + this.context = context; } @Override public String toString() { - return "EventImpl{" + - "type=" + type + - ", connection=" + connection + - ", session=" + session + - ", link=" + link + - ", delivery=" + delivery + - ", transport=" + transport + - '}'; + return "EventImpl{" + "type=" + type + ", context=" + context + '}'; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org