You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by tj...@apache.org on 2020/03/20 15:30:13 UTC

[felix-atomos] branch master updated (53ed72c -> 83ad9a6)

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

tjwatson pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/felix-atomos.git.


    from 53ed72c  Update README to point to the OSGi Core draft spec
     new 20c8e81  Add option to report resolution errors
     new 83ad9a6  Handle the persistence issues when changing to Java 8

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../impl/runtime/base/AtomosRuntimeBase.java       | 41 +++++++++++++++++++++-
 .../atomos/impl/runtime/base/AtomosStorage.java    |  6 ++++
 .../apache/felix/atomos/launch/AtomosLauncher.java |  4 +++
 3 files changed, 50 insertions(+), 1 deletion(-)


[felix-atomos] 02/02: Handle the persistence issues when changing to Java 8

Posted by tj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 83ad9a621c412ac3888cacf6b79a239a2ed122a0
Author: Thomas Watson <tj...@us.ibm.com>
AuthorDate: Fri Mar 20 10:18:59 2020 -0500

    Handle the persistence issues when changing to Java 8
    
    When running with Java 11 or higher with the module path
    the persistence for Atomos will contain at least 2 layers,
    the empty and the boot layer. This causes issues if you the
    launch the persistent configuration using Java 8 because
    Atomos will only allow a single layer to exist in
    that case.
    
    This handles that case by printing a message and
    continuing on as if there was no persistence
---
 .../org/apache/felix/atomos/impl/runtime/base/AtomosStorage.java    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosStorage.java b/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosStorage.java
index e59415b..a27cd82 100644
--- a/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosStorage.java
+++ b/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosStorage.java
@@ -64,6 +64,12 @@ public class AtomosStorage
             }
             long nextLayerId = in.readLong();
             int numLayers = in.readInt();
