Convert DOMSchemaServiceImpl into a component 47/88147/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 29 Feb 2020 09:43:46 +0000 (10:43 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 29 Feb 2020 09:43:55 +0000 (10:43 +0100)
This is a trivial service which has no dependencies, promote it
to a component and remove it from blueprint.

JIRA: MDSAL-521
Change-Id: Ia6f0feb0ad1324e4a57cac476167dfbe4e07eade
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-broker/pom.xml
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java
dom/mdsal-dom-broker/src/main/resources/org/opendaylight/blueprint/dom-broker.xml

index aacf4019648cff15823cad89faf1e230f1f774e2..7c44669306c2936635d46331281ad07993e6bbe0 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-model-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.kohsuke.metainf-services</groupId>
+            <artifactId>metainf-services</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
index cf15687b509f5f3007568e0369e5c804ad893584..6f673cf4606cb12317f999575b02b4feeaa4041e 100644 (file)
@@ -5,7 +5,6 @@
  * 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.dom.broker;
 
 import static com.google.common.base.Preconditions.checkState;
@@ -16,6 +15,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import javax.inject.Singleton;
+import org.kohsuke.MetaInfServices;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMMountPointListener;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
@@ -27,10 +28,16 @@ import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.util.ListenerRegistry;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DOMMountPointServiceImpl implements DOMMountPointService {
+@Component(immediate = true)
+@MetaInfServices
+@Singleton
+public final class DOMMountPointServiceImpl implements DOMMountPointService {
     private static final Logger LOG = LoggerFactory.getLogger(DOMMountPointServiceImpl.class);
 
     private final Map<YangInstanceIdentifier, DOMMountPoint> mountPoints = new HashMap<>();
@@ -53,6 +60,18 @@ public class DOMMountPointServiceImpl implements DOMMountPointService {
         return listeners.register(listener);
     }
 
+    @Activate
+    @SuppressWarnings("static-method")
+    void activate() {
+        LOG.info("DOMMountPointService activated");
+    }
+
+    @Deactivate
+    @SuppressWarnings("static-method")
+    void deactivate() {
+        LOG.info("DOMMountPointService deactivated");
+    }
+
     @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
             justification = "https://github.com/spotbugs/spotbugs/issues/811")
     @SuppressWarnings("checkstyle:IllegalCatch")
@@ -70,7 +89,7 @@ public class DOMMountPointServiceImpl implements DOMMountPointService {
             }
         });
 
-        return new AbstractObjectRegistration<DOMMountPoint>(mountPoint) {
+        return new AbstractObjectRegistration<>(mountPoint) {
             @Override
             protected void removeRegistration() {
                 unregisterMountPoint(getInstance().getIdentifier());
index 6b868d0abfcfbf7e9a511616c475a404a8e661cb..1451e27a42b9bd9d123540ed1cc6efbceaa98b9f 100644 (file)
       <value>org.opendaylight.mdsal.dom.api.DOMActionProviderService</value>
     </interfaces>
   </service>
-
-  <!-- DOM MountPoint Service -->
-
-  <bean id="domMountPointService" class="org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl"/>
-
-  <service ref="domMountPointService" interface="org.opendaylight.mdsal.dom.api.DOMMountPointService"
-        odl:type="default"/>
-
 </blueprint>