Remove OSGiBaseNetconfSchemas 60/102760/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 19 Oct 2022 11:47:15 +0000 (13:47 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 19 Oct 2022 11:47:15 +0000 (13:47 +0200)
We have constructor injection and therefore can easily reuse
DefaultBaseNetconfSchemas in OSGi environment as well.

Change-Id: I1677a9d208990eb60a74349f8b9fae921ac33096
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/DefaultBaseNetconfSchemas.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/OSGiBaseNetconfSchemas.java [deleted file]

index ea9100b81d8ce6b9879ca7264f4df4929e64125b..a91f40728f6fff229fcbeb081586d1eeafca8e3b 100644 (file)
@@ -16,26 +16,31 @@ import org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
 
 @Beta
+@Component
 @Singleton
 public final class DefaultBaseNetconfSchemas implements BaseNetconfSchemas {
     private final @NonNull BaseSchema withoutNotifications;
     private final @NonNull BaseSchema withNotifications;
 
     @Inject
-    public DefaultBaseNetconfSchemas(final YangParserFactory parserFactory) throws YangParserException {
+    @Activate
+    public DefaultBaseNetconfSchemas(@Reference final YangParserFactory parserFactory) throws YangParserException {
         withoutNotifications = new BaseSchema(withoutNotifications(parserFactory));
         withNotifications = new BaseSchema(withNotifications(parserFactory));
     }
 
     @Override
-    public @NonNull BaseSchema getBaseSchema() {
+    public BaseSchema getBaseSchema() {
         return withoutNotifications;
     }
 
     @Override
-    public @NonNull BaseSchema getBaseSchemaWithNotifications() {
+    public BaseSchema getBaseSchemaWithNotifications() {
         return withNotifications;
     }
 
diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/OSGiBaseNetconfSchemas.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/OSGiBaseNetconfSchemas.java
deleted file mode 100644 (file)
index ac1ace9..0000000
+++ /dev/null
@@ -1,51 +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.netconf.sal.connect.netconf.schema.mapping;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.parser.api.YangParserException;
-import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
-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)
-public final class OSGiBaseNetconfSchemas implements BaseNetconfSchemas {
-    private static final Logger LOG = LoggerFactory.getLogger(OSGiBaseNetconfSchemas.class);
-
-    @Reference
-    YangParserFactory parserFactory;
-
-    private DefaultBaseNetconfSchemas delegate;
-
-    @Override
-    public BaseSchema getBaseSchema() {
-        return delegate.getBaseSchema();
-    }
-
-    @Override
-    public BaseSchema getBaseSchemaWithNotifications() {
-        return delegate.getBaseSchemaWithNotifications();
-    }
-
-    @Activate
-    void activate() throws YangParserException {
-        delegate = new DefaultBaseNetconfSchemas(parserFactory);
-        LOG.info("Base NETCONF Schemas started");
-    }
-
-    @Deactivate
-    void deactivate() {
-        delegate = null;
-        LOG.info("Base NETCONF Schemas stopped");
-    }
-}