Convert mdsal-binding-dom-codec-osgi to a JPMS module 61/100661/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Apr 2022 05:13:58 +0000 (07:13 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Apr 2022 05:14:37 +0000 (07:14 +0200)
This is a simple implementation, convert it to JPMS module, fixing up
warnings in the process of doing so.

JIRA: MDSAL-641
Change-Id: I03f71512580ae9c6b48d5acd0d0c6e77a02f3e82
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec-osgi/pom.xml
binding/mdsal-binding-dom-codec-osgi/src/main/java/module-info.java [new file with mode: 0644]
binding/mdsal-binding-dom-codec-osgi/src/main/java/org/opendaylight/mdsal/binding/dom/codec/osgi/impl/OSGiBindingDOMCodec.java

index 5f157eb2910dac4530847097f3403a7d526c2c09..abf540296ae63ab3c720c4e7d349c5890f6330bd 100644 (file)
     <packaging>bundle</packaging>
 
     <dependencies>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-dom-codec-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-dom-codec-spi</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-runtime-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-runtime-osgi</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-dom-schema-osgi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.framework</artifactId>
@@ -63,7 +87,6 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Automatic-Module-Name>org.opendaylight.mdsal.binding.dom.codec.osgi</Automatic-Module-Name>
                         <!-- Karaf cannot handle Factory Component requirements, see https://issues.apache.org/jira/browse/KARAF-6625 -->
                         <_dsannotations-options>norequirements</_dsannotations-options>
                     </instructions>
diff --git a/binding/mdsal-binding-dom-codec-osgi/src/main/java/module-info.java b/binding/mdsal-binding-dom-codec-osgi/src/main/java/module-info.java
new file mode 100644 (file)
index 0000000..b30d3c9
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2022 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
+ */
+module org.opendaylight.mdsal.binding.dom.codec.osgi {
+    exports org.opendaylight.mdsal.binding.dom.codec.osgi;
+
+    requires transitive org.opendaylight.mdsal.dom.schema.osgi;
+    requires org.opendaylight.mdsal.binding.dom.codec.api;
+    requires org.opendaylight.mdsal.binding.dom.codec.spi;
+    requires org.opendaylight.mdsal.binding.runtime.osgi;
+    requires org.opendaylight.yangtools.yang.binding;
+    requires org.opendaylight.yangtools.yang.data.api;
+    requires org.osgi.framework;
+    requires org.osgi.service.component;
+    requires org.slf4j;
+
+    // Annotations
+    requires static org.checkerframework.checker.qual;
+    requires static org.gaul.modernizer_maven_annotations;
+    requires static org.osgi.service.component.annotations;
+}
index 7dbfacc19a9a4deb144b1de07666c224392b0544..2c11ff784830c6b1197994797b83a78bc0556549 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Map;
 import java.util.Set;
 import org.checkerframework.checker.lock.qual.GuardedBy;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.binding.dom.codec.osgi.OSGiBindingDOMCodecServices;
 import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.mdsal.binding.runtime.osgi.OSGiBindingRuntimeContext;
@@ -40,7 +41,8 @@ public final class OSGiBindingDOMCodec {
 
         abstract void remove(OSGiBindingRuntimeContext runtimeContext);
 
-        abstract @NonNull AbstractInstances toActive(BindingDOMCodecFactory codecFactory, ComponentFactory factory);
+        abstract @NonNull AbstractInstances toActive(BindingDOMCodecFactory codecFactory,
+            ComponentFactory<OSGiBindingDOMCodecServices> factory);
 
         abstract @NonNull AbstractInstances toInactive();
     }
@@ -67,7 +69,8 @@ public final class OSGiBindingDOMCodec {
         }
 
         @Override
-        AbstractInstances toActive(final BindingDOMCodecFactory codecFactory, final ComponentFactory factory) {
+        AbstractInstances toActive(final BindingDOMCodecFactory codecFactory,
+                final ComponentFactory<OSGiBindingDOMCodecServices> factory) {
             final ActiveInstances active = new ActiveInstances(codecFactory, factory);
             instances.stream()
                 .sorted(Comparator.comparing(OSGiBindingRuntimeContext::getGeneration).reversed())
@@ -82,11 +85,13 @@ public final class OSGiBindingDOMCodec {
     }
 
     private static final class ActiveInstances extends AbstractInstances {
-        private final Map<OSGiBindingRuntimeContext, ComponentInstance> instances = new IdentityHashMap<>();
+        private final Map<OSGiBindingRuntimeContext, ComponentInstance<OSGiBindingDOMCodecServices>> instances =
+            new IdentityHashMap<>();
+        private final ComponentFactory<OSGiBindingDOMCodecServices> factory;
         private final BindingDOMCodecFactory codecFactory;
-        private final ComponentFactory factory;
 
-        ActiveInstances(final BindingDOMCodecFactory codecFactory, final ComponentFactory factory) {
+        ActiveInstances(final BindingDOMCodecFactory codecFactory,
+                final ComponentFactory<OSGiBindingDOMCodecServices> factory) {
             this.codecFactory = requireNonNull(codecFactory);
             this.factory = requireNonNull(factory);
         }
@@ -102,7 +107,7 @@ public final class OSGiBindingDOMCodec {
 
         @Override
         void remove(final OSGiBindingRuntimeContext runtimeContext) {
-            final ComponentInstance instance = instances.remove(runtimeContext);
+            final ComponentInstance<OSGiBindingDOMCodecServices> instance = instances.remove(runtimeContext);
             if (instance != null) {
                 instance.dispose();
             } else {
@@ -112,7 +117,7 @@ public final class OSGiBindingDOMCodec {
 
         @Override
         AbstractInstances toActive(final BindingDOMCodecFactory ignoreCodecFactory,
-                final ComponentFactory ignoreFactory) {
+                final ComponentFactory<OSGiBindingDOMCodecServices> ignoreFactory) {
             throw new IllegalStateException("Attempted to activate active instances");
         }
 
@@ -130,7 +135,7 @@ public final class OSGiBindingDOMCodec {
     BindingDOMCodecFactory codecFactory = null;
 
     @Reference(target = "(component.factory=" + OSGiBindingDOMCodecServicesImpl.FACTORY_NAME + ")")
-    ComponentFactory contextFactory = null;
+    ComponentFactory<OSGiBindingDOMCodecServices> contextFactory = null;
 
     @GuardedBy("this")
     private AbstractInstances instances = new InactiveInstances();