Examples of ExecutionHandler


Examples of util.io.ExecutionHandler

        String params = Settings.propUserDefinedWebbrowserParams.getString().replace("{0}", url);

        // Test if the JVM is a Mac-VM and the Application is an .app-File.
        // These Files must be launched differently
        if ((getOs() == OS_MAC) && (browserExecutable.trim().toLowerCase().endsWith(".app"))) {
          new ExecutionHandler(new String[] { "open", "-a", browserExecutable, params }).execute();
        } else {
          new ExecutionHandler(new String[] { browserExecutable, params }).execute();
        }
      } else {
        boolean opened = false;
        // Java 6 specific code of how to run the browser
        if (Desktop.isDesktopSupported()) {
View Full Code Here

Examples of util.io.ExecutionHandler

                    aeDesc = null// Encourage it to get disposed if it was created
                    browser = null; // Ditto
                }
                break;
            case MRJ_2_1:
                new ExecutionHandler(new String[] { (String) browser, url }).execute();
                break;
            case MRJ_3_0:
                int[] instance = new int[1];
                int result = ICStart(instance, 0);
                if (result == 0) {
                    int[] selectionStart = new int[] { 0 };
                    byte[] urlBytes = url.getBytes();
                    int[] selectionEnd = new int[] { urlBytes.length };
                    result = ICLaunchURL(instance[0], new byte[] { 0 }, urlBytes,
                                            urlBytes.length, selectionStart,
                                            selectionEnd);
                    if (result == 0) {
                        // Ignore the return value; the URL was launched successfully
                        // regardless of what happens here.
                        ICStop(instance);
                    } else {
                        throw new IOException("Unable to launch URL: " + result);
                    }
                } else {
                    throw new IOException("Unable to create an Internet Config instance: " + result);
                }
                break;
            case MRJ_3_1:
            case MRJ_COCOA:
                try {
                    openURL.invoke(null, new Object[] { url });
                } catch (InvocationTargetException ite) {
                    throw new IOException("InvocationTargetException while calling openURL: " + ite.getMessage());
                } catch (IllegalAccessException iae) {
                    throw new IOException("IllegalAccessException while calling openURL: " + iae.getMessage());
                }
                break;
            case WINDOWS_NT:
            case WINDOWS_9x:
                // Add quotes around the URL to allow ampersands and other special
                // characters to work.
                String[] arguments;
                if (jvm == WINDOWS_9x) {
                    arguments = new String[] { (String) browser,
                                          FIRST_WINDOWS_PARAMETER,
                                          SECOND_WINDOWS_PARAMETER,
                                          null };
                } else {
                    arguments = new String[] { (String) browser,
                                          FIRST_WINDOWS_PARAMETER,
                                          SECOND_WINDOWS_PARAMETER,
                                          THIRD_WINDOWS_PARAMETER,
                                          null };
                }
                arguments[arguments.length - 1] = '"' + url + '"';
                ExecutionHandler executionHandler = new ExecutionHandler(arguments);
                executionHandler.execute();
               
                // This avoids a memory leak on some versions of Java on Windows.
                // That's hinted at in <http://developer.java.sun.com/developer/qow/archive/68/>.
                try {
                    executionHandler.getProcess().waitFor();
                    executionHandler.exitValue();
                } catch (InterruptedException ie) {
                    throw new IOException("InterruptedException while launching browser: " + ie.getMessage());
                }
                break;
            case OTHER:
                // Assume that we're on Unix and that Netscape is installed
               
                // Attempt to open the URL in a currently running session of Netscape
                executionHandler = new ExecutionHandler(new String[] { (String) browser,
                                                    NETSCAPE_REMOTE_PARAMETER,
                                                    NETSCAPE_OPEN_PARAMETER_START +
                                                    url +
                                                    NETSCAPE_OPEN_PARAMETER_END });
                executionHandler.execute();
               
                try {
                    int exitCode = executionHandler.getProcess().waitFor();
                    if (exitCode != 0) {    // if Netscape was not open
                        new ExecutionHandler(new String[] { (String) browser, url }).execute();
                    }
                } catch (InterruptedException ie) {
                    throw new IOException("InterruptedException while launching browser: " + ie.getMessage());
                }
                break;
            default:
                // This should never occur, but if it does, we'll try the simplest thing possible
                new ExecutionHandler(new String[] { (String) browser, url }).execute();
                break;
        }
    }
View Full Code Here

Examples of util.io.ExecutionHandler

   * @param params
   *          Params for the Application
   * @return Output of Application
   */
  private String executeApplication(String params) {
    ExecutionHandler executionHandler;

    try {
      executionHandler = new ExecutionHandler(params, mData.getProgramPath());
      executionHandler.execute(true, true);
    } catch (Exception e) {
      ErrorHandler.handle(mLocalizer.msg("ProblemAtStart", "Problems while starting Application."), e);
      return null;
    }

    int time = 0;

    // wait until the process has exited, max MaxTimouts

    if (mData.getTimeout() > 0) {
      while (time < mData.getTimeout() * 1000) {
        try {
          Thread.sleep(100);
          time += 100;
          executionHandler.exitValue();
          break;
        } catch (Exception e) {
          // Empty
        }
      }
    } else {
      while (true) {
        try {
          Thread.sleep(100);
          executionHandler.exitValue();
          break;
        } catch (Exception e) {
          // Empty
        }
      }
    }

    while (time < mData.getTimeout() * 1000) {
      try {
        Thread.sleep(100);
        time += 100;
        executionHandler.exitValue();
        break;
      } catch (Exception e) {
        // Empty
      }
    }

    // get the process output
    String output = "";
    String errors = ""; // also capture STDERR output FSCHAECK - 2008-06-13

    if (!executionHandler.getInputStreamReaderThread().isAlive()) {
      output = executionHandler.getOutput();
    }

    // read STDERR output and add to return value if necessary - FSCHAECK -
    // 2008-06-13
    if (!executionHandler.getErrorStreamReaderThread().isAlive()) {
      errors = executionHandler.getOutput();
      if (errors.length() > 0) {
        if (output.length() > 0) {
          output = output + "\n\n" + errors;
        } else {
          output = errors;
        }
      }
    }

    mError = executionHandler.exitValue() != 0;
    mExitValue = executionHandler.exitValue();

    return output;
  }
View Full Code Here

Examples of util.io.ExecutionHandler

      } else {
        application = mSettings.getApplication();
        execparam = getContentParameter(content);
      }

      new ExecutionHandler(execparam, application).execute();

      if (mSettings.getShowEmailOpened()) {
        showEMailOpenedDialog(parent);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.