Convert mdsal-binding-runtime-osgi to a JPMS module 02/106502/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 16 Jun 2023 09:57:12 +0000 (11:57 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 16 Jun 2023 09:57:59 +0000 (11:57 +0200)
Ditch Automatic-Module-Name and instead provide a proper module.

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

index 38a6b71e1a4531c1c42fcf8eaef975b1615d4b49..c2dad73aa3eb9519fa2ee6708ca3618b260988b6 100644 (file)
     <packaging>bundle</packaging>
 
     <dependencies>
+        <dependency>
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-annotations</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-model-api</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-spi</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <configuration>
-                    <instructions>
-                        <Automatic-Module-Name>org.opendaylight.mdsal.binding.runtime.osgi</Automatic-Module-Name>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
diff --git a/binding/mdsal-binding-runtime-osgi/src/main/java/module-info.java b/binding/mdsal-binding-runtime-osgi/src/main/java/module-info.java
new file mode 100644 (file)
index 0000000..fd6aba7
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2023 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.runtime.osgi {
+    exports org.opendaylight.mdsal.binding.runtime.osgi;
+
+    requires transitive org.opendaylight.mdsal.dom.schema.osgi;
+
+    requires com.google.common;
+    requires org.opendaylight.mdsal.binding.runtime.api;
+    requires org.opendaylight.mdsal.binding.runtime.spi;
+    requires org.osgi.framework;
+    requires org.osgi.service.component;
+    requires org.slf4j;
+
+    // Annotations
+    requires static com.github.spotbugs.annotations;
+    requires static org.checkerframework.checker.qual;
+    requires static org.eclipse.jdt.annotation;
+    requires static org.osgi.service.component.annotations;
+}
index 46f7d2e9248b7ba5f23d3d1a690fe9f43a92ae97..551efb3c44e24a9c7320a8debe1e4e650ee7ba75 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.mdsal.binding.runtime.osgi.impl;
 
 import static com.google.common.base.Verify.verifyNotNull;
 
-import com.google.common.annotations.Beta;
 import com.google.common.primitives.UnsignedLong;
 import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.mdsal.binding.runtime.osgi.OSGiBindingRuntimeContext;
@@ -24,29 +23,25 @@ import org.slf4j.LoggerFactory;
 /**
  * A global {@link BindingRuntimeContext}. It is injected with latest {@link OSGiBindingRuntimeContext} generation.
  */
-@Beta
 @Component(service = BindingRuntimeContext.class, immediate = true)
 public final class GlobalBindingRuntimeContext extends ForwardingBindingRuntimeContext {
     private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRuntimeContext.class);
 
-    @Reference
-    OSGiBindingRuntimeContext osgi = null;
-
+    private final UnsignedLong generation;
     private BindingRuntimeContext delegate;
-    private UnsignedLong generation;
-
-    @Override
-    protected BindingRuntimeContext delegate() {
-        return verifyNotNull(delegate);
-    }
 
     @Activate
-    void activate() {
+    public GlobalBindingRuntimeContext(@Reference final OSGiBindingRuntimeContext osgi) {
         generation = osgi.getGeneration();
         delegate = osgi.getService();
         LOG.info("Global BindingRuntimeContext generation {} activated", generation);
     }
 
+    @Override
+    protected BindingRuntimeContext delegate() {
+        return verifyNotNull(delegate);
+    }
+
     @Deactivate
     void deactivate() {
         delegate = null;