From 9380823eda1a94f691f8abbb7cf5dcd6abc5e166 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Fri, 12 Oct 2018 12:06:53 +0200 Subject: [PATCH] Inject the certificate manager in the constructor This simplifies wiring in other contexts (e.g. with Blueprint annotations or Guice). Change-Id: If76dae1ec26d3ef3e3488788b6a5b77d99bb70a1 Signed-off-by: Stephen Kitt --- library/impl/pom.xml | 4 ++++ .../ovsdb/lib/impl/OvsdbConnectionService.java | 17 +++++++---------- .../resources/OSGI-INF/blueprint/library.xml | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/library/impl/pom.xml b/library/impl/pom.xml index 02f25e841..1ba80531e 100644 --- a/library/impl/pom.xml +++ b/library/impl/pom.xml @@ -68,6 +68,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html aaa-cert 0.9.0-SNAPSHOT + + javax.inject + javax.inject + diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java index 7e12a4ee7..ed502369c 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java @@ -49,6 +49,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; +import javax.inject.Inject; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -107,7 +108,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection { private static final Map CONNECTIONS = new ConcurrentHashMap<>(); private volatile boolean useSSL = false; - private volatile ICertificateManager certManagerSrv; + private final ICertificateManager certManagerSrv; private volatile int jsonRpcDecoderMaxFrameLength = 100000; private volatile Channel serverChannel; @@ -116,6 +117,11 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection { private volatile String listenerIp = "0.0.0.0"; private volatile int listenerPort = 6640; + @Inject + public OvsdbConnectionService(ICertificateManager certManagerSrv) { + this.certManagerSrv = certManagerSrv; + } + /** * If the SSL flag is enabled, the method internally will establish TLS communication using the default * ODL certificateManager SSLContext and attributes. @@ -554,15 +560,6 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection { useSSL = flag; } - /** - * Set default Certificate manager service. - * - * @param certificateManagerSrv reference - */ - public void setCertificatManager(ICertificateManager certificateManagerSrv) { - certManagerSrv = certificateManagerSrv; - } - /** * Blueprint property setter method. Blueprint call this method and set the value of json rpc decoder * max frame length to the value configured for config option (json-rpc-decoder-max-frame-length) in diff --git a/library/impl/src/main/resources/OSGI-INF/blueprint/library.xml b/library/impl/src/main/resources/OSGI-INF/blueprint/library.xml index 40073a087..5eaf9f033 100644 --- a/library/impl/src/main/resources/OSGI-INF/blueprint/library.xml +++ b/library/impl/src/main/resources/OSGI-INF/blueprint/library.xml @@ -24,6 +24,7 @@ + @@ -31,7 +32,6 @@ - -- 2.36.6