qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1593296 - in /qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl: FrameWriter.java Ref.java TransportImpl.java
Date Thu, 08 May 2014 14:46:19 GMT
Author: rhs
Date: Thu May  8 14:46:19 2014
New Revision: 1593296

URL: http://svn.apache.org/r1593296
Log:
PROTON-575: allow FrameWriter to pick up changes in the protocol tracer

Added:
    qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java
Modified:
    qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
    qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java

Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java?rev=1593296&r1=1593295&r2=1593296&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
(original)
+++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
Thu May  8 14:46:19 2014
@@ -45,7 +45,7 @@ class FrameWriter
     private WritableBuffer _buffer;
     private int _maxFrameSize;
     private byte _frameType;
-    private ProtocolTracer _protocolTracer;
+    final private Ref<ProtocolTracer> _protocolTracer;
     private Object _logCtx;
 
     private int _frameStart = 0;
@@ -53,7 +53,7 @@ class FrameWriter
     private int _performativeSize;
 
     FrameWriter(EncoderImpl encoder, int maxFrameSize, byte frameType,
-                ProtocolTracer protocolTracer, Object logCtx)
+                Ref<ProtocolTracer> protocolTracer, Object logCtx)
     {
         _encoder = encoder;
         _bbuf = ByteBuffer.allocate(1024);
@@ -157,9 +157,10 @@ class FrameWriter
             TransportFrame frame = new TransportFrame(channel, (FrameBody) frameBody, Binary.create(originalPayload));
             TransportImpl.log(_logCtx, TransportImpl.OUTGOING, frame);
 
-            if( _protocolTracer!=null )
+            ProtocolTracer tracer = _protocolTracer.get();
+            if(tracer != null)
             {
-                _protocolTracer.sentFrame(frame);
+                tracer.sentFrame(frame);
             }
         }
 

Added: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java?rev=1593296&view=auto
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java (added)
+++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/Ref.java Thu
May  8 14:46:19 2014
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.proton.engine.impl;
+
+
+/**
+ * Ref
+ *
+ */
+
+class Ref<T>
+{
+
+    T value;
+
+    public Ref(T initial) {
+        value = initial;
+    }
+
+    public T get() {
+        return value;
+    }
+
+    public void set(T value) {
+        this.value = value;
+    }
+
+}

Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java?rev=1593296&r1=1593295&r2=1593296&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
(original)
+++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
Thu May  8 14:46:19 2014
@@ -99,7 +99,7 @@ public class TransportImpl extends Endpo
     private Open _open;
     private SaslImpl _sasl;
     private SslImpl _ssl;
-    private ProtocolTracer _protocolTracer = null;
+    private final Ref<ProtocolTracer> _protocolTracer = new Ref(null);
 
     private ByteBuffer _lastInputBuffer;
 
@@ -1177,9 +1177,10 @@ public class TransportImpl extends Endpo
 
         log(this, INCOMING, frame);
 
-        if( _protocolTracer != null )
+        ProtocolTracer tracer = _protocolTracer.get();
+        if( tracer != null )
         {
-            _protocolTracer.receivedFrame(frame);
+            tracer.receivedFrame(frame);
         }
 
         frame.getBody().invoke(this,frame.getPayload(), frame.getChannel());
@@ -1203,13 +1204,13 @@ public class TransportImpl extends Endpo
     @Override
     public ProtocolTracer getProtocolTracer()
     {
-        return _protocolTracer;
+        return _protocolTracer.get();
     }
 
     @Override
     public void setProtocolTracer(ProtocolTracer protocolTracer)
     {
-        this._protocolTracer = protocolTracer;
+        this._protocolTracer.set(protocolTracer);
     }
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message