Author: chatellier Date: 2011-07-18 15:38:28 +0000 (Mon, 18 Jul 2011) New Revision: 3446 Log: Launch sub simulations with R args Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2011-07-15 13:12:45 UTC (rev 3445) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2011-07-18 15:38:28 UTC (rev 3446) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin, Benjamin Poussin + * Copyright (C) 2002 - 2011 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -36,6 +36,7 @@ import java.net.URLClassLoader; import java.rmi.RemoteException; import java.util.ArrayList; +import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -185,28 +186,50 @@ log.debug("classpath to use : " + classpath); } + // common args + List<String> command = new ArrayList<String>(); + command.add(java); + command.add("-Xmx1024M"); + + // jri args + String libraryPath = System.getProperty("java.library.path"); + if (StringUtils.isNotBlank(libraryPath)) { + command.add("-Djava.library.path=\"" + libraryPath + "\""); + } + String rType = System.getProperty("R.type"); + if (StringUtils.isNotBlank(rType)) { + command.add("-DR.type=\"" + rType + "\""); + } + + // common args + command.add("-classpath"); + command.add(classpath); + command.add(IsisFish.class.getName()); + command.add("--option"); + command.add("launch.ui"); + command.add("false"); + // prepare le process ProcessBuilder processBuilder = null; if (tempPrescriptFile != null) { - processBuilder = new ProcessBuilder(java, "-Xmx1024M", "-classpath", - classpath, IsisFish.class.getName(), "--option", "launch.ui", - "false", "--simulateWithSimulationAndScript", simulationId, - simulationZip.getAbsolutePath(), tempPrescriptFile.getAbsolutePath()); + command.add("--simulateWithSimulationAndScript"); + command.add(simulationId); + command.add(simulationZip.getAbsolutePath()); + command.add(tempPrescriptFile.getAbsolutePath()); } else { - processBuilder = new ProcessBuilder(java, "-Xmx1024M", "-classpath", - classpath, IsisFish.class.getName(), "--option", "launch.ui", - "false", "--simulateWithSimulation", simulationId, - simulationZip.getAbsolutePath()); + command.add("--simulateWithSimulation"); + command.add(simulationId); + command.add(simulationZip.getAbsolutePath()); } + processBuilder = new ProcessBuilder(command); processBuilder.redirectErrorStream(true); // demarrage du process Process process = processBuilder.start(); if (log.isInfoEnabled()) { - log.info(_("SubProcess start: %s %s", process, processBuilder - .command())); + log.info(_("SubProcess start: %s %s", process, processBuilder.command())); } // prepare de thread de surveillance du process si control n'est pas null @@ -246,8 +269,7 @@ public SimulationCheckpointExternalProcessThread( SimulationControl control, String simulationId, Process process) { if (log.isInfoEnabled()) { - log - .info("Lancement du thread de surveillance des simulations externes"); + log.info("Lancement du thread de surveillance des simulations externes"); } this.control = control; this.simulationId = simulationId;