gt:                     String value = (String) m.invoke(jobConfig, new Object[] {});
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 ActiveEon Team
   *                        http://www.activeeon.com/
   *  Contributor(s):
   *
   * ################################################################
   * $$ACTIVEEON_INITIAL_DEV$$
   */
  package org.ow2.proactive.scheduler.ext.filessplitmerge;
  
  import java.io.File;
  import java.io.IOException;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.net.URISyntaxException;
  import java.net.UnknownHostException;
  import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.List;
  
  import javax.security.auth.login.LoginException;
  
  import org.objectweb.proactive.ActiveObjectCreationException;
  import org.objectweb.proactive.core.node.NodeException;
  import org.ow2.proactive.scheduler.common.exception.SchedulerException;
  import org.ow2.proactive.scheduler.common.exception.UserException;
  import org.ow2.proactive.scheduler.common.job.Job;
  import org.ow2.proactive.scheduler.common.job.JobEnvironment;
  import org.ow2.proactive.scheduler.common.job.JobId;
  import org.ow2.proactive.scheduler.common.job.JobPriority;
  import org.ow2.proactive.scheduler.common.job.TaskFlowJob;
  import org.ow2.proactive.scheduler.common.task.NativeTask;
  import org.ow2.proactive.scheduler.common.task.RestartMode;
  import org.ow2.proactive.scheduler.ext.filessplitmerge.exceptions.InvalidInputDataException;
  import org.ow2.proactive.scheduler.ext.filessplitmerge.exceptions.NotInitializedException;
  import org.ow2.proactive.scheduler.ext.filessplitmerge.logging.LoggerManager;
  import org.ow2.proactive.scheduler.ext.filessplitmerge.util.MySchedulerProxy;
  import org.ow2.proactive.scripting.GenerationScript;
  import org.ow2.proactive.scripting.InvalidScriptException;
  import org.ow2.proactive.scripting.Script;
  import org.ow2.proactive.scripting.SimpleScript;
  import org.ow2.proactive.utils.Tools;
  
  
  /**
   * This is an abstract class that creates and submits a job to the Scheduler see
   * javadoc for {@link #createNativeTask(File, int)} method in order to
   * understand the methods of this class that you must override in order to
   * enable tasks creation
   * 
   * @author esalagea
   * 
   */
  public abstract class JobCreator {
  
      public static int DEFAULT_MAX_NB_OF_EXECUTION_PER_TASK = 5;
  
      /**
       * Creates a TaskFlow job and submits it to the Scheduler.<p/> The
       * scheduler url, username and password are the ones that have been used to
       * initiate the {@link EmbarrasinglyParrallelApplication} singleton object
       * <p/> this method calls
       * {@link #submitJob(String, String, String, String, String, JobPriority, boolean, String, JobConfiguration)}
       * 
       * @param jobName
       * @param jobDescription
       * @param priority
       * @param cancelJobOnTaskError
       *            if set to true, the job will be canceled if a task fails
       * @param jobConfiguration -
       *            an object containing the configuration for this job. This
       *            object will be passed in parameter, when the job finishes, to
       *            the
       *            {@link JobPostTreatmentManager#mergeResults(JobConfiguration, int)}
       * @throws SchedulerException
       * @throws LoginException
       * @throws IOException
       * @throws InvalidScriptException
       * @throws InvalidInputDataException
       * @throws NotInitializedException
       */
      public void submitJob(String jobName, String jobDescription, JobPriority priority,
              boolean cancelJobOnTaskError, JobConfiguration jobConfiguration) throws SchedulerException,
              IOException, InvalidScriptException, InvalidInputDataException, NotInitializedException {
          String schedulerURL = EmbarrasinglyParrallelApplication.instance().getScheduelrURL();
          String username = EmbarrasinglyParrallelApplication.instance().getUserName();
          String password = EmbarrasinglyParrallelApplication.instance().getSchedulerPassword();
          this.submitJob(jobName, jobDescription, schedulerURL, username, password, priority,
                  cancelJobOnTaskError, jobConfiguration);
      }
  
      /**
       * Creates and submits a TaskFlow job to the scheduler. The job is composed
       * by a number of n native tasks: - the number n of native tasks is given by
       * the the size of the list returned by the <{@link #splitData()} method
       * (each member of the list represents the input data for a single task) -
       * the command line for a task is given by the <{@link #createCommandLineForTask(File, int) }
       * method - the pre-script, post-script and clean-script filePaths and
       * arguments are given by the respective methods - the restart mode and the
       * result preview for each task are given by the respective methods
       * 
       * @param jobName
       * @param jobDescription
       * @param schedulerURL
       * @param username
       * @param password
       * @param priority
       * @param cancelJobOnTaskError
       *            if set to true, the job will be canceled if a task fails
       * @param jobConfiguration -
       *            an object containing the configuration for this job. This
       *            object will be passed in parameter, when the job finishes, to
       *            the
       *            {@link JobPostTreatmentManager#mergeResults(JobConfiguration, int)}
       * @throws SchedulerException
       * @throws LoginException
       * @throws IOException
       * @throws InvalidScriptException
       * @throws InvalidInputDataException
       * @throws NotInitializedException
       */
      public void submitJob(String jobName, String jobDescription, String schedulerURL, String username,
              String password, JobPriority priority, boolean cancelJobOnTaskError,
              JobConfiguration jobConfiguration) throws SchedulerException, IOException,
              InvalidScriptException, InvalidInputDataException, NotInitializedException {
  
          //		SchedulerAuthenticationInterface auth = SchedulerConnection
          //				.join(schedulerURL);
          //		UserSchedulerInterface uischeduler = auth.logAsUser(username, password);
  
          TaskFlowJob job = new TaskFlowJob();
  
          job.setName(jobName);
          job.setDescription(jobDescription);
  
          job.setPriority(priority);
          job.setCancelJobOnError(cancelJobOnTaskError);
  
          List<File> splittedData = splitData();
          List<NativeTask> tasks = null;
          tasks = createTasks(splittedData);
          Iterator<NativeTask> it = tasks.iterator();
          while (it.hasNext()) {
              NativeTask nt = it.next();
              try {
                  job.addTask(nt);
              } catch (UserException e2) {
                  e2.printStackTrace();
              }
          }
  
          attachGenericInformationtoJob(jobConfiguration, job);
          setJobClasPath(job);
  
          // ******************** SUBMIT THE JOB ***********************
          // submitting a job to the scheduler returns the corresponding jobId
          // this id will be used to talk to the scheduler about this job.
          JobId jobId = null;
          try {
              jobId = MySchedulerProxy.getActiveInstance().submit(job);
          } catch (ActiveObjectCreationException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (NodeException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              return;
          }
  
          // Add this id to the GoldJobPostTreatmentManager as an awaited job
          // This way, the GoldJobPostTreatmentManager will merge the results of
          // this
          // job when it is finished
          JobPostTreatmentManagerHolder.getPostTreatmentManager().addAwaitedJob(jobId.value());
      }
  
      /**
       * This method adds to the job the classpath of the current application. It
       * calls {@link Job#setEnvironment(JobEnvironment)} method As the job
       * created by the {@link JobCreator} only contains NativeTasks, the
       * classpath will only be needed in order to show the results preview in the
       * Scheduler GUI
       * 
       * 
       * Note: The classpsth is serialized and sent to the Scheduler server as
       * byte array. If you don't use result preview in your application,there's
       * no need for this method to be called. Therefore, if
       * {@link #getDefaultResultPreviewClassName()} returns null or an empty
       * String, this method will return
       * 
       * 
       * IMPORTNAT: This method modifies the Job object in argument
       * 
       * @param job
       */
      protected void setJobClasPath(Job job) {
  
          if ((getDefaultResultPreviewClassName() == null) ||
              (getDefaultResultPreviewClassName().trim().equals("")))
              return;
  
          String appClassPath = "";
          try {
              File appMainFolder = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation()
                      .toURI());
              appClassPath = appMainFolder.getAbsolutePath();
  
          } catch (URISyntaxException e1) {
              LoggerManager
                      .getInstane()
                      .warning(
                              "Preview of the partial results will not be possible as some ressources could not be found by the system. \nThis will not alterate your results in any way. ");
              LoggerManager
                      .getLogger()
                      .warn(
                              "JobCreator: The bin folder of the project is null. It is needed to set the job environment. ",
                              e1);
          }
  
          JobEnvironment je = new JobEnvironment();
          try {
              je.setJobClasspath(new String[] { appClassPath });
          } catch (IOException e) {
  
              LoggerManager
                      .getInstane()
                      .warning(
                              "Preview of the partial results will not be possible as the job classpath could not be loaded. \nThis will not alterate your results in any way.");
              LoggerManager.getLogger().warn("Could not add classpath to the job. ", e);
          }
          job.setEnvironment(je);
      }
  
      /**
       * Attach all the attributes A (given by pair of getA()/setA()) in the
       * jobConfigObject as generic information to the job. The key of the generic
       * information is the attribute name (i.e. A) and the value is the result of
       * the getter. This only applies for the attributes of type String.
       * 
       * @param jobConfig
       * @param job
       */
      private void attachGenericInformationtoJob(JobConfiguration jobConfig, TaskFlowJob job) {
          Class<? extends JobConfiguration> clazz = jobConfig.getClass();
          Method[] ms = clazz.getMethods();
  
          for (int i = 0; i < ms.length; i++) {
              Method m = ms[i];
              if ((m.getName().startsWith("get")) && (m.getReturnType() == String.class) &&
                  (m.getParameterTypes().length == 0)) {
  
                  try {
  