karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-5205] Add refresh option to bundle:update and update MBean operation
Date Fri, 16 Jun 2017 13:03:48 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 16ed4bde7 -> 99a8b8d08


[KARAF-5205] Add refresh option to bundle:update and update MBean operation


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/99a8b8d0
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/99a8b8d0
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/99a8b8d0

Branch: refs/heads/karaf-4.0.x
Commit: 99a8b8d0802d1d8bd6c8260e51f228d7e7ebcbc7
Parents: 16ed4bd
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Fri Jun 16 14:38:47 2017 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Fri Jun 16 14:51:20 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/karaf/bundle/command/Update.java |  9 +++++++++
 .../org/apache/karaf/bundle/core/BundlesMBean.java   |  2 ++
 .../karaf/bundle/core/internal/BundlesMBeanImpl.java | 15 ++++++++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/99a8b8d0/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java b/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java
index 4470f9f..90a8d61 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/command/Update.java
@@ -25,11 +25,13 @@ import java.net.URL;
 
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.util.bundles.BundleUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.FrameworkWiring;
 
 @Command(scope = "bundle", name = "update", description = "Update bundle.")
 @Service
@@ -38,6 +40,9 @@ public class Update extends BundleCommand {
     @Argument(index = 1, name = "location", description = "The bundles update location",
required = false, multiValued = false)
     URI location;
 
+    @Option(name = "-r", aliases = { "--refresh" }, description = "Perform a refresh after
the bundle update", required = false, multiValued = false)
+    boolean refresh;
+
     protected Object doExecute(Bundle bundle) throws Exception {
         if (location != null) {
             update(bundle, location.toURL());
@@ -49,6 +54,10 @@ public class Update extends BundleCommand {
                 bundle.update();
             }
         }
+        if (refresh) {
+            FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
+            wiring.refreshBundles(null);
+        }
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/99a8b8d0/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundlesMBean.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundlesMBean.java b/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundlesMBean.java
index 0327622..c191dfa 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundlesMBean.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/BundlesMBean.java
@@ -33,7 +33,9 @@ public interface BundlesMBean {
     void refresh(String bundleId) throws MBeanException;
 
     void update(String bundleId) throws MBeanException;
+    void update(String bundleId, boolean refresh) throws MBeanException;
     void update(String bundleId, String location) throws MBeanException;
+    void update(String bundleId, String location, boolean refresh) throws MBeanException;
 
     void resolve() throws MBeanException;
     void resolve(String bundleId) throws MBeanException;

http://git-wip-us.apache.org/repos/asf/karaf/blob/99a8b8d0/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundlesMBeanImpl.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundlesMBeanImpl.java
b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundlesMBeanImpl.java
index ba710dc..fd133a0 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundlesMBeanImpl.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/BundlesMBeanImpl.java
@@ -143,10 +143,18 @@ public class BundlesMBeanImpl extends StandardMBean implements BundlesMBean
{
     }
 
     public void update(String bundleId) throws MBeanException {
-        update(bundleId, null);
+        update(bundleId, null, false);
+    }
+
+    public void update(String bundleId, boolean refresh) throws MBeanException {
+        update(bundleId, null, refresh);
     }
 
     public void update(String bundleId, String location) throws MBeanException {
+        update(bundleId, location, false);
+    }
+
+    public void update(String bundleId, String location, boolean refresh) throws MBeanException
{
         try {
             List<Bundle> bundles = selectBundles(bundleId);
 
@@ -163,6 +171,11 @@ public class BundlesMBeanImpl extends StandardMBean implements BundlesMBean
{
 
             InputStream is = new URL(location).openStream();
             bundles.get(0).update(is);
+
+            if (refresh) {
+                FrameworkWiring wiring = bundleContext.getBundle(0).adapt(FrameworkWiring.class);
+                wiring.refreshBundles(null);
+            }
         } catch (Exception e) {
             throw new MBeanException(null, e.getMessage());
         }


Mime
View raw message