+            if (numLayers > 1 && !atomosRuntime.getBootLayer().isAddLayerSupported())
+            {
+                System.out.println(
+                    "Atomos persistent layers are ignored because Atomos is not loaded as a module.");
+                return;
+            }
             for (int i = 0; i < numLayers; i++)
             {
                 readLayer(in);


[felix-atomos] 01/02: Add option to report resolution errors

Posted by tj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 20c8e812da031c2aa72bc42ef008f1f116ef31f1
Author: Thomas Watson <tj...@us.ibm.com>
AuthorDate: Fri Mar 20 10:06:50 2020 -0500

    Add option to report resolution errors
    
    For the AtomosLauncher this option is
    enabled by default to ease error detection
    by default
---
 .../impl/runtime/base/AtomosRuntimeBase.java       | 41 +++++++++++++++++++++-
 .../apache/felix/atomos/launch/AtomosLauncher.java |  4 +++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosRuntimeBase.java b/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosRuntimeBase.java
index 79190e4..70699d8 100644
--- a/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosRuntimeBase.java
+++ b/atomos.runtime/src/main/java/org/apache/felix/atomos/impl/runtime/base/AtomosRuntimeBase.java
@@ -60,6 +60,8 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.framework.Version;
@@ -69,6 +71,7 @@ import org.osgi.framework.connect.FrameworkUtilHelper;
 import org.osgi.framework.connect.ModuleConnector;
 import org.osgi.framework.hooks.bundle.CollisionHook;
 import org.osgi.framework.hooks.resolver.ResolverHookFactory;
+import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.framework.namespace.PackageNamespace;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRevision;
@@ -76,11 +79,13 @@ import org.osgi.framework.wiring.FrameworkWiring;
 
 import sun.misc.Signal;
 
-public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBundleListener, FrameworkUtilHelper
+public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBundleListener, FrameworkUtilHelper, FrameworkListener
 {
     static final String JAR_PROTOCOL = "jar";
     static final String FILE_PROTOCOL = "file";
     public static final String ATOMOS_PROP_PREFIX = "atomos.";
+    public static final String ATOMOS_REPORT_RESOLUTION_PROP = ATOMOS_PROP_PREFIX
+        + "enable.resolution.errors";
     public static final String ATOMOS_DEBUG_PROP = ATOMOS_PROP_PREFIX + "enable.debug";
     public static final String ATOMOS_INDEX_PATH_PROP = ATOMOS_PROP_PREFIX + "index.path";
     public static final String ATOMOS_IGNORE_INDEX = "IGNORE";
@@ -94,6 +99,7 @@ public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBun
     public static final String GRAAL_NATIVE_IMAGE_KIND = "org.graalvm.nativeimage.kind";
 
     private final boolean DEBUG;
+    private final boolean REPORT_RESOLUTION_ERRORS;
     private final String indexPath;
 
     private final AtomicReference<BundleContext> context = new AtomicReference<>();
@@ -181,6 +187,8 @@ public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBun
     {
         saveConfig(config);
         DEBUG = Boolean.parseBoolean(this.config.get(ATOMOS_DEBUG_PROP));
+        REPORT_RESOLUTION_ERRORS = Boolean.parseBoolean(
+            this.config.get(ATOMOS_REPORT_RESOLUTION_PROP));
         indexPath = getIndexPath(this.config.get(ATOMOS_INDEX_PATH_PROP));
 
         try
@@ -550,6 +558,35 @@ public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBun
         }
     }
 
+    @Override
+    public void frameworkEvent(FrameworkEvent event)
+    {
+        if (REPORT_RESOLUTION_ERRORS && event.getType() == FrameworkEvent.ERROR)
+        {
+            if (event.getThrowable() instanceof BundleException
+                && ((BundleException) event.getThrowable()).getType() == BundleException.RESOLVE_ERROR)
+            {
+                Bundle b = event.getBundle();
+                BundleRevision rev = b == null ? null : b.adapt(BundleRevision.class);
+                if (rev != null)
+                {
+                    rev.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).forEach(
+                        i -> {
+                            @SuppressWarnings("unchecked")
+                            List<String> tags = (List<String>) i.getAttributes().get(
+                                IdentityNamespace.CAPABILITY_TAGS_ATTRIBUTE);
+                            if (tags != null
+                                && tags.contains(ConnectContent.TAG_OSGI_CONNECT))
+                            {
+                                System.out.println("Unable to resolve connected bundle: "
+                                    + event.getThrowable().getMessage());
+                            }
+                        });
+                }
+            }
+        }
+    }
+
     protected final void addAtomosLayer(AtomosLayerBase atomosLayer)
     {
         addingLayer(atomosLayer);
@@ -1450,6 +1487,7 @@ public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBun
         AtomosFrameworkUtilHelper.addHelper(this);
 
         bc.addBundleListener(this);
+        bc.addFrameworkListener(this);
         for (Bundle b : bc.getBundles())
         {
             addPackages(b);
@@ -1533,6 +1571,7 @@ public abstract class AtomosRuntimeBase implements AtomosRuntime, SynchronousBun
         }
 
         bc.removeBundleListener(this);
+        bc.removeFrameworkListener(this);
 
         AtomosFrameworkUtilHelper.removeHelper(this);
         atomosCommandsReg.unregister();
diff --git a/atomos.runtime/src/main/java/org/apache/felix/atomos/launch/AtomosLauncher.java b/atomos.runtime/src/main/java/org/apache/felix/atomos/launch/AtomosLauncher.java
index 6862ed3..e3f3204 100644
--- a/atomos.runtime/src/main/java/org/apache/felix/atomos/launch/AtomosLauncher.java
+++ b/atomos.runtime/src/main/java/org/apache/felix/atomos/launch/AtomosLauncher.java
@@ -77,6 +77,10 @@ public class AtomosLauncher
     public static Framework launch(Map<String, String> frameworkConfig)
         throws BundleException
     {
+        frameworkConfig = new HashMap<>(frameworkConfig);
+        // default to reporting resolution issues from launcher
+        frameworkConfig.putIfAbsent(AtomosRuntimeBase.ATOMOS_REPORT_RESOLUTION_PROP,
+            "true");
         AtomosRuntime atomosRuntime = AtomosRuntime.newAtomosRuntime(frameworkConfig);
         if (atomosRuntime.getBootLayer().isAddLayerSupported())
         {