servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r708478 - in /servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq: AdministrationCommand.java CreateBrokerCommand.java DestroyBrokerCommand.java
Date Tue, 28 Oct 2008 08:37:34 GMT
Author: lhein
Date: Tue Oct 28 01:37:34 2008
New Revision: 708478

URL: http://svn.apache.org/viewvc?rev=708478&view=rev
Log:
made the classes compilable again

Modified:
    servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/AdministrationCommand.java
    servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/CreateBrokerCommand.java
    servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/DestroyBrokerCommand.java

Modified: servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/AdministrationCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/AdministrationCommand.java?rev=708478&r1=708477&r2=708478&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/AdministrationCommand.java
(original)
+++ servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/AdministrationCommand.java
Tue Oct 28 01:37:34 2008
@@ -18,80 +18,74 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 
+import org.apache.activemq.console.command.Command;
 import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
-import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.Arguments;
+import org.apache.geronimo.gshell.command.CommandAction;
 import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.common.Arguments;
+import org.apache.geronimo.gshell.io.IO;
 
 /**
- *
  * @version $Rev$ $Date$
  */
-public class AdministrationCommand implements Command
-{
+public class AdministrationCommand implements CommandAction {
 
-	private String description;
-	private String id;
-	private org.apache.activemq.console.command.Command command;
-
-	public Object execute(CommandContext context, Object... objArgs) throws Exception {
-		String[] args = Arguments.toStringArray(objArgs);
-		org.apache.activemq.console.CommandContext context2 = new org.apache.activemq.console.CommandContext();
-		context2.setFormatter(new CommandShellOutputFormatter(context.getIO().outputStream));
-        org.apache.activemq.console.command.Command currentCommand = command.getClass().newInstance();
+    private Command command;
+
+    @Argument(index=0, multiValued=true, required=true)
+    private Collection<String> arguments = null;
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.geronimo.gshell.command.CommandAction#execute(org.apache.geronimo
+     * .gshell.command.CommandContext)
+     */
+    public Object execute(CommandContext context) throws Exception {
+        final String[] args = Arguments.toStringArray(arguments.toArray());
+        final IO io = context.getIo();
+        
+        org.apache.activemq.console.CommandContext context2 = new org.apache.activemq.console.CommandContext();
+        context2.setFormatter(new CommandShellOutputFormatter(context.getIo().outputStream));
+        Command currentCommand = command.getClass().newInstance();
+        
         try {
-			currentCommand.setCommandContext(context2);
-			currentCommand.execute(new ArrayList<String>(Arrays.asList(args)));
-		} catch (Throwable e) {
-			Throwable cur = e;
-			while( cur.getCause()!=null ) {
-				cur = cur.getCause();
-			}
-			if( cur instanceof java.net.ConnectException ){
-				context2.print(
-						"\n"+
-						"Could not connect to JMX server.  This command requires that the remote JMX server
be enabled.\n"+
-						"This is typically done by adding the following JVM arguments: \n" +
-						"   -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false
\n" +
-						"   -Dcom.sun.management.jmxremote.ssl=false \n" +
-						"\n" +
-						"The connection error was: "+cur+"\n");
-			} else {
-				if( e instanceof Exception ) {
-					throw (Exception)e;
-				} else {
-					throw new RuntimeException(e);
-				}
-				
-			}
-		}
-		return SUCCESS;
-	}
-
-	public String getDescription() {
-		return description;
-	}
-
-	public String getId() {
-		return id;
-	}
-
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public org.apache.activemq.console.command.Command getCommand() {
-		return command;
-	}
-
-	public void setCommand(org.apache.activemq.console.command.Command command) {
-		this.command = command;
-	}
-	
- 
+            currentCommand.setCommandContext(context2);
+            currentCommand.execute(new ArrayList<String>(Arrays.asList(args)));
+            return Result.SUCCESS;
+        } catch (Throwable e) {
+            Throwable cur = e;
+            while (cur.getCause() != null) {
+                cur = cur.getCause();
+            }
+            if (cur instanceof java.net.ConnectException) {
+                context2
+                    .print("\n"
+                           + "Could not connect to JMX server.  This command requires that
the remote JMX server be enabled.\n"
+                           + "This is typically done by adding the following JVM arguments:
\n"
+                           + "   -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false
\n"
+                           + "   -Dcom.sun.management.jmxremote.ssl=false \n" + "\n"
+                           + "The connection error was: " + cur + "\n");
+            } else {
+                if (e instanceof Exception) {
+                    throw (Exception)e;
+                } else {
+                    throw new RuntimeException(e);
+                }
+
+            }
+        }
+        return Result.FAILURE;
+    }
+
+    public Command getCommand() {
+        return command;
+    }
+
+    public void setCommand(Command command) {
+        this.command = command;
+    }
 }

