qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [27/38] qpid-proton git commit: PROTON-881: added Extendable interface for things that support attachments and modified the reactor code to use it for handlers
Date Sun, 05 Jul 2015 23:45:28 GMT
PROTON-881: added Extendable interface for things that support attachments and modified the
reactor code to use it for handlers


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/09c190f2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/09c190f2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/09c190f2

Branch: refs/heads/master
Commit: 09c190f2b18b4a19e21da891afbf7736e40fd923
Parents: 7115d0d
Author: Rafael Schloming <rhs@alum.mit.edu>
Authored: Thu May 14 11:44:02 2015 -0400
Committer: Rafael Schloming <rhs@alum.mit.edu>
Committed: Thu May 14 11:44:02 2015 -0400

----------------------------------------------------------------------
 .../apache/qpid/proton/example/reactor/Cat.java |  2 +-
 .../qpid/proton/example/reactor/Echo.java       |  2 +-
 .../qpid/proton/example/reactor/Scheduling.java |  4 +--
 .../apache/qpid/proton/engine/BaseHandler.java  |  9 ++++++
 .../org/apache/qpid/proton/engine/Endpoint.java |  4 +--
 .../apache/qpid/proton/engine/Extendable.java   | 34 ++++++++++++++++++++
 .../apache/qpid/proton/reactor/Acceptor.java    |  6 ++--
 .../apache/qpid/proton/reactor/Selectable.java  | 11 ++-----
 .../org/apache/qpid/proton/reactor/Task.java    | 13 +++-----
 .../qpid/proton/reactor/impl/AcceptorImpl.java  | 20 ++++++++----
 .../qpid/proton/reactor/impl/ReactorImpl.java   | 25 ++++++--------
 .../proton/reactor/impl/SelectableImpl.java     | 29 +++--------------
 .../qpid/proton/reactor/impl/TaskImpl.java      | 31 +++++++-----------
 .../apache/qpid/proton/reactor/ReactorTest.java |  7 ++--
 14 files changed, 101 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
