qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [2/2] qpid-proton-j git commit: PROTON-1606: move options into reactor package and simplify as a property, expose via reactor for use, apply option to acceptors as well.
Date Fri, 06 Oct 2017 12:07:01 GMT
PROTON-1606: move options into reactor package and simplify as a property, expose via reactor
for use, apply option to acceptors as well.

Updates for changes in #11 / 819e4c3a468f5b0cd65625f86edca82f448468aa


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

Branch: refs/heads/master
Commit: 1b858d4fc3b34f2d6ea28ef050482d8097201bd8
Parents: 819e4c3
Author: Robbie Gemmell <robbie@apache.org>
Authored: Fri Oct 6 12:53:55 2017 +0100
Committer: Robbie Gemmell <robbie@apache.org>
Committed: Fri Oct 6 12:53:55 2017 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/Proton.java     |  2 +-
 .../org/apache/qpid/proton/ReactorOptions.java  | 52 --------------------
 .../org/apache/qpid/proton/reactor/Reactor.java |  9 +++-
 .../qpid/proton/reactor/ReactorOptions.java     | 49 ++++++++++++++++++
 .../qpid/proton/reactor/impl/AcceptorImpl.java  | 11 +++--
 .../qpid/proton/reactor/impl/IOHandler.java     | 14 +-----
 .../qpid/proton/reactor/impl/ReactorImpl.java   | 19 ++++---
 7 files changed, 78 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java b/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
index f80cfee..72f4e04 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/Proton.java
@@ -40,6 +40,7 @@ import org.apache.qpid.proton.engine.SslPeerDetails;
 import org.apache.qpid.proton.engine.Transport;
 import org.apache.qpid.proton.message.Message;
 import org.apache.qpid.proton.reactor.Reactor;
+import org.apache.qpid.proton.reactor.ReactorOptions;
 
 public final class Proton
 {
@@ -107,7 +108,6 @@ public final class Proton
         return reactor;
     }
 
