Remove OSGiBindingAdapterFactory 10/94210/9
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 11 Dec 2020 10:57:27 +0000 (11:57 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 21 Sep 2021 23:35:57 +0000 (23:35 +0000)
We have constructor injection, hence we do not need a separate
OSGi class for BindingAdapterFactory.

Change-Id: I41eeec3112bc8e745cd3b2db9012f28f57746625
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/AbstractAdapterFactory.java [deleted file]
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingAdapterFactory.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/OSGiBindingAdapterFactory.java [deleted file]

diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/AbstractAdapterFactory.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/AbstractAdapterFactory.java
deleted file mode 100644 (file)
index 8b22f97..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.adapter;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.ActionProviderService;
-import org.opendaylight.mdsal.binding.api.ActionService;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.MountPointService;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
-import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
-import org.opendaylight.mdsal.dom.api.DOMActionService;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMMountPointService;
-import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
-
-abstract class AbstractAdapterFactory implements AdapterFactory {
-    @Override
-    public final DataBroker createDataBroker(final DOMDataBroker domService) {
-        return new BindingDOMDataBrokerAdapter(context(), domService);
-    }
-
-    @Override
-    public final MountPointService createMountPointService(final DOMMountPointService domService) {
-        return new BindingDOMMountPointServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final NotificationService createNotificationService(final DOMNotificationService domService) {
-        return new BindingDOMNotificationServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final NotificationPublishService createNotificationPublishService(
-            final DOMNotificationPublishService domService) {
-        return new BindingDOMNotificationPublishServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final RpcConsumerRegistry createRpcConsumerRegistry(final DOMRpcService domService) {
-        return new BindingDOMRpcServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final RpcProviderService createRpcProviderService(final DOMRpcProviderService domService) {
-        return new BindingDOMRpcProviderServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final ActionService createActionService(final DOMActionService domService) {
-        return new ActionServiceAdapter(context(), domService);
-    }
-
-    @Override
-    public final ActionProviderService createActionProviderService(final DOMActionProviderService domService) {
-        return new ActionProviderServiceAdapter(context(), domService);
-    }
-
-    abstract @NonNull AdapterContext context();
-}
index be127044093970b892a19685da25d569de27aa36..ed85afbab7091a059f2e8363ee11aa9202bba80e 100644 (file)
@@ -15,8 +15,27 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.kohsuke.MetaInfServices;
+import org.opendaylight.mdsal.binding.api.ActionProviderService;
+import org.opendaylight.mdsal.binding.api.ActionService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
+import org.opendaylight.mdsal.dom.api.DOMActionProviderService;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.yangtools.concepts.Immutable;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
 
 /**
  * Implementation of AdapterFactory.
@@ -24,10 +43,11 @@ import org.opendaylight.yangtools.concepts.Immutable;
  * @author Robert Varga
  */
 @Beta
+@Component(immediate = true, service = AdapterFactory.class)
 @MetaInfServices(value = AdapterFactory.class)
 @NonNullByDefault
 @Singleton
-public final class BindingAdapterFactory extends AbstractAdapterFactory implements Immutable {
+public final class BindingAdapterFactory implements AdapterFactory, Immutable {
     private final AdapterContext codec;
 
     public BindingAdapterFactory() {
@@ -36,12 +56,49 @@ public final class BindingAdapterFactory extends AbstractAdapterFactory implemen
     }
 
     @Inject
-    public BindingAdapterFactory(final AdapterContext codec) {
+    @Activate
+    public BindingAdapterFactory(@Reference final AdapterContext codec) {
         this.codec = requireNonNull(codec);
     }
 
     @Override
-    AdapterContext context() {
-        return codec;
+    public DataBroker createDataBroker(final DOMDataBroker domService) {
+        return new BindingDOMDataBrokerAdapter(codec, domService);
+    }
+
+    @Override
+    public MountPointService createMountPointService(final DOMMountPointService domService) {
+        return new BindingDOMMountPointServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public NotificationService createNotificationService(final DOMNotificationService domService) {
+        return new BindingDOMNotificationServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public NotificationPublishService createNotificationPublishService(
+            final DOMNotificationPublishService domService) {
+        return new BindingDOMNotificationPublishServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public RpcConsumerRegistry createRpcConsumerRegistry(final DOMRpcService domService) {
+        return new BindingDOMRpcServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public RpcProviderService createRpcProviderService(final DOMRpcProviderService domService) {
+        return new BindingDOMRpcProviderServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public ActionService createActionService(final DOMActionService domService) {
+        return new ActionServiceAdapter(codec, domService);
+    }
+
+    @Override
+    public ActionProviderService createActionProviderService(final DOMActionProviderService domService) {
+        return new ActionProviderServiceAdapter(codec, domService);
     }
 }
diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/OSGiBindingAdapterFactory.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/OSGiBindingAdapterFactory.java
deleted file mode 100644 (file)
index 998d427..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.adapter;
-
-import static com.google.common.base.Verify.verifyNotNull;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Beta
-@Component(immediate = true, service = AdapterFactory.class)
-// TODO: once we have constructor injection, unify this with BindingAdapterFactory
-public final class OSGiBindingAdapterFactory extends AbstractAdapterFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(OSGiBindingAdapterFactory.class);
-
-    @Reference
-    AdapterContext codec = null;
-
-    @Override
-    AdapterContext context() {
-        return verifyNotNull(codec);
-    }
-
-    @Activate
-    @SuppressWarnings("static-method")
-    void activate() {
-        LOG.info("Binding Adapter Factory activated");
-    }
-
-    @Deactivate
-    @SuppressWarnings("static-method")
-    void deactivate() {
-        LOG.info("Binding Adapter Factory deactivated");
-    }
-}