Package org.rzo.yajsw.os

Examples of org.rzo.yajsw.os.Process


    /*
     * WindowsXPProcess p = new WindowsXPProcess(); p.setCommand("notepad");
     * p.setUser("test\\yajsw"); p.setPassword("yajsw"); p.start();
     */
    // getProcess(3332);
    Process p = new WindowsXPProcess();
    // p.setCommand("ping 127.0.0.1");
    p.setCommand("set.bat");
    List<String[]> env = OperatingSystem.instance().processManagerInstance().getProcess(
        OperatingSystem.instance().processManagerInstance().currentProcessId()).getEnvironment();
    p.setEnvironment(env);
    System.out.println(p.getEnvironmentAsMap().get("Path"));
    System.out.println(env.get(0)[0]);
    p.setPipeStreams(true, false);
    p.start();
    String line = null;
    int k = 0;
    try
    {
      InputStreamReader isr = new InputStreamReader(p.getInputStream());
      BufferedReader br = new BufferedReader(isr);
      line = br.readLine();
      System.out.println(line);
      while (k < 30 && line != null)
      {
View Full Code Here


    setState(STATE_SHUTDOWN);
  }

  public void osProcessTerminated()
  {
    Process process = _osProcess;
    if (process != null)
      _exitCode = process.getExitCode();
  }
View Full Code Here

  {
    if (config == null)
      return null;
    String wrapperConfFileName = config.getCachedPath(false);

    final Process _osProcess = OperatingSystem.instance().processManagerInstance().createProcess();

    try
    {
      _osProcess.setCommand(new String[]
      { getJava(), "-cp", WrapperLoader.getWrapperHome() + "/wrapper.jar", TrayIconMainBooter.class.getName(), wrapperConfFileName });
      _osProcess.setPipeStreams(false, false);
      _osProcess.setVisible(false);
      _osProcess.start();
      Runtime.getRuntime().addShutdownHook(new Thread()
      {
        public void run()
        {
          if (_osProcess != null)
            _osProcess.kill(0);
        }
      });
      return _osProcess;
    }
    catch (Exception e)
View Full Code Here

  }

  private String getCurrentJava()
  {
    int myPid = OperatingSystem.instance().processManagerInstance().currentProcessId();
    Process myProcess = OperatingSystem.instance().processManagerInstance().getProcess(myPid);
    String cmd = myProcess.getCommand();
    String jvm = null;
    if (cmd.startsWith("\""))
      jvm = cmd.substring(0, cmd.indexOf("\" ") + 1);
    else
      jvm = cmd.substring(0, cmd.indexOf(" "));
View Full Code Here

    String count = "" + _process.getRestartCount();
    String pid = "" + _process.getAppPid();
    String exitCode = "" + _process.getExitCode();
    try
    {
      Process p = OperatingSystem.instance().processManagerInstance().createProcess();
      p.setCommand(getScript() + " " + id + " " + state + " " + count + " " + pid + " " + exitCode);
      p.setPipeStreams(false, false);
      p.start();
      p.waitFor(getTimeout());
      if (p.isRunning())
        p.kill(999);
      if (p.getExitCode() != 0)
        System.out.println("script " + getScript() + "returned " + p.getExitCode());
      p.destroy();
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
View Full Code Here

    System.exit(-1);
  }

  public static void generate(int pid, File input, File output)
  {
    Process p = OperatingSystem.instance().processManagerInstance().getProcess(pid);
    if (p == null)
    {
      System.out.println("cannot find process " + pid);
      return;
    }
    String cmd = p.getCommand().trim();
    if (cmd == null)
    {
      System.out.println("cannot get command line of process");
      return;
    }
View Full Code Here

    {
        for (Integer pp :  pids)
          {
          if (pp != pid)
          {
           Process ppp = OperatingSystem.instance().processManagerInstance().getProcess(pp);
           if (ppp == null)
           {
             System.out.println("no access right to pid "+pp);
             continue;
           }
           if (ppp.getCommand().trim().endsWith("Main")||ppp.getCommand().trim().endsWith("Main\""))
             result = pp;
          }
    }
  }
    return result;
View Full Code Here

  {
    Map<String, ServiceInfo> result = new HashMap<String, ServiceInfo>();
    Map<Integer, Integer> processes = WindowsXPProcess.getProcessMaps(0)[0];
    for (Integer pid : processes.keySet())
    {
      Process p = _processes.get(pid);
      if (p == null)
      {
        p = WindowsXPProcess.getProcess(pid);
        if (p == null)
          continue;
        _processes.put(pid, p);
      }
      String cmd = p.getCommand();
      if (cmd != null && cmd.contains("wrapper.jar\" -c"))
      {
        JCLParser jp = JCLParser.parse(cmd);
        ServiceInfoImpl service = new ServiceInfoImpl();
        service.setCommand(cmd);
        String confFile = jp.getArgs().get(1);
        if (confFile == null)
          continue;
        File f = new File(confFile);
        if (!f.exists())
          f = new File(p.getWorkingDir(), confFile);
        service.setDisplayName(f.getAbsolutePath());
        service.setName(jp.getArgs().get(1));
        service.setPid(pid);
        service.setWrapperAppPid(getAppPid(pid));
        service.setAccount(p.getUser());
        result.put(service.getName(), service);
      }
      Set<Integer> newPids = new HashSet<Integer>(processes.keySet());
      Set<Integer> toRemove = new HashSet<Integer>(_processes.keySet());
      toRemove.removeAll(newPids);
View Full Code Here

  {
    AbstractWrappedProcessMBean  proxy = null;
    try
    {
    String config = name;
    Process p = _processes.get(_services.get(name).getPid());
    File f = new File(p.getWorkingDir(), config);
    if (!f.exists())
    {
      System.out.println("file not found "+f.getAbsolutePath());
      //return null;
    }
View Full Code Here

  }

  private String getCurrentJava()
  {
    int myPid = OperatingSystem.instance().processManagerInstance().currentProcessId();
    Process myProcess = OperatingSystem.instance().processManagerInstance().getProcess(myPid);
    String cmd = myProcess.getCommand();
    String jvm = null;
    if (cmd.startsWith("\""))
      jvm = cmd.substring(0, cmd.indexOf("\" ") + 1);
    else
      jvm = cmd.substring(0, cmd.indexOf(" "));
View Full Code Here

TOP

Related Classes of org.rzo.yajsw.os.Process

Copyright © 2018 www.massapicom. 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.