-
     public static Reactor reactor(ReactorOptions options) throws IOException
     {
         return Reactor.Factory.create(options);

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/proton-j/src/main/java/org/apache/qpid/proton/ReactorOptions.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/ReactorOptions.java b/proton-j/src/main/java/org/apache/qpid/proton/ReactorOptions.java
deleted file mode 100644
index bfe368d..0000000
--- a/proton-j/src/main/java/org/apache/qpid/proton/ReactorOptions.java
+++ /dev/null
@@ -1,52 +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.
- *
- */
-package org.apache.qpid.proton;
-
-public class ReactorOptions {
-    private boolean isSaslCreatedByDefault;
-
-    public ReactorOptions() {
-        //Default case creates SASL
-        isSaslCreatedByDefault = true;
-    }
-
-    /**
-     * The default handlers will not create the SASL layer by default. They can still be
created by user later
-     */
-    public void disableSaslByDefault() {
-        this.isSaslCreatedByDefault = false;
-    }
-
-    /**
-     * The default handlers will create the SASL layer by default.
-     */
-    public void enableSaslByDefault() {
-        this.isSaslCreatedByDefault = true;
-    }
-
-    /**
-     * Returns If the SASL is created by default
-     * @return True if SASL will be created by default. False otherwise
-     */
-    public boolean isSaslCreatedByDefault() {
-        return this.isSaslCreatedByDefault;
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
index 86aeed5..0fb28a1 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/Reactor.java
@@ -24,7 +24,6 @@ package org.apache.qpid.proton.reactor;
 import java.io.IOException;
 import java.util.Set;
 
-import org.apache.qpid.proton.ReactorOptions;
 import org.apache.qpid.proton.engine.BaseHandler;
 import org.apache.qpid.proton.engine.Collector;
 import org.apache.qpid.proton.engine.Connection;
@@ -32,6 +31,7 @@ import org.apache.qpid.proton.engine.Event.Type;
 import org.apache.qpid.proton.engine.Handler;
 import org.apache.qpid.proton.engine.HandlerException;
 import org.apache.qpid.proton.engine.Record;
+import org.apache.qpid.proton.reactor.ReactorOptions;
 import org.apache.qpid.proton.reactor.impl.ReactorImpl;
 
 /**
@@ -284,6 +284,13 @@ public interface Reactor {
     void setConnectionHost(Connection c, String host, int port);
 
     /**
+     * Gets the reactor options.
+     *
+     * @return the reactor options
+     */
+    ReactorOptions getOptions();
+
+    /**
      * Get the address used by the connection
      * <p>
      * This may be used to retrieve the remote peer address.

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorOptions.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorOptions.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorOptions.java
new file mode 100644
index 0000000..5863f7c
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/ReactorOptions.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.reactor;
+
+public class ReactorOptions {
+    private boolean enableSaslByDefault = true;
+
+    /**
+     * Sets whether SASL will be automatically enabled with ANONYMOUS as the mechanism,
+     * or if no SASL layer will be enabled. If disabled, the application handlers
+     * can still enable SASL on the transport when it is bound to the connection.
+     *
+     * True by default.
+     *
+     * @param enableSaslByDefault
+     *            true if SASL should be enabled by default, false if not.
+     */
+    public void setEnableSaslByDefault(boolean enableSaslByDefault) {
+        this.enableSaslByDefault = enableSaslByDefault;
+    }
+
+    /**
+     * Returns whether SASL should be enabled by default.
+     *
+     * @return True if SASL should be enabled by default, false if not.
+     * @see #setEnableSaslByDefault(boolean)
+     */
+    public boolean isEnableSaslByDefault() {
+        return this.enableSaslByDefault;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/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 b9fd1de..7275113 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
@@ -37,6 +37,7 @@ 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.ReactorOptions;
 import org.apache.qpid.proton.reactor.impl.ReactorImpl;
 import org.apache.qpid.proton.reactor.Selectable;
 import org.apache.qpid.proton.reactor.Selectable.Callback;
@@ -72,10 +73,12 @@ public class AcceptorImpl implements Acceptor {
                     conn_recs.set(ReactorImpl.CONNECTION_PEER_ADDRESS_KEY, Address.class,
addr);
                 }
                 Transport trans = Proton.transport();
-                Sasl sasl = trans.sasl();
-                sasl.server();
-                sasl.setMechanisms("ANONYMOUS");
-                sasl.done(SaslOutcome.PN_SASL_OK);
+                if(reactor.getOptions().isEnableSaslByDefault()) {
+                    Sasl sasl = trans.sasl();
+                    sasl.server();
+                    sasl.setMechanisms("ANONYMOUS");
+                    sasl.done(SaslOutcome.PN_SASL_OK);
+                }
                 trans.bind(conn);
                 IOHandler.selectableTransport(reactor, socketChannel.socket(), trans);
             } catch(IOException ioException) {

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
index d4373c8..0594d32 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java
@@ -29,7 +29,6 @@ import java.nio.channels.SocketChannel;
 import java.util.Iterator;
 
 import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.ReactorOptions;
 import org.apache.qpid.proton.amqp.Symbol;
 import org.apache.qpid.proton.amqp.transport.ErrorCondition;
 import org.apache.qpid.proton.engine.BaseHandler;
@@ -47,19 +46,8 @@ import org.apache.qpid.proton.reactor.Selector;
 import org.apache.qpid.proton.reactor.Acceptor;
 import org.apache.qpid.proton.reactor.impl.AcceptorImpl;
 
-@SuppressWarnings("deprecation")
 public class IOHandler extends BaseHandler {
 
-    private ReactorOptions options;
-
-    public IOHandler() {
-        this.options = new ReactorOptions();
-    }
-
-    public IOHandler(ReactorOptions options) {
-        this.options = options;
-    }
-
     // pni_handle_quiesced from connection.c
     private void handleQuiesced(Reactor reactor, Selector selector) throws IOException {
         // check if we are still quiesced, other handlers of
@@ -113,7 +101,7 @@ public class IOHandler extends BaseHandler {
         }
         Transport transport = Proton.transport();
 
-        if (this.options.isSaslCreatedByDefault()) {
+        if (reactor.getOptions().isEnableSaslByDefault()) {
             Sasl sasl = transport.sasl();
             sasl.client();
             sasl.setMechanisms("ANONYMOUS");

http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/1b858d4f/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 b629dab..ab71f8a 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
@@ -29,7 +29,6 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.qpid.proton.Proton;
-import org.apache.qpid.proton.ReactorOptions;
 import org.apache.qpid.proton.engine.BaseHandler;
 import org.apache.qpid.proton.engine.Collector;
 import org.apache.qpid.proton.engine.Connection;
@@ -48,12 +47,12 @@ import org.apache.qpid.proton.reactor.Acceptor;
 import org.apache.qpid.proton.reactor.impl.AcceptorImpl;
 import org.apache.qpid.proton.reactor.Reactor;
 import org.apache.qpid.proton.reactor.ReactorChild;
+import org.apache.qpid.proton.reactor.ReactorOptions;
 import org.apache.qpid.proton.reactor.Selectable;
 import org.apache.qpid.proton.reactor.Selectable.Callback;
 import org.apache.qpid.proton.reactor.Selector;
 import org.apache.qpid.proton.reactor.Task;
 
-@SuppressWarnings("deprecation")
 public class ReactorImpl implements Reactor, Extendable {
     public static final ExtendableAccessor<Event, Handler> ROOT = new ExtendableAccessor<>(Handler.class);
 
@@ -73,6 +72,7 @@ public class ReactorImpl implements Reactor, Extendable {
     private Selector selector;
     private Record attachments;
     private final IO io;
+    private final ReactorOptions options;
     protected static final String CONNECTION_PEER_ADDRESS_KEY = "pn_reactor_connection_peer_address";
 
     @Override
@@ -87,6 +87,10 @@ public class ReactorImpl implements Reactor, Extendable {
     }
 
     protected ReactorImpl(IO io) throws IOException {
+        this(io, new ReactorOptions());
+    }
+
+    protected ReactorImpl(IO io, ReactorOptions options) throws IOException {
         collector = (CollectorImpl)Proton.collector();
         global = new IOHandler();
         handler = new BaseHandler();
@@ -97,11 +101,7 @@ public class ReactorImpl implements Reactor, Extendable {
         wakeup = this.io.pipe();
         mark();
         attachments = new RecordImpl();
-    }
-
-    protected ReactorImpl(IO io, ReactorOptions options) throws IOException {
-        this(io);
-        global = new IOHandler(options);
+        this.options = options;
     }
 
     public ReactorImpl() throws IOException {
@@ -144,6 +144,11 @@ public class ReactorImpl implements Reactor, Extendable {
     }
 
     @Override
+    public ReactorOptions getOptions() {
+        return options;
+    }
+
+    @Override
     public long getTimeout() {
         return timeout;
     }


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


Mime
View raw message