1 17 package org.apache.geronimo.system.main; 18 19 import java.util.Collections ; 20 21 import org.apache.geronimo.gbean.AbstractName; 22 import org.apache.geronimo.gbean.AbstractNameQuery; 23 import org.apache.geronimo.kernel.Jsr77Naming; 24 import org.apache.geronimo.kernel.repository.Artifact; 25 26 29 public class ClientCommandLine extends CommandLine { 30 34 public static void main(String [] args) { 35 log.info("Client startup begun"); 36 if(args.length == 0) { 37 System.out.println(); 38 System.out.println("ERROR: No arguments"); 39 showHelp(); 40 System.exit(1); 41 } else if(args[0].equals("--help") || args[0].equals("-h") || args[0].equals("/?")) { 42 showHelp(); 43 System.exit(0); 44 } 45 try { 46 Artifact configuration = Artifact.create(args[0]); 47 String [] clientArgs = new String [args.length -1]; 48 System.arraycopy(args, 1, clientArgs, 0, clientArgs.length); 49 new ClientCommandLine(configuration, clientArgs); 50 } catch (Exception e) { 51 ExceptionUtil.trimStackTrace(e); 52 e.printStackTrace(); 53 System.exit(2); 54 throw new AssertionError (); 55 } 56 } 57 58 private static void showHelp() { 59 System.out.println(); 60 System.out.println("syntax: java -jar bin/client.jar config-name [app arg] [app arg] ..."); 61 System.out.println(); 62 System.out.println("The first argument should identify the Geronimo configuration that"); 63 System.out.println("contains the application client you want to run."); 64 System.out.println(); 65 System.out.println("The rest of the arguments will be passed as arguments to the"); 66 System.out.println("application client when it is started."); 67 System.out.println(); 68 } 69 70 71 public ClientCommandLine(Artifact configuration, String [] args) throws Exception { 72 Jsr77Naming naming = new Jsr77Naming(); 73 AbstractName baseName = naming.createRootName(configuration, configuration.toString(), "J2EEApplication"); 76 AbstractNameQuery baseNameQuery = new AbstractNameQuery(baseName); 77 invokeMainGBean(Collections.singletonList(configuration), baseNameQuery, "main", args); 78 } 79 } 80 | Popular Tags |