You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/11/12 21:14:50 UTC

svn commit: r1541217 - /karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java

Author: jbonofre
Date: Tue Nov 12 20:14:50 2013
New Revision: 1541217

URL: http://svn.apache.org/r1541217
Log:
[KARAF-2575] Add missing commands in bin/instance script

Modified:
    karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java

Modified: karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java
URL: http://svn.apache.org/viewvc/karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java?rev=1541217&r1=1541216&r2=1541217&view=diff
==============================================================================
--- karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java (original)
+++ karaf/trunk/instance/command/src/main/java/org/apache/karaf/instance/main/Execute.java Tue Nov 12 20:14:50 2013
@@ -33,16 +33,20 @@ import org.fusesource.jansi.AnsiConsole;
 
 public class Execute {
     static Class<? extends Action> x = CreateCommand.class;
-    private static final Class<?> [] COMMAND_CLASSES = new Class[] {
-        CreateCommand.class,
-        StartCommand.class,
-        StopCommand.class,
-        DestroyCommand.class,
-        ListCommand.class,
-        ChangeSshPortCommand.class,
-        ChangeRmiRegistryPortCommand.class,
-        ChangeRmiServerPortCommand.class};
+    private static final Class<?>[] COMMAND_CLASSES = new Class[]{
+            ChangeOptsCommand.class,
+            ChangeRmiRegistryPortCommand.class,
+            ChangeRmiServerPortCommand.class,
+            ChangeSshPortCommand.class,
+            CloneCommand.class,
+            CreateCommand.class,
+            DestroyCommand.class,
+            ListCommand.class,
+            RenameCommand.class,
+            StartCommand.class,
+            StopCommand.class};
     private static final Map<String, Class<?>> COMMANDS = new TreeMap<String, Class<?>>();
+
     static {
         for (Class<?> c : COMMAND_CLASSES) {
             Command ann = c.getAnnotation(Command.class);
@@ -51,22 +55,22 @@ public class Execute {
             }
             COMMANDS.put(ann.name(), c);
         }
-    }    
-    
+    }
+
     // For testing
     static boolean exitAllowed = true;
-    
+
     /**
      * Environment variable for specifying extra options to the Karaf instance
      * process kicked off from this Java process.
      */
     private static final String ENV_KARAF_OPTS = "KARAF_OPTS";
-    
+
     /**
      * System property for specifying extra options to the Karaf instance
      * process kicked off from this Java process.
      */
-    private static final String PROP_KARAF_OPTS = "karaf.opts";    
+    private static final String PROP_KARAF_OPTS = "karaf.opts";
 
     public static void main(String[] args) throws Exception {
         AnsiConsole.systemInstall();
@@ -85,24 +89,24 @@ public class Execute {
         String storage = System.getProperty("karaf.instances");
         if (storage == null) {
             System.err.println("System property 'karaf.instances' is not set. \n" +
-        		"This property needs to be set to the full path of the instance.properties file.");
-            exit(-1);
+                    "This property needs to be set to the full path of the instance.properties file.");
+            exit(-2);
         }
         File storageFile = new File(storage);
         System.setProperty("user.dir", storageFile.getParentFile().getParentFile().getCanonicalPath());
-        
+
         try {
             String karafOpts = System.getenv(ENV_KARAF_OPTS);
             if (karafOpts != null) {
                 System.setProperty(PROP_KARAF_OPTS, karafOpts);
             }
-        } catch(Exception e) {
+        } catch (Exception e) {
             System.err.println("Could not read KARAF_OPTS environment variable: " + e.getMessage());
             if (System.getProperty("karaf.showStackTrace") != null) {
                 throw e;
             }
-        }        
-        
+        }
+
         Object command = cls.newInstance();
         if (command instanceof InstanceCommandSupport) {
             try {
@@ -115,10 +119,10 @@ public class Execute {
             }
         } else {
             System.err.println("Not an instance command: " + commandName);
-            exit(-1);
+            exit(-3);
         }
     }
-    
+
     static void execute(InstanceCommandSupport command, File storageFile, String[] args) throws Exception {
         DefaultActionPreparator dap = new DefaultActionPreparator();
         List<Object> params = new ArrayList<Object>(Arrays.asList(args));
@@ -127,7 +131,7 @@ public class Execute {
         if (!dap.prepare(command, null, params)) {
             return;
         }
-                
+
         InstanceServiceImpl instanceService = new InstanceServiceImpl();
         instanceService.setStorageLocation(storageFile);
         command.setInstanceService(instanceService);
@@ -140,7 +144,7 @@ public class Execute {
             Command ann = entry.getValue().getAnnotation(Command.class);
             System.out.printf("  %s - %s\n", entry.getKey(), ann.description());
         }
-        
+
         System.out.println("Type 'command --help' for more help on the specified command.");
     }