Cool Stuart,
the process not being stopped was a bug I just was about to report :)

/peter

On 4/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Author: mcculls
> Date: Sun Apr 15 14:21:14 2007
> New Revision: 6111
>
> Log:
> Various fixes for Windows: use URI for bundle locations, protect path 
> separators in properties file, and ensure exec'd process is destroyed when 
> Pax-Runner is Ctrl-C'd
>
> Modified:
>    projects/pax/runner/src/main/java/org/ops4j/pax/runner/EquinoxRunner.java
>    projects/pax/runner/src/main/java/org/ops4j/pax/runner/FelixRunner.java
>    
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/KnopflerfishRunner.java
>    projects/pax/runner/src/main/java/org/ops4j/pax/runner/Run.java
>
> Modified: 
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/EquinoxRunner.java
> ==============================================================================
> --- projects/pax/runner/src/main/java/org/ops4j/pax/runner/EquinoxRunner.java 
>   (original)
> +++ projects/pax/runner/src/main/java/org/ops4j/pax/runner/EquinoxRunner.java 
>   Sun Apr 15 14:21:14 2007
> @@ -175,6 +175,7 @@
>              outPipe.start();
>              Pipe inPipe = new Pipe( System.in, in );
>              inPipe.start();
> +            Run.destroyFrameworkOnExit( process, new Pipe[]{inPipe, outPipe, 
> errPipe} );
>              process.waitFor();
>              inPipe.stop();
>              outPipe.stop();
>
> Modified: 
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/FelixRunner.java
> ==============================================================================
> --- projects/pax/runner/src/main/java/org/ops4j/pax/runner/FelixRunner.java   
>   (original)
> +++ projects/pax/runner/src/main/java/org/ops4j/pax/runner/FelixRunner.java   
>   Sun Apr 15 14:21:14 2007
> @@ -41,6 +41,10 @@
>
>      private static final String VERSION = "0.9.0-incubator-SNAPSHOT";
>
> +    // have to escape \ for pattern compiler and again for javac
> +    private static final String ONE_BACKSLASH_REGEXP = "\\\\";
> +    private static final String TWO_BACKSLASH_REGEXP = "\\\\\\\\";
> +
>      private Properties m_props;
>      private CmdLine m_cmdLine;
>      private List<File> m_sysBundles;
> @@ -239,7 +243,11 @@
>              {
>                  FileUtils.writeProperty( out, "felix.cache.profile", profile 
> );
>              }
> -            FileUtils.writeProperty( out, "felix.cache.dir", Run.WORK_DIR + 
> "/cache" );
> +
> +            // Need to quote windows separators in propertyfile otherwise 
> they're interpreted as line continuations
> +            String quotedWorkDir = Run.WORK_DIR.getPath().replaceAll( 
> ONE_BACKSLASH_REGEXP, TWO_BACKSLASH_REGEXP );
> +
> +            FileUtils.writeProperty( out, "felix.cache.dir", quotedWorkDir + 
> "/cache" );
>              FileUtils.writeProperty( out, "felix.startlevel.framework", "1" 
> );
>              FileUtils.writeProperty( out, "felix.startlevel.bundle", "3" );
>              FileUtils.writeProperty( out, "obr.repository.url", 
> "http://www2.osgi.org/repository/repository.xml"; );
> @@ -272,8 +280,7 @@
>                  buf.append( " \\\n    " );
>              }
>              first = false;
> -            buf.append( "file:" );
> -            buf.append( bundle.getAbsolutePath() );
> +            buf.append( bundle.toURI() );
>          }
>          FileUtils.writeProperty( out, startLevel, buf.toString() );
>      }
> @@ -302,7 +309,7 @@
>          {
>              String[] commands =
>                  {
> -                    "-Dfelix.config.properties=file:" + Run.WORK_DIR + 
> "/conf/config.properties",
> +                    "-Dfelix.config.properties=" + Run.WORK_DIR.toURI() + 
> "/conf/config.properties",
>                      "-jar",
>                      m_main.getAbsolutePath(),
>                  };
> @@ -325,6 +332,7 @@
>              outPipe.start();
>              Pipe inPipe = new Pipe( System.in, in );
>              inPipe.start();
> +            Run.destroyFrameworkOnExit( process, new Pipe[]{inPipe, outPipe, 
> errPipe} );
>              process.waitFor();
>              inPipe.stop();
>              outPipe.stop();
>
> Modified: 
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/KnopflerfishRunner.java
> ==============================================================================
> --- 
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/KnopflerfishRunner.java
>       (original)
> +++ 
> projects/pax/runner/src/main/java/org/ops4j/pax/runner/KnopflerfishRunner.java
>       Sun Apr 15 14:21:14 2007
> @@ -177,20 +177,20 @@
>                  out.write( value );
>                  out.write( "\n" );
>              }
> -            out.write( "-Dorg.knopflerfish.gosg.jars=file://" + 
> confDir.getAbsolutePath() + "/lib/\n\n" );
> +            out.write( "-Dorg.knopflerfish.gosg.jars=" + confDir.toURI() + 
> "/lib/\n\n" );
>              out.write( "-init\n" );
>              out.write( "-initlevel 1\n" );
>              for( File bundle : m_bundles )
>              {
>                  out.write( "-install " );
> -                out.write( bundle.getAbsolutePath() );
> +                out.write( bundle.toURI().toString() );
>                  out.write( "\n" );
>              }
>              out.write( "-startlevel 7\n" );
>              for( File bundle : m_bundles )
>              {
>                  out.write( "-start " );
> -                out.write( bundle.getAbsolutePath() );
> +                out.write( bundle.toURI().toString() );
>                  out.write( "\n" );
>              }
>              out.flush();
> @@ -248,6 +248,7 @@
>              outPipe.start();
>              Pipe inPipe = new Pipe( System.in, in );
>              inPipe.start();
> +            Run.destroyFrameworkOnExit( process, new Pipe[]{inPipe, outPipe, 
> errPipe} );
>              process.waitFor();
>              inPipe.stop();
>              outPipe.stop();
>
> Modified: projects/pax/runner/src/main/java/org/ops4j/pax/runner/Run.java
> ==============================================================================
> --- projects/pax/runner/src/main/java/org/ops4j/pax/runner/Run.java     
> (original)
> +++ projects/pax/runner/src/main/java/org/ops4j/pax/runner/Run.java     Sun 
> Apr 15 14:21:14 2007
> @@ -205,4 +205,26 @@
>
>          return repositoryList;
>      }
> +
> +    // helper function to ensure shutdown of framework VM on Windows when 
> Pax-Runner is Ctrl-C'd
> +    protected static void destroyFrameworkOnExit( final Process frameworkVM, 
> final Pipe[] pipes )
> +    {
> +        Runtime.getRuntime().addShutdownHook( new Thread( new Runnable()
> +        {
> +            public void run()
> +            {
> +                try
> +                {
> +                    for (int i = 0; i < pipes.length; i++ )
> +                    {
> +                        pipes[i].stop();
> +                    }
> +                }
> +                finally
> +                {
> +                    frameworkVM.destroy();
> +                }
> +            }
> +        } ) );
> +    }
>  }
>
> _______________________________________________
> notify mailing list
> [EMAIL PROTECTED]
> http://lists.ops4j.org/mailman/listinfo/notify
>
>

_______________________________________________
general mailing list
[EMAIL PROTECTED]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to