1 28 29 package org.objectweb.util.launcher; 30 31 32 import org.objectweb.util.cmdline.api.Option; 33 import org.objectweb.util.cmdline.lib.ApplicationBase; 34 35 import org.objectweb.util.launcher.option.OptionVersion; 36 import org.objectweb.util.launcher.parser.ParserZeus; 37 import org.objectweb.util.launcher.parser.Repository; 38 import org.objectweb.util.trace.TraceSystem; 39 40 41 42 50 public class LauncherApplication 51 extends ApplicationBase 52 { 53 56 public LauncherApplication() { 57 super(new LauncherCmdline(), false); 58 getCommandLine().addOption(new OptionVersion(this)); 59 } 60 61 65 public String getMailingList() { 66 return "openccm@objectweb.org"; 67 } 68 69 74 protected void process(Repository repository, StringList args) { 75 Option[] opt = getCommandLine().getOptions(); 76 boolean default_run = true ; 77 for (int i = 0 ; i < opt.length ; i++) { 78 try { 79 CommandBuilder builder = (CommandBuilder)opt[i]; 80 CommandJava[] cmd = builder.complete(repository); 81 if (cmd.length!=0) default_run = false; 82 for (int j=0 ; j < cmd.length ; j++) { 83 cmd[j].addArguments(args); 84 cmd[j].run(); 85 } 86 } catch(ClassCastException ex) { 87 } 89 } 90 if (default_run) { 91 LauncherCmdline cmdline = (LauncherCmdline) getCommandLine(); 92 CommandJava cmd = CommandProvider.get(repository,"default"); 93 cmd.addArguments(args); 94 cmd.run(); 95 } 96 } 97 98 103 public int start(java.lang.String [] args) { 104 StringList arg = new StringList(args); 105 arg.remove(0); 106 try { 107 process((new ParserZeus()).load(args[0]), arg); 108 } catch(Exception ex) { 109 TraceSystem.get("launcher").fatal("Application terminated with "+ex); 110 return -1; 111 } 112 return 0; 113 } 114 } 115 | Popular Tags |