index 53eb793..7cc1df3 100644
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
+++ b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Cat.java
@@ -78,7 +78,7 @@ public class Cat extends BaseHandler {
         Reactor reactor = event.getReactor();
         Selectable selectable = reactor.selectable();
         selectable.setChannel(channel);
-        selectable.add(new EchoHandler());
+        setHandler(selectable, new EchoHandler());
         reactor.update(selectable);
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
index 2d5be72..e2b0807 100644
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
+++ b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Echo.java
@@ -78,7 +78,7 @@ public class Echo extends BaseHandler {
         Reactor reactor = event.getReactor();
         Selectable selectable = reactor.selectable();
         selectable.setChannel(channel);
-        selectable.add(new EchoHandler());
+        setHandler(selectable, new EchoHandler());
         reactor.update(selectable);
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
----------------------------------------------------------------------
diff --git a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
index 47e0cb3..f304b74 100644
--- a/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
+++ b/examples/java/reactor/src/main/java/org/apache/qpid/proton/example/reactor/Scheduling.java
@@ -38,13 +38,13 @@ public class Scheduling extends BaseHandler {
         startTime = System.currentTimeMillis();
         System.out.println("Hello, World!");
         Task task = event.getReactor().schedule(1000, this);
-        task.setAttachment("Yay");
+        task.attachments().set("key", String.class, "Yay");
     }
 
     @Override
     public void onTimerTask(Event event) {
         Task task = event.getTask();
-        System.out.println(task.getAttachment() + " my task is complete!");
+        System.out.println(task.attachments().get("key", String.class) + " my task is complete!");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
index ac17c5e..02e10d5 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java
@@ -31,6 +31,15 @@ import java.util.Iterator;
 
 public class BaseHandler implements Handler
 {
+
+    public static Handler getHandler(Extendable ext) {
+        return ext.attachments().get(Handler.class, Handler.class);
+    }
+
+    public static void setHandler(Extendable ext, Handler handler) {
+        ext.attachments().set(Handler.class, Handler.class, handler);
+    }
+
     private HashSet<Handler> children = new HashSet<Handler>();
 
     @Override public void onConnectionInit(Event e) { onUnhandled(e); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
index 021a001..d88087b 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java
@@ -23,7 +23,7 @@ package org.apache.qpid.proton.engine;
 
 import org.apache.qpid.proton.amqp.transport.ErrorCondition;
 
-public interface Endpoint
+public interface Endpoint extends Extendable
 {
     /**
      * @return the local endpoint state
@@ -77,6 +77,4 @@ public interface Endpoint
      */
     public Object getContext();
 
-    Record attachments();
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
new file mode 100644
index 0000000..14b9b2e
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Extendable.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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;
+
+
+/**
+ * Extendable
+ *
+ */
+
+public interface Extendable
+{
+
+    Record attachments();
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
index f2a320b..744f4cb 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Acceptor.java
@@ -21,10 +21,10 @@
 
 package org.apache.qpid.proton.reactor;
 
-import org.apache.qpid.proton.engine.Handler;
+import org.apache.qpid.proton.engine.Extendable;
 
-public interface Acceptor extends ReactorChild {
+public interface Acceptor extends ReactorChild, Extendable {
 
-    void add(Handler handler);
     void close();
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
index e839b10..73bc3b8 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Selectable.java
@@ -24,10 +24,11 @@ package org.apache.qpid.proton.reactor;
 import java.nio.channels.SelectableChannel;
 
 import org.apache.qpid.proton.engine.Collector;
+import org.apache.qpid.proton.engine.Extendable;
 import org.apache.qpid.proton.engine.Handler;
 import org.apache.qpid.proton.engine.Transport;
 
-public interface Selectable extends ReactorChild {
+public interface Selectable extends ReactorChild, Extendable {
 
     public interface Callback {
         void run(Selectable selectable);
@@ -75,10 +76,6 @@ public interface Selectable extends ReactorChild {
 
     public SelectableChannel getChannel() ;
 
-    void setAttachment(Object attachment) ;
-
-    Object getAttachment() ;
-
     boolean isRegistered() ;
 
     void setRegistered(boolean registered) ;
@@ -86,6 +83,7 @@ public interface Selectable extends ReactorChild {
     void setCollector(final Collector collector) ;
 
     public Reactor getReactor() ;
+
     public void terminate() ;
 
     public boolean isTerminal();
@@ -96,7 +94,4 @@ public interface Selectable extends ReactorChild {
 
     public void setReactor(Reactor reactor) ;
 
-    public void add(Handler handler);
-
-    public Handler getHandler() ;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
index 88031c5..9d2557c 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Task.java
@@ -21,15 +21,12 @@
 
 package org.apache.qpid.proton.reactor;
 
-import org.apache.qpid.proton.engine.Handler;
+import org.apache.qpid.proton.engine.Extendable;
 
-public interface Task {
+public interface Task extends Extendable {
 
     public long deadline();
-    public void setReactor(Reactor reactor) ;
+    public void setReactor(Reactor reactor);
     public Reactor getReactor();
-    public void setHandler(Handler handler) ;
-    public Handler getHandler() ;
-    public Object getAttachment() ;
-    public void setAttachment(Object attachment) ;
-}
\ No newline at end of file
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
index 243a963..7300b50 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/AcceptorImpl.java
@@ -27,11 +27,14 @@ import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 
 import org.apache.qpid.proton.Proton;
+import org.apache.qpid.proton.engine.BaseHandler;
 import org.apache.qpid.proton.engine.Connection;
 import org.apache.qpid.proton.engine.Handler;
+import org.apache.qpid.proton.engine.Record;
 import org.apache.qpid.proton.engine.Sasl;
 import org.apache.qpid.proton.engine.Sasl.SaslOutcome;
 import org.apache.qpid.proton.engine.Transport;
+import org.apache.qpid.proton.engine.impl.RecordImpl;
 import org.apache.qpid.proton.reactor.Acceptor;
 import org.apache.qpid.proton.reactor.Reactor;
 import org.apache.qpid.proton.reactor.Selectable;
@@ -39,6 +42,8 @@ import org.apache.qpid.proton.reactor.Selectable.Callback;
 
 public class AcceptorImpl implements Acceptor {
 
+    private Record attachments = new RecordImpl();
+
     private class AcceptorReadable implements Callback {
         @Override
         public void run(Selectable selectable) {
@@ -48,7 +53,7 @@ public class AcceptorImpl implements Acceptor {
                 if (socketChannel == null) {
                     throw new ReactorInternalException("Selectable readable, but no socket
to accept");
                 }
-                Handler handler = (Handler)selectable.getAttachment();
+                Handler handler = BaseHandler.getHandler(AcceptorImpl.this);
                 if (handler == null) {
                     // TODO: set selectable.getAttachment() to null?
                     handler = reactor.getHandler();
@@ -99,7 +104,7 @@ public class AcceptorImpl implements Acceptor {
         sel.onReadable(new AcceptorReadable());
         sel.onFree(new AcceptorFree());
         sel.setReactor(reactor);
-        sel.setAttachment(handler);
+        BaseHandler.setHandler(this, handler);
         sel.setReading(true);
         reactor.update(sel);
     }
@@ -120,11 +125,6 @@ public class AcceptorImpl implements Acceptor {
         }
     }
 
-    @Override
-    public void add(Handler handler) {
-        sel.add(handler);
-    }
-
     // Used for unit tests, where acceptor is bound to an ephemeral port
     public int getPortNumber() throws IOException {
         ServerSocketChannel ssc = (ServerSocketChannel)sel.getChannel();
@@ -135,4 +135,10 @@ public class AcceptorImpl implements Acceptor {
     public void free() {
         sel.free();
     }
+
+    @Override
+    public Record attachments() {
+        return attachments;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
index 94bae9e..e48bd3b 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/ReactorImpl.java
@@ -33,6 +33,7 @@ import org.apache.qpid.proton.engine.Collector;
 import org.apache.qpid.proton.engine.Connection;
 import org.apache.qpid.proton.engine.Event;
 import org.apache.qpid.proton.engine.Event.Type;
+import org.apache.qpid.proton.engine.Extendable;
 import org.apache.qpid.proton.engine.Handler;
 import org.apache.qpid.proton.engine.Record;
 import org.apache.qpid.proton.engine.impl.CollectorImpl;
@@ -46,7 +47,7 @@ import org.apache.qpid.proton.reactor.Selectable.Callback;
 import org.apache.qpid.proton.reactor.Selector;
 import org.apache.qpid.proton.reactor.Task;
 
-public class ReactorImpl implements Reactor {
+public class ReactorImpl implements Reactor, Extendable {
 
     private CollectorImpl collector;
     private long now;
@@ -201,37 +202,29 @@ public class ReactorImpl implements Reactor {
         }
     }
 
-    static Handler getHandler(Record record) {
-        return record.get(ReactorImpl.class, Handler.class);
-    }
-
-    static void setHandler(Record record, Handler handler) {
-        record.set(ReactorImpl.class, Handler.class, handler);
-    }
-
     // pn_event_handler
     private Handler eventHandler(Event event) {
         Handler result;
         if (event.getLink() != null) {
-            result = getHandler(event.getLink().attachments());
+            result = BaseHandler.getHandler(event.getLink());
             if (result != null) return result;
         }
         if (event.getSession() != null) {
-            result = getHandler(event.getSession().attachments());
+            result = BaseHandler.getHandler(event.getSession());
             if (result != null) return result;
         }
         if (event.getConnection() != null) {
-            result = getHandler(event.getConnection().attachments());
+            result = BaseHandler.getHandler(event.getConnection());
             if (result != null) return result;
         }
 
         if (event.getTask() != null) {
-            result = event.getTask().getHandler();
+            result = BaseHandler.getHandler(event.getTask());
             if (result != null) return result;
         }
 
         if (event.getSelectable() != null) {
-            result = event.getSelectable().getHandler();
+            result = BaseHandler.getHandler(event.getSelectable());
             if (result != null) return result;
         }
 
@@ -332,7 +325,7 @@ public class ReactorImpl implements Reactor {
     public Task schedule(int delay, Handler handler) {
         Task task = timer.schedule(now + delay);
         task.setReactor(this);
-        task.setHandler(handler);
+        BaseHandler.setHandler(task, handler);
         if (selectable != null) {
             selectable.setDeadline(timer.deadline());
             update(selectable);
@@ -403,7 +396,7 @@ public class ReactorImpl implements Reactor {
     @Override
     public Connection connection(Handler handler) {
         Connection connection = Proton.connection();
-        setHandler(connection.attachments(), handler);
+        BaseHandler.setHandler(connection, handler);
         connection.collect(collector);
         children.add(connection);
         ((ConnectionImpl)connection).setReactor(this);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
index 570851e..2e053ef 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/SelectableImpl.java
@@ -27,8 +27,10 @@ import org.apache.qpid.proton.engine.BaseHandler;
 import org.apache.qpid.proton.engine.Collector;
 import org.apache.qpid.proton.engine.Event.Type;
 import org.apache.qpid.proton.engine.Handler;
+import org.apache.qpid.proton.engine.Record;
 import org.apache.qpid.proton.engine.Transport;
 import org.apache.qpid.proton.engine.impl.CollectorImpl;
+import org.apache.qpid.proton.engine.impl.RecordImpl;
 import org.apache.qpid.proton.reactor.Reactor;
 import org.apache.qpid.proton.reactor.Selectable;
 
@@ -45,7 +47,7 @@ public class SelectableImpl implements Selectable {
     private boolean writing = false;
     private long deadline = 0;
     private SelectableChannel channel;
-    private Object attachment;
+    private Record attachments = new RecordImpl();
     private boolean registered;
     private Reactor reactor;
     private Transport transport;
@@ -166,16 +168,6 @@ public class SelectableImpl implements Selectable {
     }
 
     @Override
-    public void setAttachment(Object attachment) {
-        this.attachment = attachment;
-    }
-
-    @Override
-    public Object getAttachment() {
-        return attachment;
-    }
-
-    @Override
     public boolean isRegistered() {
         return registered;
     }
@@ -245,22 +237,11 @@ public class SelectableImpl implements Selectable {
         this.reactor = reactor;
     }
 
-    // TODO: all this gets stuffed into records in the C code...
-    private BaseHandler _handler;
     @Override
-    public void add(Handler handler) {
-        if (_handler == null) {
-            _handler = new BaseHandler();
-        }
-        _handler.add(handler);
+    public Record attachments() {
+        return attachments;
     }
 
-    @Override
-    public Handler getHandler() {
-        return _handler;
-    }
-
-
     public boolean isTerminated() {
         return terminated;
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
index 3f650c2..5311059 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/TaskImpl.java
@@ -23,7 +23,8 @@ package org.apache.qpid.proton.reactor.impl;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.qpid.proton.engine.Handler;
+import org.apache.qpid.proton.engine.Record;
+import org.apache.qpid.proton.engine.impl.RecordImpl;
 import org.apache.qpid.proton.reactor.Reactor;
 import org.apache.qpid.proton.reactor.Task;
 
@@ -31,11 +32,13 @@ public class TaskImpl implements Task, Comparable<TaskImpl> {
     private final long deadline;
     private final int counter;
     private final AtomicInteger count = new AtomicInteger();
+    private Record attachments = new RecordImpl();
 
     public TaskImpl(long deadline) {
         this.deadline = deadline;
         this.counter = count.getAndIncrement();
     }
+
     @Override
     public int compareTo(TaskImpl other) {
         int result;
@@ -48,36 +51,26 @@ public class TaskImpl implements Task, Comparable<TaskImpl> {
         }
         return result;
     }
+
     @Override
     public long deadline() {
         return deadline;
     }
+
     private Reactor reactor;
     @Override
     public void setReactor(Reactor reactor) {
         this.reactor = reactor;
-
     }
+
     @Override
     public Reactor getReactor() {
         return reactor;
     }
-    private Handler handler;
-    @Override
-    public void setHandler(Handler handler) {
-        this.handler = handler;
-    }
-    @Override
-    public Handler getHandler() {
-        return handler;
-    }
-    private Object attachment;
-    @Override
-    public Object getAttachment() {
-        return attachment;
-    }
+
     @Override
-    public void setAttachment(Object attachment) {
-        this.attachment = attachment;
+    public Record attachments() {
+        return attachments;
     }
-}
\ No newline at end of file
+
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09c190f2/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java b/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
index 4b1dba0..76fc632 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/reactor/ReactorTest.java
@@ -122,8 +122,7 @@ public class ReactorTest {
      * which is immediately closed by the reactor.  The expected behaviour is for:
      * <ul>
      *   <li>The reactor to end immediately (as it has no more work to process).</li>
-     *   <li>The handler, associated with the acceptor, to receive init, update and
-     *       final events.</li>
+     *   <li>The handler, associated with the acceptor, to receive no events.</li>
      *   <li>For it's lifetime, the acceptor is one of the reactor's children.</li>
      * </ul>
      * @throws IOException
@@ -135,7 +134,7 @@ public class ReactorTest {
         assertNotNull(acceptor);
         assertTrue("acceptor should be one of the reactor's children", reactor.children().contains(acceptor));
         TestHandler acceptorHandler = new TestHandler();
-        acceptor.add(acceptorHandler);
+        BaseHandler.setHandler(acceptor, acceptorHandler);
         reactor.getHandler().add(new BaseHandler() {
             @Override
             public void onReactorInit(Event event) {
@@ -144,7 +143,7 @@ public class ReactorTest {
         });
         reactor.run();
         reactor.free();
-        acceptorHandler.assertEvents(Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.SELECTABLE_FINAL);
+        acceptorHandler.assertEvents();
         assertFalse("acceptor should have been removed from the reactor's children", reactor.children().contains(acceptor));
     }
 


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


Mime
View raw message