Modified: servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/CreateBrokerCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/CreateBrokerCommand.java?rev=708478&r1=708477&r2=708478&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/CreateBrokerCommand.java
(original)
+++ servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/CreateBrokerCommand.java
Tue Oct 28 01:37:34 2008
@@ -27,121 +27,125 @@
 import java.util.Scanner;
 
 import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.apache.servicemix.kernel.gshell.core.OsgiCommandSupport;
 
 /**
- *
  * @version $Rev$ $Date$
  */
-@CommandComponent(id="activemq:create-broker", description="Creates a broker instance.")
-public class CreateBrokerCommand
-    extends OsgiCommandSupport
-{
-	
-    @Option(name="-n", aliases={"--name"}, description="The name of the broker (defaults
to localhost).")
-    private String name="localhost";
- 
+// @Command(id="activemq:create-broker", description="Creates a broker instance.")
+public class CreateBrokerCommand extends OsgiCommandSupport {
+    
+    @Option(name = "-n", aliases = {"--name"}, description = "The name of the broker (defaults
to localhost).")
+    private String name = "localhost";
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * org.apache.servicemix.kernel.gshell.core.OsgiCommandSupport#doExecute()
+     */
     protected Object doExecute() throws Exception {
-    	
-    	try {
-    		String name = getName();    		
-    		File base = new File(System.getProperty("servicemix.base"));
-    		File deploy = new File(base, "deploy");
-    		
-			HashMap<String, String> props = new HashMap<String, String>();
-			props.put("${name}", name);
-			
-			mkdir(deploy);
-			File configFile = new File(deploy,name+"-broker.xml");
-			copyFilteredResourceTo(configFile, "broker.xml", props);
-
-			
-			io.out.println("");
-			io.out.println("Default ActiveMQ Broker ("+name+") configuration file created at: "+configFile.getPath());
-			io.out.println("Please review the configuration and modify to suite your needs.  ");
-			io.out.println("");
-			
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
+
+        try {
+            String name = getName();
+            File base = new File(System.getProperty("servicemix.base"));
+            File deploy = new File(base, "deploy");
+
+            HashMap<String, String> props = new HashMap<String, String>();
+            props.put("${name}", name);
+
+            mkdir(deploy);
+            File configFile = new File(deploy, name + "-broker.xml");
+            copyFilteredResourceTo(configFile, "broker.xml", props);
+
+            io.out.println("");
+            io.out.println("Default ActiveMQ Broker (" + name + ") configuration file created
at: "
+                           + configFile.getPath());
+            io.out.println("Please review the configuration and modify to suite your needs.
 ");
+            io.out.println("");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
 
         return 0;
     }
-	
-	private void copyFilteredResourceTo(File outFile, String resource, HashMap<String, String>
props) throws Exception {
-		if( !outFile.exists() ) {
-	        io.out.println("Creating file: @|green "+outFile.getPath()+"|");
-			InputStream is = CreateBrokerCommand.class.getResourceAsStream(resource);
-			try {
-				// Read it line at a time so that we can use the platform line ending when we write it
out.
-				PrintStream out = new PrintStream(new FileOutputStream(outFile));
-				try { 
-					Scanner scanner = new Scanner(is);
-					while (scanner.hasNextLine() ) {
-						String line = scanner.nextLine();
-						line = filter(line, props);
-						out.println(line);
-					}
-				} finally {
-					safeClose(out);
-				}
-			} finally {
-				safeClose(is);
-			}
-		} else {
-	        io.out.println("@|red File allready exists|. Move it out of the way if you want
it re-created: "+outFile.getPath()+"");
-		}
-	}
-
-	private void safeClose(InputStream is) throws IOException {
-		if( is==null)
-			return;
-		try {
-			is.close();
-		} catch (Throwable ignore) {
-		}
-	}
-	
-	private void safeClose(OutputStream is) throws IOException {
-		if( is==null)
-			return;
-		try {
-			is.close();
-		} catch (Throwable ignore) {
-		}
-	}
 
-	private String filter(String line, HashMap<String, String> props) {
-		for (Map.Entry<String, String> i : props.entrySet()) {
+    private void copyFilteredResourceTo(File outFile, String resource, HashMap<String,
String> props)
+        throws Exception {
+        if (!outFile.exists()) {
+            io.out.println("Creating file: @|green " + outFile.getPath() + "|");
+            InputStream is = CreateBrokerCommand.class.getResourceAsStream(resource);
+            try {
+                // Read it line at a time so that we can use the platform line
+                // ending when we write it out.
+                PrintStream out = new PrintStream(new FileOutputStream(outFile));
+                try {
+                    Scanner scanner = new Scanner(is);
+                    while (scanner.hasNextLine()) {
+                        String line = scanner.nextLine();
+                        line = filter(line, props);
+                        out.println(line);
+                    }
+                } finally {
+                    safeClose(out);
+                }
+            } finally {
+                safeClose(is);
+            }
+        } else {
+            io.out.println("@|red File allready exists|. Move it out of the way if you want
it re-created: "
+                           + outFile.getPath() + "");
+        }
+    }
+
+    private void safeClose(InputStream is) throws IOException {
+        if (is == null)
+            return;
+        try {
+            is.close();
+        } catch (Throwable ignore) {
+        }
+    }
+
+    private void safeClose(OutputStream is) throws IOException {
+        if (is == null)
+            return;
+        try {
+            is.close();
+        } catch (Throwable ignore) {
+        }
+    }
+
+    private String filter(String line, HashMap<String, String> props) {
+        for (Map.Entry<String, String> i : props.entrySet()) {
             int p1;
             while ((p1 = line.indexOf(i.getKey())) >= 0) {
-				String l1 = line.substring(0, p1);
-				String l2 = line.substring(p1+i.getKey().length());
-				line = l1+i.getValue()+l2;
-			}
-		}
-		return line;
-	}
-
-	private void mkdir(File file) {
-		if( !file.exists() ) {
-	        io.out.println("Creating missing directory: @|green "+file.getPath()+"|");
-			file.mkdirs();
-		}
-	}
-
-	public String getName() {
-		if( name ==  null ) {
-    		File base = new File(System.getProperty("servicemix.base"));
-    		name = base.getName();
-		}
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
+                String l1 = line.substring(0, p1);
+                String l2 = line.substring(p1 + i.getKey().length());
+                line = l1 + i.getValue() + l2;
+            }
+        }
+        return line;
+    }
+
+    private void mkdir(File file) {
+        if (!file.exists()) {
+            io.out.println("Creating missing directory: @|green " + file.getPath() + "|");
+            file.mkdirs();
+        }
+    }
+
+    public String getName() {
+        if (name == null) {
+            File base = new File(System.getProperty("servicemix.base"));
+            name = base.getName();
+        }
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 
 }

Modified: servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/DestroyBrokerCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/DestroyBrokerCommand.java?rev=708478&r1=708477&r2=708478&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/DestroyBrokerCommand.java
(original)
+++ servicemix/smx4/features/trunk/activemq/activemq-commands/src/main/java/org/apache/servicemix/kernel/gshell/activemq/DestroyBrokerCommand.java
Tue Oct 28 01:37:34 2008
@@ -19,55 +19,49 @@
 import java.io.File;
 
 import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.apache.servicemix.kernel.gshell.core.OsgiCommandSupport;
 
 /**
- * 
- *
  * @version $Rev$ $Date$
  */
-@CommandComponent(id="activemq:destroy-broker", description="Destroys a broker instance.")
-public class DestroyBrokerCommand
-    extends OsgiCommandSupport
-{
-	
-    @Option(name="-n", aliases={"--name"}, description="The name of the broker (defaults
to localhost).")
-    private String name="localhost";
- 
+// @CommandComponent(id="activemq:destroy-broker", description="Destroys a broker instance.")
+public class DestroyBrokerCommand extends OsgiCommandSupport {
+
+    @Option(name = "-n", aliases = {"--name"}, description = "The name of the broker (defaults
to localhost).")
+    private String name = "localhost";
+
     protected Object doExecute() throws Exception {
-    	
-    	try {
-    		String name = getName();    		
-    		File base = new File(System.getProperty("servicemix.base"));
-    		File deploy = new File(base, "deploy");
-			File configFile = new File(deploy,name+"-broker.xml");
-
-			configFile.delete();
-			
-			io.out.println("");
-			io.out.println("Default ActiveMQ Broker ("+name+") configuration file created at: "+configFile.getPath()+"
removed.");
-			io.out.println("");
-			
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
+
+        try {
+            String name = getName();
+            File base = new File(System.getProperty("servicemix.base"));
+            File deploy = new File(base, "deploy");
+            File configFile = new File(deploy, name + "-broker.xml");
+
+            configFile.delete();
+
+            io.out.println("");
+            io.out.println("Default ActiveMQ Broker (" + name + ") configuration file created
at: "
+                           + configFile.getPath() + " removed.");
+            io.out.println("");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
 
         return 0;
     }
-	
 
-	public String getName() {
-		if( name ==  null ) {
-    		File base = new File(System.getProperty("servicemix.base"));
-    		name = base.getName();
-		}
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
+    public String getName() {
+        if (name == null) {
+            File base = new File(System.getProperty("servicemix.base"));
+            name = base.getName();
+        }
+        return name;
+    }
 
+    public void setName(String name) {
+        this.name = name;
+    }
 }



Mime
View raw message