gt:             return new HashMap<String, String>(0);
context: /*
   * ################################################################
   *
   * ProActive Parallel Suite(TM): The Java(TM) library for
   *    Parallel, Distributed, Multi-Core Computing for
   *    Enterprise Grids & Clouds
   *
   * Copyright (C) 1997-2011 INRIA/University of
   *                 Nice-Sophia Antipolis/ActiveEon
   * Contact: proactive@ow2.org or contact@activeeon.com
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Affero General Public License
   * as published by the Free Software Foundation; version 3 of
   * the License.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this library; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
   * USA
   *
   * If needed, contact us to obtain a release under GPL Version 2 or 3
   * or a different license than the AGPL.
   *
   *  Initial developer(s):               The ProActive Team
   *                        http://proactive.inria.fr/team_members.htm
   *  Contributor(s): ActiveEon Team - http://www.activeeon.com
   *
   * ################################################################
   * $$ACTIVEEON_CONTRIBUTOR$$
   */
  package org.ow2.proactive.scheduler.common.task;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  
  import org.objectweb.proactive.annotation.PublicAPI;
  import org.ow2.proactive.db.types.BigString;
  import org.ow2.proactive.scheduler.common.exception.ExecutableCreationException;
  import org.ow2.proactive.scripting.InvalidScriptException;
  import org.ow2.proactive.scripting.Script;
  import org.ow2.proactive.scripting.SimpleScript;
  
  
  /**
   * Class representing a forked environment of a JVM created specifically for an execution of a Java Task.
   * A Java Task can be executed in the current JVM - then all Java Tasks are dependent on the same JVM (provider) and JVM options (like memory),
   * or can be executed in a dedicated JVM with additional options specified like javaHome, java Arguments, classpath, ...
   *
   * @author ProActive team
   *
   */
  @PublicAPI
  @XmlAccessorType(XmlAccessType.FIELD)
  public class ForkEnvironment implements Serializable {
  
      /**
       * Path to directory with Java installed, to this path '/bin/java' will be added.
       * If the path is null only 'java' command will be called
       */
      private String javaHome = null;
  
      /**
       * Path to the working directory
       */
      private String workingDir = null;
  
      /**
       * Base environment : used by internal constructor to set up
       * a base environment on which to apply client env
       */
      private transient Map<String, String> baseSystemEnvironment = null;
  
      /**
       * User custom system environment : can modify base env or create new variable
       */
      private List<PropertyModifier> systemEnvironment = null;
  
      /**
       * Arguments passed to Java (not an application) (example: memory settings or properties)
       */
      private List<BigString> jvmArguments = null;
  
      /**
       * Additional classpath when new JVM will be started
       */
      private List<BigString> additionalClasspath = null;
  
      /**
       * EnvScript : can be used to initialize environment just before JVM fork.
       */
      private Script<?> script = null;
  
      public ForkEnvironment() {
      }
  
      /**
       * This constructor is used for internal stuff only.
       * It allows an internal subtype to create a ForkEnvironement with a base env.
       *
       * @param forkEnv the fork environment that should be decorated with a base env, if null, empty fork env will be used
       * @param baseEnv the environment on witch to base the user env.
       */
      protected ForkEnvironment(ForkEnvironment forkEnv, Map<String, String> baseEnv) {
          this.baseSystemEnvironment = baseEnv;
          if (forkEnv != null) {
              this.javaHome = forkEnv.javaHome;
              this.workingDir = forkEnv.workingDir;
              this.systemEnvironment = forkEnv.systemEnvironment;
              this.jvmArguments = forkEnv.jvmArguments;
              this.additionalClasspath = forkEnv.additionalClasspath;
              this.script = forkEnv.script;
          }
      }
  
      /**
       * Copy constructor
       * 
       * @param f the object to copy
       * @throws ExecutableCreationException script copy failed
       */
      public ForkEnvironment(ForkEnvironment f) throws ExecutableCreationException {
          if (f.javaHome != null)
              this.javaHome = new String(f.javaHome);
          if (f.workingDir != null)
              this.workingDir = new String(f.workingDir);
          if (f.systemEnvironment != null) {
              for (PropertyModifier prop : f.systemEnvironment) {
                  this.addSystemEnvironmentVariable(new String(prop.getName()), new String(prop.getValue()),
                          prop.getAppendChar());
              }
          }
          if (f.jvmArguments != null) {
              for (BigString bs : f.jvmArguments) {
                  this.addJVMArgument(new String(bs.getValue()));
              }
          }
          if (f.additionalClasspath != null) {
              for (BigString bs : f.additionalClasspath) {
                  this.addAdditionalClasspath(new String(bs.getValue()));
              }
          }
          if (f.script != null) {
              try {
                  this.script = new SimpleScript(f.script);
              } catch (InvalidScriptException e) {
                  throw new ExecutableCreationException("Failed to copy ForkEnvironment Script", e);
              }
          }
      }
  
      /**
       * Returns the javaHome.
       *
       * @return the javaHome.
       */
      public String getJavaHome() {
          return javaHome;
      }
  
      /**
       * Sets the javaHome to the given javaHome value.
       *
       * @param javaHome the javaHome to set.
       */
      public void setJavaHome(String javaHome) {
          this.javaHome = javaHome;
      }
  
      /**
       * Return the working Directory
       *
       * @return the working Directory
       */
      public String getWorkingDir() {
          return workingDir;
      }
  
      /**
       * Set the working directory value to the given workingDir value
       *
       * @param workingDir the working directory to set
       */
      public void setWorkingDir(String workingDir) {
          this.workingDir = workingDir;
      }
  
      /**
       * Return a copy of the system environment, empty map if no variables.
       *
       * @return a copy of the system environment, empty map if no variables.
       */
      public Map<String, String> getSystemEnvironment() {
          if (this.systemEnvironment == null && this.baseSystemEnvironment == null) {
  