You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2020/06/03 17:51:52 UTC

[felix-dev] branch master updated: FELIX-6282: Added core R7 dependency in pom. Exports R7 api to allow to resolve the connect bundle from an OBR. Avoid NPE when adapting system bundle to FrameworkWiringDTO. (#24)

This is an automated email from the ASF dual-hosted git repository.

pderop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new 470750c  FELIX-6282: Added core R7 dependency in pom. Exports R7 api to allow to resolve the connect bundle from an OBR. Avoid NPE when adapting system bundle to FrameworkWiringDTO. (#24)
470750c is described below

commit 470750cbb399e2d1c79ee6d91db809ad7a1ab477
Author: pderop <pi...@gmail.com>
AuthorDate: Wed Jun 3 19:51:42 2020 +0200

    FELIX-6282: Added core R7 dependency in pom. Exports R7 api to allow to resolve the connect bundle from an OBR. Avoid NPE when adapting system bundle to FrameworkWiringDTO. (#24)
---
 connect/pom.xml                                    | 14 ++++----------
 .../felix/connect/felix/framework/DTOFactory.java  | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/connect/pom.xml b/connect/pom.xml
index f6f6b4c..8cbf5d0 100644
--- a/connect/pom.xml
+++ b/connect/pom.xml
@@ -58,13 +58,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>osgi.core</artifactId>
-            <version>6.0.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>5.0.0</version>
+            <version>7.0.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -169,7 +163,7 @@
                         <Bundle-SymbolicName>org.apache.felix.connect</Bundle-SymbolicName>
                         <Bundle-Name>Pojo Service Registry</Bundle-Name>
                         <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
-                        <Private-Package>
+                        <Export-Package>
                             org.osgi.framework.*,
                             org.osgi.resource,
                             org.osgi.dto,
@@ -178,8 +172,8 @@
                             org.osgi.service.packageadmin,
                             org.osgi.service.startlevel,
                             org.osgi.util.tracker,
-                            org.apache.felix.connect.*
-                        </Private-Package>
+                            org.apache.felix.connect.*;version=${project.version}
+                        </Export-Package>
                         <Import-Package>!*</Import-Package>
                         <Include-Resource>
                             META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES,{src/main/resources/}
diff --git a/connect/src/main/java/org/apache/felix/connect/felix/framework/DTOFactory.java b/connect/src/main/java/org/apache/felix/connect/felix/framework/DTOFactory.java
index 2b5e739..2ff406a 100644
--- a/connect/src/main/java/org/apache/felix/connect/felix/framework/DTOFactory.java
+++ b/connect/src/main/java/org/apache/felix/connect/felix/framework/DTOFactory.java
@@ -41,6 +41,7 @@ import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.framework.wiring.dto.BundleRevisionDTO;
 import org.osgi.framework.wiring.dto.BundleWireDTO;
 import org.osgi.framework.wiring.dto.BundleWiringDTO;
+import org.osgi.framework.wiring.dto.FrameworkWiringDTO;
 import org.osgi.framework.wiring.dto.BundleWiringDTO.NodeDTO;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
@@ -113,6 +114,10 @@ public class DTOFactory
         {
             return type.cast(createFrameworkStartLevelDTO((Framework) bundle));
         }
+        else if (type == FrameworkWiringDTO.class)
+        {
+            return type.cast(createFrameworkWiringDTO(bundle));
+        }
         return null;
     }
 
@@ -399,6 +404,23 @@ public class DTOFactory
         return dto;
     }
 
+    private static FrameworkWiringDTO createFrameworkWiringDTO(Bundle framework)
+    {
+        FrameworkWiringDTO dto = new FrameworkWiringDTO();
+
+        dto.resources = new HashSet<BundleRevisionDTO>();
+        dto.wirings = new HashSet<NodeDTO>();
+
+        Set<Bundle> bundles = new LinkedHashSet<Bundle>(Arrays.asList(framework.getBundleContext().getBundles()));
+
+        for (Bundle bundle : bundles)
+        {
+            addBundleWiring(bundle, dto.resources, dto.wirings);
+        }
+
+        return dto;
+    }
+
     private static void addBundleWiring(Bundle bundle, Set<BundleRevisionDTO> resources, Set<NodeDTO> wirings)
     {
         BundleRevisions brs = bundle.adapt(BundleRevisions.class);