felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r956255 - in /felix/trunk/dependencymanager/shell: pom.xml src/main/java/org/apache/felix/dm/shell/Activator.java src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java
Date Sat, 19 Jun 2010 17:31:56 GMT
Author: pderop
Date: Sat Jun 19 17:31:56 2010
New Revision: 956255

URL: http://svn.apache.org/viewvc?rev=956255&view=rev
Log:
Added support for Gogo shell

Added:
    felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java
Modified:
    felix/trunk/dependencymanager/shell/pom.xml
    felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/Activator.java

Modified: felix/trunk/dependencymanager/shell/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/shell/pom.xml?rev=956255&r1=956254&r2=956255&view=diff
==============================================================================
--- felix/trunk/dependencymanager/shell/pom.xml (original)
+++ felix/trunk/dependencymanager/shell/pom.xml Sat Jun 19 17:31:56 2010
@@ -55,6 +55,11 @@
       <artifactId>osgi</artifactId>
       <version>3.1.1</version>
     </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.apache.felix.gogo.runtime</artifactId>
+      <version>0.6.0</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -72,7 +77,12 @@
             <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
             <Export-Package></Export-Package>
             <Private-Package>org.apache.felix.dm.shell</Private-Package>
-            <Import-Package>org.apache.felix.dm.management;version="[3.0.0,4.0.0)",org.apache.felix.shell;version="1.0";resolution:=optional,org.osgi.framework;version="1.3",org.eclipse.osgi.framework.console;resolution:=optional</Import-Package>
+            <Import-Package>org.apache.felix.dm.management;version="[3.0.0,4.0.0)",
+            				org.apache.felix.shell;version="1.0";resolution:=optional,
+            				org.osgi.framework;version="1.3",
+            				org.eclipse.osgi.framework.console;resolution:=optional,
+            				org.apache.felix.service.command;resolution:=optional
+          	</Import-Package>
           </instructions>
         </configuration>
       </plugin>

Modified: felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/Activator.java?rev=956255&r1=956254&r2=956255&view=diff
==============================================================================
--- felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/Activator.java
(original)
+++ felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/Activator.java
Sat Jun 19 17:31:56 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.dm.shell;
 
+import java.util.Hashtable;
+
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -28,18 +30,30 @@ import org.osgi.framework.BundleContext;
  */
 public class Activator implements BundleActivator {
     public void start(BundleContext context) throws Exception {
+        // Provide DependencyManager shell commands for the old Felix Shell.
         try {
             context.registerService("org.apache.felix.shell.Command", new FelixDMCommand(context),
null);
         }
         catch (Throwable t) {
         }
+        // Provide DependencyManager shell commands for the Equinox Shell.
         try {
             context.registerService("org.eclipse.osgi.framework.console.CommandProvider",
new EquinoxDMCommand(context), null);
         }
         catch (Throwable t) {
         }
+        // Provide DependencyManager shell commands for the Gogo Shell.
+        try {
+            Hashtable props = new Hashtable();
+            props.put(org.apache.felix.service.command.CommandProcessor.COMMAND_SCOPE, "dependencymanager");
+            props.put(org.apache.felix.service.command.CommandProcessor.COMMAND_FUNCTION,

+                      new String[] { "dmhelp", "dm", "dmnodeps", "dmnotavail", "dmcompact"
});
+            context.registerService(GogoDMCommand.class.getName(), new GogoDMCommand(context),
props);
+        }
+        catch (Throwable t) {            
+        }
     }
 
     public void stop(BundleContext context) throws Exception {
-    }
+    }    
 }

Added: felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java?rev=956255&view=auto
==============================================================================
--- felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java
(added)
+++ felix/trunk/dependencymanager/shell/src/main/java/org/apache/felix/dm/shell/GogoDMCommand.java
Sat Jun 19 17:31:56 2010
@@ -0,0 +1,81 @@
+package org.apache.felix.dm.shell;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * This class provides DependencyManager commands for the Gogo shell.
+ */
+public class GogoDMCommand extends DMCommand
+{
+    public GogoDMCommand(BundleContext context)
+    {
+        super(context);
+    }
+    
+    public void dmhelp() {
+        System.out.println("dependencymanager:dm -> list DM component diagnostics.");
+        System.out.println("dependencymanager:dm bundleId -> list DM component diagnostics
for a given bundle.");
+        System.out.println("dependencymanager:dmnotavail -> list unavailable DM components.");
+        System.out.println("dependencymanager:dmnotavail bundleId -> list unavailable
DM components for a given bundle.");
+        System.out.println("dependencymanager:dmnodeps -> list DM component diagnostics
without dependencies.");
+        System.out.println("dependencymanager:dmnodeps bundleId-> list DM component diagnostics
without dependencies for a given bundle.");
+        System.out.println("dependencymanager:dmcompact -> list DM component compact diagnostics.");
+        System.out.println("dependencymanager:dmcompact bundleId -> list DM component
compact diagnostics for a given bundle.");
+    }
+    
+    public void dm() {
+        execute("dm", new String[0]);
+    }
+
+    public void dm(int bundleId) {
+        execute("dm", new String[] { String.valueOf(bundleId) });
+    }
+
+    public void dmnodeps() {
+        execute("dm nodeps", new String[0]);
+    }
+    
+    public void dmnodeps(int bundleId) {
+        execute("dm nodeps", new String[] { String.valueOf(bundleId) });
+    }
+    
+    public void dmnotavail() {
+        execute("dm notavail", new String[0]);
+    }
+   
+   public void dmnotavail(int bundleId) {
+       execute("dm notavail", new String[] { String.valueOf(bundleId) });
+   }
+
+   public void dmcompact() {
+       execute("dm compact", new String[0]);
+   }    
+
+   public void dmcompact(int bundleId) {
+        execute("dm compact", new String[] { String.valueOf(bundleId) });
+   }    
+        
+   private void execute(String line, String[] args) {
+       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+       ByteArrayOutputStream errorBytes = new ByteArrayOutputStream();
+       PrintStream out = new PrintStream(bytes);
+       PrintStream err = new PrintStream(errorBytes);
+        
+       if (args != null && args.length > 0) {
+           line += " " + args[0]; // Add bundle Id
+       }
+        
+       super.execute(line.toString(), out, err);
+       if (bytes.size() > 0) {
+           System.out.println(new String(bytes.toByteArray()));
+       }
+       if (errorBytes.size() > 0) {
+           System.out.print("Error:\n");
+           System.out.println(new String(errorBytes.toByteArray()));
+       }
+    }
+}



Mime
View raw message