Building Controls Virtual Test Bed
Launcher.java
Go to the documentation of this file.
1 package BCVTB;
2 import java.io.File;
3 import java.io.FileNotFoundException;
4 import java.io.IOException;
5 import java.io.FileInputStream;
6 import java.io.BufferedReader;
7 import java.io.BufferedInputStream;
8 import java.io.InputStreamReader;
9 import java.io.FileReader;
10 import java.util.Properties;
11 import java.util.Map;
12 import java.util.TreeMap;
13 import java.util.ArrayList;
14 import java.util.Iterator;
15 import java.net.URL;
16 import java.awt.GraphicsEnvironment;
17 
18 public class Launcher{
19 
21  public Launcher()
22  throws FileNotFoundException, Exception
23  {
24  ptFile = null;
25  run = false;
26  update = false;
27  console = false;
28  pb = new ProcessBuilder();
29  prop = pb.environment();
30  // We need to add PATH so that it is replaced if a user sets
31  // PATH=xyz:$PATH
32  // On Linux Ubuntu 10.04, this is required.
33  prop.put("PATH", System.getenv("PATH"));
36  }
37 
44  protected void setupCommandList(String[] args, ArrayList<String> comLis){
45  if ( args.length == 1 ){
46  String em = "Error: The flag '-command' must be followed by at least one argument."
47  + "The command line is '" + args[0] + "'.";
48  throw new UnsupportedOperationException(em);
49  }
50  else{ // Got a -command with at least one more argument. Retrieve it.
51  for(int i = 1; i < args.length; i++)
52  comLis.add(args[i]);
53  }
54  }
55 
61  boolean isJVMFlag(final String[] args, int i){
62  if (args[i].equals("-command")) return false;
63  if (args[i].equals("-file")) return false;
64  if (args[i].equals("-run")) return false;
65  if (args[i].equals("-update")) return false;
66  if (args[i].equals("-console")) return false;
67  if (args[i].equals("-diagnostics")) return false;
68  if (args[i].equals("-command")) return false;
69  if (i == args.length-1) return false; // It is the last argument. This cannot be a JVM flag
70  if (new File(args[i]).exists()) return false; // It is a file, probably the MoMOL file
71  return true;
72  }
73 
81  protected void setupPtolemyArguments(String[] args, ArrayList<String> ptArgs,
82  ArrayList<String> JVMFlags){
83  boolean getCommandFlags = false;
84  boolean checkForJVMFlag = true;
85 
86  for (int i = 0; i < args.length; i++){
87  if (checkForJVMFlag && isJVMFlag(args, i)){
88  JVMFlags.add(args[i]);
89  }
90  else {
91  checkForJVMFlag = false;
92  if(args[i].equals("-file")){
93  // got runtime file
94  if ( i == args.length -1 ){
95  String em = "Error: The flag '-file' must be followed by at least one argument."
96  + "The command line is'";
97  for(int j = 0; j < args.length; j++)
98  em += ' ' + args[j];
99  em += "'.";
100  throw new UnsupportedOperationException(em);
101  }
102  else{ // Got a -file with at least one more argument. Retrieve it.
103  getCommandFlags = false;
104  }
105  }else if(args[i].equals("-console")){
106  // run it
107  console = true;
108  getCommandFlags = false;
109  }else if(args[i].equals("-run")){
110  // run it
111  run = true;
112  getCommandFlags = false;
113  }else if(args[i].equals("-update")){
114  // run it
115  update=true;
116  getCommandFlags = true;
117  }else if(args[i].equals("-diagnostics")){
118  // Dump system variables
120  }
121  else if(getCommandFlags){
122  // We are still scanning for command flags.
123  // This is a command flag
124  ptArgs.add(args[i]);
125  if (update) // only one command flag is needed for "-update 1.2 fileName.xml"
126  getCommandFlags = false;
127  }else{
128  // Retrieve the ptFile
129  ptFile = args[i];
130  if (! new File(ptFile).exists())
131  throw new UnsupportedOperationException("Error: Argument '" + ptFile + "' is not a file.");
132  // We may have more flags, such as -finalTime 3600
133  getCommandFlags = true;
134  }
135  }
136  }
137  }
138 
144  protected String getProperty(final String key){
145  return userProp.getProperty(key);
146  }
147 
153  protected String getUserPropertyFileName()
154  throws Exception{
155  String userPropertyFile;
156  final String root = getBCVTBRoot();
157  switch (os) {
158  case LINUX:
159  userPropertyFile = root + "/bin/systemVariables-linux.properties";
160  break;
161  case MAC:
162  userPropertyFile = root + "/bin/systemVariables-mac.properties";
163  break;
164  case WINDOWS:
165  userPropertyFile = root + "\\bin\\systemVariables-windows.properties";
166  break;
167  default:
168  final String em = "Unsupported operating system when trying to get system property file." +
169  LS + "os = " + os;
170  throw new Exception(em);
171  }
172  return userPropertyFile;
173  }
174 
183  void updateClasspath(){
184  // Run on windows only
185  final String osNam = System.getProperty("os.name").toLowerCase();
186  if (osNam.indexOf("windows") > -1){ // have windows
187  Iterator it = prop.entrySet().iterator();
188  while (it.hasNext()) {
189  final Map.Entry pairs = (Map.Entry)it.next();
190  final String key = (String)pairs.getKey();
191  final String val = (String)pairs.getValue();
192  // Return if we find CLASSPATH or classpath
193  if (key.equalsIgnoreCase("CLASSPATH") && (!key.equals("CLASSPATH"))){
194  if ( prop.containsKey("CLASSPATH"))
195  prop.put("CLASSPATH", prop.get("CLASSPATH") + ";" + val);
196  else
197  prop.put("CLASSPATH", val);
198  // Remove old variable since Windows may pick the lowercase classpath
199  // variable
200  prop.remove(key);
201  // return, since prop gets changed and the iterator does point
202  // to too many elements, which causes a null pointer exception.
203  return;
204  }
205  }
206  }
207  }
208 
209 
215  void setCommand(String[] args)
216  throws UnsupportedOperationException{
217  // Search for the -command flag
218  ArrayList<String> comLis = new ArrayList<String>();
219  ArrayList<String> ptArg = new ArrayList<String>();
220  ArrayList<String> JVMFlags = new ArrayList<String>();
221 
222  // Check if first argument is -command
223  if (args.length > 0 && args[0].equals("-command")){
224  setupCommandList(args, comLis);
225  }
226  else{
227  setupPtolemyArguments(args, ptArg, JVMFlags);
228  }
229  // Set up the arguments of the process builder
230  if ( comLis.size() == 0 ){
231  // Did not get any -command. Set the commmand that starts ptolemy
232  comLis.add("java");
233  // Add JVM flags to command line
234  for ( Iterator<String> iter = JVMFlags.iterator(); iter.hasNext(); )
235  comLis.add( iter.next() );
236 
237  if ( console ){
238  // ptolemy.moml.MoMLCommandLineApplication does not set the isHeadless
239  // property to false. Hence, we set it here so that no windows
240  // are being opened. This environment flag is checked in
241  // Simulator and in SystemCommand
242  comLis.add("-Dptolemy.ptII.isHeadless=true");
243  comLis.add("ptolemy.moml.MoMLCommandLineApplication");
244  }
245  else if ( run ){
246  comLis.add("ptolemy.actor.gui.PtExecuteApplication");
247  comLis.add("-bcvtb");
248  }
249  else if ( update ){
250  comLis.add("-classpath");
251  comLis.add(prop.get("BCVTB_HOME") + PS + "bin" + PS + "BCVTB.jar");
252  comLis.add("BCVTB.VersionUpdater");
253  }
254  else{
255  comLis.add("ptolemy.vergil.VergilApplication");
256  comLis.add("-bcvtb");
257  }
258  // Add arguments to command line
259  for ( Iterator<String> iter = ptArg.iterator(); iter.hasNext(); )
260  comLis.add( iter.next() );
261  if ( ptFile == null ){
262  if (console){
263  final String em = "Error: If flag -console is used, a model file is required as an argument."
264  + LS + " Call program as java -jar bin/BCVTB.jar -console modelFile.xml";
265  throw new UnsupportedOperationException(em);
266  }
267  else if (update){
268  final String em = "Error: If flag -update is used, a model file is required as an argument."
269  + LS + " Call program as java -jar bin/BCVTB.jar -update toVersion modelFile.xml"
270  + LS + " where 'toVersion' is the new version number, such as 1.2";
271  throw new UnsupportedOperationException(em);
272  }
273  }
274  else
275  comLis.add(ptFile);
276  }
277  // for (int i = 0; i < comLis.size(); i++)
278  // System.err.println("aabb " + comLis.get(i));
279  // Set commands to process builder
280  pb.command(comLis);
281 
282  /*
283  System.err.print("\n----- JVMFlags: ");
284  for ( Iterator<String> iter = JVMFlags.iterator(); iter.hasNext(); )
285  System.err.print(iter.next() + " ");
286  System.err.print("\n----- comLis: ");
287  for ( Iterator<String> iter = comLis.iterator(); iter.hasNext(); )
288  System.err.print(iter.next() + " ");
289  System.err.print("\n----- ptArg: ");
290  for ( Iterator<String> iter = ptArg.iterator(); iter.hasNext(); )
291  System.err.print(iter.next() + " ");
292  */
293 
294  }
295 
296 
301  protected void detectSystemVariables()
302  throws Exception{
303  // Set operating system
304  //
305  final String osNam = System.getProperty("os.name").toLowerCase();
306  if (osNam.indexOf("windows") > -1){
307  os = osName.WINDOWS;
308  prop.put("BCVTB_OS", "windows");
309  }
310  else if (osNam.indexOf("mac") > -1){
311  os = osName.MAC;
312  prop.put("BCVTB_OS", "mac");
313  }
314  else if (osNam.indexOf("linux") > -1){
315  os = osName.LINUX;
316  prop.put("BCVTB_OS", "linux");
317  }
318  else
319  throw new Exception("Unsupported operating system " +
320  System.getProperty("os.name") + ".");
321  }
322 
327  protected String getBCVTBRoot()
328  throws FileNotFoundException {
329  // getResource uses / as the path separator, even on Windows
330  final String localPS = "/";
331  String dir = Launcher.class.getResource("Launcher.class").toString();
332  final String start = ( os == osName.WINDOWS ) ? "file:/" : "file:";
333  dir = dir.substring(dir.indexOf(start) + start.length(),
334  dir.indexOf("BCVTB.jar"));
335  // cut last file separator if string ends with a file separator
336  if (dir.endsWith(localPS))
337  dir = new String(dir.substring(0, dir.length()-1));
338  // If a directory has spaces in its name, then they show up
339  // as %20. This will cause File(..).exists() to return false.
340  // The next line fixes this problem.
341  dir = _replaceAll(dir, "%20", " ");
342  final String libPT = localPS + "lib" + localPS + "ptII";
343  while ( dir.indexOf(localPS) > -1 ){
344  final String fname = dir + libPT;
345  if (new File(fname).exists()){
346  break;
347  }
348  // Move up one entry in directory hierarchy
349  dir = dir.substring(0, dir.lastIndexOf(localPS, dir.length()-1));
350  }
351  // On some Java implementations, class.getResource does not return
352  // the full path, but rather bin/BCVTB.jar!/BCVTB/Lauchner.class
353  // if called from the bcvtb directory.
354  // In this situation, we set dir="." and check for "./lib/ptII"
355  if ( dir.equals("bin"))
356  dir =".";
357  if ( (!new File(dir+libPT).exists()) ){
358  final String em = "Error: Could not determine BCVTB root directory." + LS
359  + "Expected to find a directory that contains " + libPT + LS
360  + "Did you move the file BCVTB.jar?";
361  throw new FileNotFoundException(em);
362  }
363  if (os == osName.WINDOWS)
364  dir = dir.replace("/", "\\");
365  return dir;
366  }
367 
368  private static void _dumpProperties(Map<String, String> p){
369  System.err.println("********** Environment variables:");
370  TreeMap<String, String> tm = new TreeMap<String, String>();
371  tm.putAll(p);
372 
373  Iterator it = tm.entrySet().iterator();
374  while (it.hasNext()) {
375  Map.Entry pairs = (Map.Entry)it.next();
376  System.out.println(pairs.getKey() + " = " + pairs.getValue());
377  }
378  System.err.println("*********************************");
379  }
380 
386  boolean _isSet(String var){
387  boolean ret = (var != null && var.trim().length() > 0);
388  return ret;
389  }
390 
398  protected void setSystemVariable(final String name,
399  final String value){
400  // Check if it already exists and whether it needs to be
401  // substituted in the value
402  prop.put(name, value);
403  }
404 
405  private static String _replaceAll(final String s, final String pattern, final String value){
406  // To avoid an infinite loop, we return the string if the value contains the
407  // pattern
408  if (value != null && value.contains(pattern))
409  return s;
410  String ret = new String(s);
411  int i = ret.indexOf(pattern);
412  while(i > -1 ){
413  // if value == null, just remove the pattern, else replace it by the value
414  if ( value == null )
415  ret = new String(ret.substring(0, i) + ret.substring(i+pattern.length()));
416  else
417  ret = new String(ret.substring(0, i) + value + ret.substring(i+pattern.length()));
418  i = ret.indexOf(pattern);
419  }
420  return ret;
421  }
422 
423  private static String _replaceAllSystemVariables(final String s,
424  final String pattern,
425  final String value){
426  String ret = s;
427  final String osNam = System.getProperty("os.name").toLowerCase();
428  if (osNam.indexOf("windows") > -1) // have windows
429  ret = _replaceAll(ret, "%" + pattern + "%" , value);
430  else{
431  if (! pattern.equals(value)){
432  ret = _replaceAll(ret, "$" + pattern , value);
433  ret = _replaceAll(ret, "${" + pattern + "}", value);
434  }
435  }
436  return ret;
437  }
438 
442  protected void resolveEnvironmentVariable(){
443  Iterator itOut = prop.entrySet().iterator();
444  while (itOut.hasNext()) {
445  Map.Entry pairsOut = (Map.Entry)itOut.next();
446  // value of outer pair
447  String keyOut = (String)pairsOut.getKey();
448  String valOut = (String)pairsOut.getValue();
449  // iterate through all key/value maps
450  Iterator itIn = prop.entrySet().iterator();
451  while (itIn.hasNext()) {
452  Map.Entry pairsIn = (Map.Entry)itIn.next();
453  final String keyIn = (String)pairsIn.getKey();
454  final String valIn = (String)pairsIn.getValue();
455  valOut = _replaceAllSystemVariables(valOut, keyIn, valIn);
456  }
457  prop.put(keyOut, valOut);
458  }
459  }
460 
464  Iterator it = prop.entrySet().iterator();
465  while (it.hasNext()) {
466  Map.Entry pairs = (Map.Entry)it.next();
467  final String key = (String)pairs.getKey();
468  final String val = (String)pairs.getValue();
469 
470  Iterator itUsePro = userProp.entrySet().iterator();
471  while (itUsePro.hasNext()){
472  Map.Entry pairUsePro = (Map.Entry)itUsePro.next();
473  final String keyUsePro = (String)pairUsePro.getKey();
474  final String valUsePro = (String)pairUsePro.getValue();
475  userProp.setProperty(keyUsePro,
476  _replaceAllSystemVariables(valUsePro, key, val));
477  }
478  }
479  }
480 
484  private void _resolveReferences(){
485  Iterator it = userProp.entrySet().iterator();
486  while (it.hasNext()) {
487  Map.Entry pairs = (Map.Entry)it.next();
488  final String key = (String)pairs.getKey();
489  final String val = (String)pairs.getValue();
490 
491  Iterator itUsePro = userProp.entrySet().iterator();
492  while (itUsePro.hasNext()){
493  Map.Entry pairUsePro = (Map.Entry)itUsePro.next();
494  final String keyUsePro = (String)pairUsePro.getKey();
495  final String valUsePro = (String)pairUsePro.getValue();
496  userProp.setProperty(keyUsePro,
497  _replaceAllSystemVariables(valUsePro, key, val));
498  }
499  }
500  }
501 
502 
509  throws FileNotFoundException, Exception{
511  // Get root directory of BCVTB
512  final String root = getBCVTBRoot();
513  prop.put("BCVTB_HOME", root);
515  // Set PTII if it is not already set
516  String ptIIDir = prop.get("PTII");
517  if ( ! _isSet(ptIIDir) ){ // is not set
518  ptIIDir = root + PS + "lib" + PS + "ptII";
519  prop.put("PTII", ptIIDir);
520  }
522  // Read user property file
523  final String userPropertyFile = getUserPropertyFileName();
524  userProp = new Properties();
525  try{
526  userProp.loadFromXML(new FileInputStream(userPropertyFile));
527  }
528  catch(IOException e){
529  throw new IOException("IOException when reading user property file." + LS +
530  e.getMessage());
531  }
532  // Replace all new line characters. This avoids having environment
533  // variables such as
534  // PATH=\n/usr/local/energyplus
535  Iterator itUsePro = userProp.entrySet().iterator();
536  while (itUsePro.hasNext()){
537  Map.Entry pairUsePro = (Map.Entry)itUsePro.next();
538  final String key = (String)pairUsePro.getKey();
539  String val = (String)pairUsePro.getValue();
540  if ( val.indexOf(LS) != -1 ){
541  val = _replaceAll(val, LS, null);
542  userProp.setProperty(key, val);
543  }
544  }
546  // Set user properties to system properties
547  // Resolve references within user-defined properties
549  //Replace references to existing system properties
551 
552  Iterator itu = userProp.entrySet().iterator();
553  while (itu.hasNext()) {
554  Map.Entry pairs = (Map.Entry)itu.next();
555  final String key = (String)pairs.getKey();
556  final String val = ((String)pairs.getValue()).trim();
557  setSystemVariable(key, val);
558  }
559  updateClasspath();
561  // Resolve all references to environment variables
563  }
564 
569  protected int startProcess(){
570  int retVal = 1;
571  try {
572  Process p = pb.redirectErrorStream(true).start();
573  writeProcessOutput(p);
574  retVal = p.waitFor();
575  }
576  catch (IOException e) {
577  System.err.println(e.getMessage());
578  }
579  catch (InterruptedException e) {
580  System.err.println(e.getMessage());
581  }
582  catch (Exception e) {
583  System.err.println(e.getMessage());
584  }
585  return retVal;
586  }
587 
588 
589  static void writeProcessOutput(Process process) throws Exception{
590  InputStreamReader tempReader = new InputStreamReader(
591  new BufferedInputStream(process.getInputStream()));
592  BufferedReader reader = new BufferedReader(tempReader);
593  while (true){
594  String line = reader.readLine();
595  if (line == null)
596  break;
597  System.out.println(line);
598  }
599  }
600 
605  static void showThrowable(Throwable t){
606  System.err.println(t.getMessage());
607  t.printStackTrace();
608 
609  // Check for headless mode
610  final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
611 
612  if (!console && !ge.isHeadless())
613  javax.swing.JOptionPane.showMessageDialog(null,
614  t.getMessage(),
615  "BCVTB Error",
616  javax.swing.JOptionPane.ERROR_MESSAGE);
617  }
618 
621  public static void main(String[] args){
622  int retVal;
623  if (args.length ==2 && args[0].equals("--getEnvironmentVariable")){
624  // Initialize the environment variables
625  try{
626  Launcher l = new Launcher();
627  // Get the environment variable
628  final String key = args[1];
629  final String value = l.getProperty(key);
630  if ( value == null ){
631  final String filNam = l.getUserPropertyFileName();
632  final String em = "Did not find the entry '" + key + "' in the system variables " + LS +
633  "file '" + filNam + "'." + LS +
634  "Verify that '" + filNam + "'"+ LS +
635  "has an entry of the form" + LS +
636  " <entry key=\"" + key + "\">value</entry>";
637  Exception e = new Exception(em);
638  showThrowable(e);
639  retVal = 1;
640  }
641  else{
642  // On Windows, quote the value if it contais spaces
643  // Otherwise, the command
644  // for /F %%x in ('java -jar "%cd%\bin\BCVTB.jar" .... won't
645  // assign the full value to the variable
646  // final String osNam = System.getProperty("os.name").toLowerCase();
647  // if ( (osNam.indexOf("windows") > -1) && (value.trim()).contains(" ") )
648  // System.out.println("\"" + value + "\"");
649  // else
650  System.out.println(value);
651  retVal = 0;
652  }
653  }
654  catch(Exception e){
655  showThrowable(e);
656  retVal = 1;
657  }
658  }
659  else{
660  // Start the BCVTB
661  retVal = startBCVTB(args);
662  }
663  System.exit(retVal);
664  }
665 
670  protected static int startBCVTB(String[] args){
671  int retVal = 1; // will set to zero if process runs with no error
672  try{
673  Launcher l = new Launcher();
674  l.setCommand(args);
675  l.updateSystemFile();
676  retVal = l.startProcess();
677  }
678  catch(NoClassDefFoundError e){
679  showThrowable(e);
680  }
681  catch(Exception e){
682  showThrowable(e);
683  }
684  return retVal;
685  }
686 
693  protected void updateSystemFile()
694  throws FileNotFoundException, IOException, Exception{
695  if (ptFile == null)
696  return;
697  boolean foundText = false;
698  // If ptFile != null, then it exists. This was checked earlier.
699  FileReader fr = new FileReader(ptFile);
700  BufferedReader reader = new BufferedReader(fr);
701  String lin;
702  while ((lin = reader.readLine()) != null) {
703  if ((lin.indexOf("property name=\"startTime\"") > -1 )||
704  (lin.indexOf("property name=\"finalTime\"") > -1 )){
705  foundText = true;
706  break;
707  }
708  }
709  reader.close();
710  fr.close();
711  if (foundText){
712  String[] args = {"1.1", ptFile};
713  VersionUpdater.main(args);
714  }
715  }
716 
718  protected Properties userProp;
720  protected String ptFile;
722  protected boolean run;
724  protected boolean update;
726  protected static boolean console = false;
727 
729  protected Map<String,String> prop;
730 
732  protected String originalPath;
733 
735  protected ProcessBuilder pb;
736 
738  protected static final String PS = System.getProperty("file.separator");
739 
741  protected static final String LS = System.getProperty("line.separator");
742 
744  enum osName {WINDOWS, LINUX, MAC}
745 
747  protected osName os;
748 }
749 /********************************************************************
750 Copyright Notice
751 ----------------
752 
753 Building Controls Virtual Test Bed (BCVTB) Copyright (c) 2008-2009, The
754 Regents of the University of California, through Lawrence Berkeley
755 National Laboratory (subject to receipt of any required approvals from
756 the U.S. Dept. of Energy). All rights reserved.
757 
758 If you have questions about your rights to use or distribute this
759 software, please contact Berkeley Lab's Technology Transfer Department
760 at TTD@lbl.gov
761 
762 NOTICE. This software was developed under partial funding from the U.S.
763 Department of Energy. As such, the U.S. Government has been granted for
764 itself and others acting on its behalf a paid-up, nonexclusive,
765 irrevocable, worldwide license in the Software to reproduce, prepare
766 derivative works, and perform publicly and display publicly. Beginning
767 five (5) years after the date permission to assert copyright is obtained
768 from the U.S. Department of Energy, and subject to any subsequent five
769 (5) year renewals, the U.S. Government is granted for itself and others
770 acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide
771 license in the Software to reproduce, prepare derivative works,
772 distribute copies to the public, perform publicly and display publicly,
773 and to permit others to do so.
774 
775 
776 Modified BSD License agreement
777 ------------------------------
778 
779 Building Controls Virtual Test Bed (BCVTB) Copyright (c) 2008-2009, The
780 Regents of the University of California, through Lawrence Berkeley
781 National Laboratory (subject to receipt of any required approvals from
782 the U.S. Dept. of Energy). All rights reserved.
783 
784 Redistribution and use in source and binary forms, with or without
785 modification, are permitted provided that the following conditions are met:
786 
787  1. Redistributions of source code must retain the above copyright
788  notice, this list of conditions and the following disclaimer.
789  2. Redistributions in binary form must reproduce the above copyright
790  notice, this list of conditions and the following disclaimer in
791  the documentation and/or other materials provided with the
792  distribution.
793  3. Neither the name of the University of California, Lawrence
794  Berkeley National Laboratory, U.S. Dept. of Energy nor the names
795  of its contributors may be used to endorse or promote products
796  derived from this software without specific prior written permission.
797 
798 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
799 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
800 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
801 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
802 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
803 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
804 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
805 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
806 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
807 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
808 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
809 
810 You are under no obligation whatsoever to provide any bug fixes,
811 patches, or upgrades to the features, functionality or performance of
812 the source code ("Enhancements") to anyone; however, if you choose to
813 make your Enhancements available either publicly, or directly to
814 Lawrence Berkeley National Laboratory, without imposing a separate
815 written license agreement for such Enhancements, then you hereby grant
816 the following license: a non-exclusive, royalty-free perpetual license
817 to install, use, modify, prepare derivative works, incorporate into
818 other computer software, distribute, and sublicense such enhancements or
819 derivative works thereof, in binary and source code form.
820 
821 ********************************************************************
822 */
823 
void _replaceEnvironmentVariables()
Resolves all references to existing environment variables in the user properties. ...
Definition: Launcher.java:463
boolean update
Flag, true if user set -update flag.
Definition: Launcher.java:724
for i
Definition: compile.m:69
Properties userProp
User properties.
Definition: Launcher.java:718
static final String PS
File separator.
Definition: Launcher.java:738
osName os
The operating system.
Definition: Launcher.java:747
ProcessBuilder pb
The process builder to start Ptolemy.
Definition: Launcher.java:735
void _resolveReferences()
Resolves all references within the user properties.
Definition: Launcher.java:484
function retVal
Definition: closeIPC.m:1
void resolveEnvironmentVariable()
Resolves all references to environment variables in the properties.
Definition: Launcher.java:442
void setupCommandList(String[] args, ArrayList< String > comLis)
Sets up the argument list if the first flag is -command
Definition: Launcher.java:44
static String _replaceAll(final String s, final String pattern, final String value)
Definition: Launcher.java:405
void setSystemVariable(final String name, final String value)
Sets the variable to the system properties.
Definition: Launcher.java:398
static void XMLCALL start(void *data, const char *el, const char **attr)
Call back functions that will be used by the expat xml parser.
Definition: util/utilXml.c:675
static void main(String[] args)
Main method.
Definition: Launcher.java:621
String originalPath
The path variable.
Definition: Launcher.java:732
static int startBCVTB(String[] args)
Starts the BCVTB.
Definition: Launcher.java:670
static String _replaceAllSystemVariables(final String s, final String pattern, final String value)
Definition: Launcher.java:423
String ptFile
Ptolemy file, or null if not specified.
Definition: Launcher.java:720
Launcher()
Constructor.
Definition: Launcher.java:21
static final String LS
Line separator.
Definition: Launcher.java:741
String getProperty(final String key)
Gets a system property.
Definition: Launcher.java:144
void setupPtolemyArguments(String[] args, ArrayList< String > ptArgs, ArrayList< String > JVMFlags)
Sets up the argument list if the first flag is not -command
Definition: Launcher.java:81
void initializeEnvironmentVariables()
Initializes the settings of environment variables.
Definition: Launcher.java:508
String getBCVTBRoot()
Gets the root directory of the BCVTB.
Definition: Launcher.java:327
int startProcess()
Starts the process.
Definition: Launcher.java:569
void updateSystemFile()
Update the ptFile if it is from an old version.
Definition: Launcher.java:693
boolean run
Flag, true if user set -run flag.
Definition: Launcher.java:722
void detectSystemVariables()
Detect system variables.
Definition: Launcher.java:301
static boolean console
Flag, true if user set -console flag.
Definition: Launcher.java:726
Map< String, String > prop
The properties of the process builder.
Definition: Launcher.java:729
String getUserPropertyFileName()
Get the user property file name.
Definition: Launcher.java:153
static void _dumpProperties(Map< String, String > p)
Definition: Launcher.java:368