karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [3/3] git commit: Fix up Id command after backport to 3.0.x
Date Thu, 17 Apr 2014 14:45:24 GMT
Fix up Id command after backport to 3.0.x


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

Branch: refs/heads/karaf-3.0.x
Commit: 202ad3e694172ad8111a043f3be03577a6f5d79d
Parents: 69ed05b
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Thu Apr 17 12:12:35 2014 -0230
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Thu Apr 17 12:12:35 2014 -0230

----------------------------------------------------------------------
 .../org/apache/karaf/bundle/command/Id.java     | 71 ++++++++++++++++++
 .../OSGI-INF/blueprint/shell-bundles.xml        |  6 ++
 .../src/main/resources/OSGI-INF/bundle.info     |  1 +
 .../org/apache/karaf/bundle/command/Id.java     | 76 --------------------
 4 files changed, 78 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/202ad3e6/bundle/command/src/main/java/org/apache/karaf/bundle/command/Id.java
----------------------------------------------------------------------
diff --git a/bundle/command/src/main/java/org/apache/karaf/bundle/command/Id.java b/bundle/command/src/main/java/org/apache/karaf/bundle/command/Id.java
new file mode 100644
index 0000000..882d6df
--- /dev/null
+++ b/bundle/command/src/main/java/org/apache/karaf/bundle/command/Id.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.bundle.command;
+
+import java.util.List;
+
+import org.apache.karaf.bundle.core.BundleService;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.shell.util.ShellUtil;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+@Command(scope = "bundle", name = "id", description = "Gets the bundle ID.")
+public class Id extends OsgiCommandSupport {
+
+    @Argument(index = 0, name = "name", description = "The bundle name, name/version, or
location", required = true, multiValued = false)
+    String name;
+
+    BundleService bundleService;
+
+    BundleContext bundleContext;
+
+    protected Object doExecute() throws Exception {
+        return doExecute(true);
+    }
+
+    protected Object doExecute(boolean force) throws Exception {
+        Bundle bundle = bundleService.getBundle(name, true);
+        
+        // if name or name/version were not successful, let's try searching by location
+        if (bundle == null) {
+            for (int i = 0; i < bundleContext.getBundles().length; i++) {
+                Bundle b = bundleContext.getBundles()[i];
+                if (name.equals(b.getLocation())) {
+                    bundle = b;
+                    break;
+                }
+            }
+        }
+        if (bundle != null) {            
+            if (force || !ShellUtil.isASystemBundle(bundleContext, bundle)) {           
    
+                return bundle.getBundleId();
+            } else {
+                System.err.println("Access to system bundle " + name + " is discouraged.
You may override with -f");
+            }
+        } else {
+            System.err.println("Bundle " + name + " is not found");
+        }
+        return null;
+    }
+
+    public void setBundleService(BundleService bundleService) {
+        this.bundleService = bundleService;
+    }
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/202ad3e6/bundle/command/src/main/resources/OSGI-INF/blueprint/shell-bundles.xml
----------------------------------------------------------------------
diff --git a/bundle/command/src/main/resources/OSGI-INF/blueprint/shell-bundles.xml b/bundle/command/src/main/resources/OSGI-INF/blueprint/shell-bundles.xml
index bed5c0f..610e3c3 100644
--- a/bundle/command/src/main/resources/OSGI-INF/blueprint/shell-bundles.xml
+++ b/bundle/command/src/main/resources/OSGI-INF/blueprint/shell-bundles.xml
@@ -124,6 +124,12 @@
             </action> 
         </command>
         <command>
+            <action class="org.apache.karaf.bundle.command.Id">
+                <property name="bundleService" ref="bundleService"/>
+                <property name="bundleContext" ref="blueprintBundleContext" />
+            </action> 
+        </command>        
+        <command>
             <action class="org.apache.karaf.bundle.command.Watch" >
                 <property name="bundleWatcher" ref="bundleWatcher"/>
             </action>

http://git-wip-us.apache.org/repos/asf/karaf/blob/202ad3e6/bundle/command/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/bundle/command/src/main/resources/OSGI-INF/bundle.info b/bundle/command/src/main/resources/OSGI-INF/bundle.info
index af2c24f..860dcbd 100644
--- a/bundle/command/src/main/resources/OSGI-INF/bundle.info
+++ b/bundle/command/src/main/resources/OSGI-INF/bundle.info
@@ -15,6 +15,7 @@ The following commands are available:
 * bundle:classes - Displays a list of classes contained in the bundle
 * bundle:find-class - Locates a specified class in any deployed bundle
 * bundle:headers - Display OSGi headers of a given bundle.
+* bundle:id - Gets the bundle ID.
 * bundle:info - Display detailed information of a given bundle.
 * bundle:install - Install one or more bundles.
 * bundle:list - List all installed bundles.

http://git-wip-us.apache.org/repos/asf/karaf/blob/202ad3e6/bundle/core/src/main/java/org/apache/karaf/bundle/command/Id.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/command/Id.java b/bundle/core/src/main/java/org/apache/karaf/bundle/command/Id.java
deleted file mode 100644
index 1e346b3..0000000
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/command/Id.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.bundle.command;
-
-import java.util.List;
-
-import org.apache.karaf.bundle.core.BundleService;
-import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.ShellUtil;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-@Command(scope = "bundle", name = "id", description = "Gets the bundle ID.")
-@Service
-public class Id implements Action {
-
-    @Argument(index = 0, name = "name", description = "The bundle name, name/version, or
location", required = true, multiValued = false)
-    String name;
-
-    @Reference
-    BundleService bundleService;
-
-    @Reference
-    BundleContext bundleContext;
-
-    public Object execute() throws Exception {
-        return doExecute(true);
-    }
-
-    protected Object doExecute(boolean force) throws Exception {
-        Bundle bundle = bundleService.getBundle(name, true);
-        
-        // if name or name/version were not successful, let's try searching by location
-        if (bundle == null) {
-            for (int i = 0; i < bundleContext.getBundles().length; i++) {
-                Bundle b = bundleContext.getBundles()[i];
-                if (name.equals(b.getLocation())) {
-                    bundle = b;
-                    break;
-                }
-            }
-        }
-        if (bundle != null) {            
-            if (force || !ShellUtil.isASystemBundle(bundleContext, bundle)) {           
    
-                return bundle.getBundleId();
-            } else {
-                System.err.println("Access to system bundle " + name + " is discouraged.
You may override with -f");
-            }
-        } else {
-            System.err.println("Bundle " + name + " is not found");
-        }
-        return null;
-    }
-
-    public void setBundleService(BundleService bundleService) {
-        this.bundleService = bundleService;
-    }
-}


Mime
View raw message