Use on-demand component activation 94/101294/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 May 2022 14:53:23 +0000 (16:53 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 25 May 2022 14:53:23 +0000 (16:53 +0200)
SCR provides for a way to activate components on-demand, so they end up
being dormant when not used. Take advantage of this and also lower the
amount of logging we perform during activation/deactivation.

Change-Id: I3bbdc6bf1d6e20b7e9440f3e3c62b075aa826bbc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/di/InMemoryDataTreeFactory.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/DefaultYangParserFactory.java
xpath/yang-xpath-impl/src/main/java/org/opendaylight/yangtools/yang/xpath/impl/AntlrXPathParserFactory.java
xpath/yang-xpath-impl/src/main/java/org/opendaylight/yangtools/yang/xpath/impl/package-info.java

index f7294d70ab89e54c86955779c75ecc6bc0c1072b..f6d6efb4928f37bfa07489ad2bee87134622ed5e 100644 (file)
@@ -50,9 +50,9 @@ import org.slf4j.LoggerFactory;
 /**
  * A factory for creating in-memory data trees.
  */
-@MetaInfServices
 @Singleton
-@Component(immediate = true)
+@Component
+@MetaInfServices
 @RequireServiceComponentRuntime
 public final class InMemoryDataTreeFactory implements DataTreeFactory {
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeFactory.class);
@@ -94,13 +94,13 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
     @Activate
     @SuppressWarnings("static-method")
     void activate() {
-        LOG.info("In-memory Data Tree activated");
+        LOG.debug("In-memory Data Tree activated");
     }
 
     @Deactivate
     @SuppressWarnings("static-method")
     void deactivate() {
-        LOG.info("In-memory Data Tree deactivated");
+        LOG.debug("In-memory Data Tree deactivated");
     }
 
     private static @NonNull DataTree createDataTree(final DataTreeConfiguration treeConfig,
index 7ad3b32c609c1e3436491ae79c9448aee9bf5d34..ce08692d5819bc527ab8a50e402a9d6fa07e13e1 100644 (file)
@@ -28,14 +28,16 @@ import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
 
 /**
  * Reference {@link YangParserFactory} implementation.
  */
 @Beta
-@MetaInfServices
+@Component
 @Singleton
-@Component(immediate = true)
+@MetaInfServices
+@RequireServiceComponentRuntime
 public final class DefaultYangParserFactory implements YangParserFactory {
     private static final List<ImportResolutionMode> SUPPORTED_MODES = List.of(ImportResolutionMode.DEFAULT);
 
index 249f14d806287e3cae38ac20b875f92b82890c51..895a36dd689624d628657dc6f72a571ad76eae41 100644 (file)
@@ -18,11 +18,13 @@ import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
 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.RequireServiceComponentRuntime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Component
 @MetaInfServices
-@Component(immediate = true)
+@RequireServiceComponentRuntime
 public final class AntlrXPathParserFactory implements YangXPathParserFactory {
     private static final Logger LOG = LoggerFactory.getLogger(AntlrXPathParserFactory.class);
 
@@ -45,12 +47,12 @@ public final class AntlrXPathParserFactory implements YangXPathParserFactory {
     @Activate
     @SuppressWarnings("static-method")
     void activate() {
-        LOG.info("XPath Parser activated");
+        LOG.debug("XPath Parser activated");
     }
 
     @Deactivate
     @SuppressWarnings("static-method")
     void deactivate() {
-        LOG.info("XPath Parser deactivated");
+        LOG.debug("XPath Parser deactivated");
     }
 }
index 7ba94d61cb8e1fea89aa06065fa02f2f0e733790..e3656754c33ee3673c816a62f274e8f8720349bb 100644 (file)
@@ -10,8 +10,6 @@
  * on the XPath grammar from <a href="https://github.com/antlr/grammars-v4/blob/master/xpath/xpath.g4">grammars-v4</a>.
  */
 @NonNullByDefault
-@RequireServiceComponentRuntime
 package org.opendaylight.yangtools.yang.xpath.impl;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.osgi.service.component.annotations.RequireServiceComponentRuntime;
\ No newline at end of file