1 28 package org.objectweb.openccm.explorer.commandLine; 29 30 import org.objectweb.openccm.corba.TheORB; 31 import org.objectweb.openccm.corba.TheRootPOA; 32 import org.objectweb.util.cmdline.lib.ApplicationBase; 33 import org.objectweb.util.cmdline.lib.DefaultCommandLine; 34 import org.objectweb.util.misc.api.ExceptionWrapper; 35 import org.objectweb.openccm.explorer.Main; 36 import org.objectweb.openccm.explorer.MainPDA; 37 import org.objectweb.openccm.explorer.CORBA.ConsoleFactory; 38 39 import java.util.Vector ; 40 import java.util.List ; 41 42 50 public class ExplorerApplication 51 extends ApplicationBase 52 implements DefaultApplication, ConfigApplication, ViewApplication { 53 54 55 protected String [] explorerConfigFiles_ = null; 56 57 58 protected String context_ = ""; 59 60 61 protected String config_ = null; 62 63 64 protected String view_ = "basic"; 65 66 69 public ExplorerApplication() { 70 super(new DefaultCommandLine(new String [] { "ccm_explorer" }, new String [0], new String [] { "Display the OpenCCM explorer console" }, true)); 71 getCommandLine().addOption(new DefaultContextOption(this)); 73 getCommandLine().addOption(new DefaultExplorerOption(this)); 74 getCommandLine().addOption(new ConfigOption(this)); 75 getCommandLine().addOption(new ViewOption(this)); 76 } 77 78 83 private String [] removeORBArgument(String [] args) { 84 int nb = 0; 85 String [] tmp = new String [args.length]; 86 for (int i = 0; i < args.length; i++) { 87 if (!args[i].startsWith("-ORB")) { 88 tmp[nb] = args[i]; 89 nb++; 90 } else { 91 i++; 92 } 93 } 94 String [] tmp2 = new String [nb]; 95 for (int i = 0; i < nb; i++) 96 tmp2[i] = tmp[i]; 97 return tmp2; 98 } 99 100 104 public void setConfigFile(String file) { 105 config_ = file; 106 } 107 108 112 public void setDefaultContextConfigFile(String file) { 113 context_ = file; 114 } 115 116 120 public void setDefaultExplorerConfigFile(String [] file) { 121 explorerConfigFiles_ = file; 122 } 123 124 128 public void setView(String view){ 129 view_ = view; 130 } 131 132 136 public void runMain(String [] args) { 137 org.omg.CORBA.ORB orb = org.objectweb.openccm.Components.Runtime.init(args); 139 141 try { 143 String [] arguments = getCommandLine().parse(removeORBArgument(args)); 144 int ret = start(arguments); 145 } catch (ExceptionWrapper exc) { 146 report_exception(exc.getException()); 147 } catch (Exception exc) { 148 report_exception(exc); 149 } 150 } 151 152 156 public int start(String [] args) { 157 List fileList = new Vector (); 158 if(explorerConfigFiles_!=null){ 159 for(int i=0 ; i < explorerConfigFiles_.length ; i++) { 160 fileList.add(explorerConfigFiles_[i]); 161 } 162 } 163 if (config_ != null) { 164 fileList.add(config_); 165 } 166 if(view_.equals("tabs")) { 167 new MainPDA(context_, (String []) fileList.toArray(new String [0])); 168 } else if(view_.equals("basic")) { 169 new Main(context_, (String []) fileList.toArray(new String [0])); 170 } 171 return 0; 172 } 173 174 178 public static void main(String [] args) { 179 ExplorerApplication application = new ExplorerApplication(); 180 application.runMain(args); 181 ConsoleFactory.getDebugConsole().add("Running the ORB \n"); 182 183 try 185 { 186 ConsoleFactory.getDebugConsole().add("Activating the RootPOA\n"); 187 TheRootPOA.getRootPOA().the_POAManager().activate(); 188 } 189 catch ( java.lang.Exception ex ) 190 { 191 System.err.println( "An exception has been intercepted" ); 192 ex.printStackTrace(); 193 } 194 195 TheORB.run(); 196 } 197 198 } 199 | Popular Tags |