Hi Pavel,

We start Xindice by using Runtime.exec() and sending the Xindice command
with config parameters for the JVM and for Xindice. We detect whether
it's running by waiting for an output message of "Server Running" (there
is probably a better way to do this, but I don't know what it is!).

The code is below - maybe it will help you...
Cheers,
Catie

/**
   * Runs the system command to start the DBServer
   * @todo: make bulletproof, handle errors & exceptions, etc
   */
  protected void startCommand()
  {

    File execDir = new File( XindiceUtil.getInstance().getXindiceHome()
);
    try
    {
      _serverProcess = Runtime.getRuntime().exec(START_COMMAND, ENV,
execDir);
      InputStream inputStream = _serverProcess.getInputStream();
      BufferedReader reader = new BufferedReader ( new
InputStreamReader(inputStream) );

      InputStream error = _serverProcess.getErrorStream();
      BufferedReader errRead = new BufferedReader ( new
InputStreamReader(error) );

      try
      {
        String line = null;
        boolean serverStarted = false;
        while ( !serverStarted )
        {
            while (errRead.ready())
            {
              line = errRead.readLine();
              System.out.println(line);
              System.out.println("ERROR LINE IS: " + line);
            }
            while(reader.ready())
            {
              line = reader.readLine();
              System.out.println("LINE IS: " + line);
            }
            if (line != null && line.indexOf("Server Running") != -1 )
            {
               serverStarted = true;
               setStarted(true);
            }
        }
      }
      catch (IOException e)
      {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
      throw new RuntimeException();
    }
  }

Reply via email to