You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/04/12 21:43:37 UTC

svn commit: r933379 [10/15] - in /myfaces/extensions/scripting/trunk: extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/ extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/ ...

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/AbstractJavaCompilerTestCase.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import java.io.File;
+
+import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
+import org.apache.myfaces.extensions.scripting.api.CompilationResult;
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;
+import org.junit.Ignore;
+
+/**
+ * <p>Test class for all Java implementations of
+ * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler</code>.</p>
+ */
+@Ignore
+public abstract class AbstractJavaCompilerTestCase extends AbstractGeneratorTestCase {
+
+    // ------------------------------------------ Test methods
+
+    public void testCompileGeneratedFile() throws Exception {
+        writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/HelloWorld.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class HelloWorld {                          ",
+                "                                                   ",
+                "   public static void main(String[] args) {        ",
+                "       System.out.println(\"Hello World\");        ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler compiler = createCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/java")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/HelloWorld.java", getCurrentClassLoader());
+
+        assertFalse(result.hasErrors());
+        assertTrue(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
+    }
+
+    public void testCompileGeneratedFileWithError() throws Exception {
+        writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/HelloWorld.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class HelloWorld {                          ",
+                "                                                   ",
+                "   public static void main(String[] args) {        ",
+                "       System.println(\"Hello World\");            ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        Compiler compiler = createCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/java")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/HelloWorld.java", getCurrentClassLoader());
+
+        assertTrue(result.hasErrors());
+        assertFalse(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
+    }
+
+    public void testCompileFileWithDependencies() throws Exception {
+        writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;                                   ",
+                "                                                                                   ",
+                "import java.io.File;                                                               ",
+                "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;                  ",
+                "import org.apache.myfaces.extensions.scripting.api.CompilationResult;         ",
+                "                                                                                   ",
+                "public class DummyCompiler implements Compiler {                                   ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, String f, ClassLoader c) {     ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, File f, ClassLoader c) {       ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "}                                                                                  "
+
+        });
+
+        Compiler compiler = createCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/java")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/DummyCompiler.java", getCurrentClassLoader());
+
+        assertFalse(result.hasErrors());
+        assertTrue(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
+    }
+
+    public void testCompileFileWithDependenciesWithoutClassloader() throws Exception {
+        writeFile("/src/main/java/org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;                                   ",
+                "                                                                                   ",
+                "import java.io.File;                                                               ",
+                "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;                  ",
+                "import org.apache.myfaces.extensions.scripting.api.CompilationResult;         ",
+                "                                                                                   ",
+                "public class DummyCompiler implements Compiler {                                   ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, String f, ClassLoader c) {     ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, File f, ClassLoader c) {       ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "}                                                                                  "
+
+        });
+
+        Compiler compiler = createCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/java")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "aorg/apache/myfaces/extensions/scripting/DummyCompiler.java", null);
+
+        assertTrue(result.hasErrors());
+        assertFalse(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
+    }
+
+    // ------------------------------------------ Utility methods
+
+    protected ClassLoader getCurrentClassLoader() {
+        return getClass().getClassLoader();
+    }
+
+    // ------------------------------------------ Template methods
+
+    /**
+     * <p>Creates a new instance of the compiler implementation that this class should test.</p>
+     *
+     * @return a new instance of the compiler implementation that this class should test
+     */
+    protected abstract Compiler createCompiler();
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultGreeter.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+/**
+ *
+ *
+ */
+public class DefaultGreeter implements Greeter {
+
+    public String sayHello() {
+        return "Hello";
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/DefaultPersonGreeter.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+/**
+ *
+ *
+ */
+public class DefaultPersonGreeter implements PersonGreeter {
+
+    private DefaultGreeter greeter = new DefaultGreeter();
+
+    public String sayHello(String name) {
+        return greeter.sayHello() + " " + name + "!";
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Greeter.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+/**
+ *
+ *
+ */
+public interface Greeter {
+
+    public String sayHello();
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/GroovyCompilerTest.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.GroovyCompiler;
+import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
+import org.apache.myfaces.extensions.scripting.api.CompilationResult;
+import org.apache.myfaces.extensions.scripting.api.Configuration;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.*;
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;
+
+import java.io.File;
+
+/**
+ * <p>Test class for
+ * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.GroovyCompiler</code></p>
+ */
+
+public class GroovyCompilerTest extends AbstractGeneratorTestCase {
+
+    // ------------------------------------------ Test methods
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();  
+        WeavingContext.setConfiguration(new Configuration());
+    }
+
+    /**
+     * <p>Tests whether it is possible to compile a dynamically generated Groovy source file.</p>
+     *
+     * @throws Exception if an error occurs
+     */
+    public void testCompileGeneratedFile() throws Exception {
+        writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/HelloWorld.groovy", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "def class HelloWorld {                             ",
+                "                                                   ",
+                "   def static main(String[] args) {                ",
+                "       println(\"Hello World\");                   ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler compiler = new GroovyCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/groovy")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/HelloWorld.groovy", getCurrentClassLoader());
+
+        assertFalse(result.hasErrors());
+        assertTrue(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
+    }
+
+    /**
+     * <p>Tests whether compilation fails in case of an invalid Groovy source file.</p>
+     *
+     * @throws Exception if an error occurs
+     */
+    public void testCompileGeneratedFileWithError() throws Exception {
+        writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/HelloWorld.groovy", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "def class HelloWorld {                             ",
+                "                                                   ",
+                "   def static main(String[] args) {                ",
+                "       System2.out.println(\"Hello World\");       ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        Compiler compiler = new GroovyCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/groovy")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/HelloWorld.groovy", getCurrentClassLoader());
+
+        assertTrue(result.hasErrors());
+        assertFalse(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/HelloWorld.class").exists());
+    }
+
+    /**
+     * <p>Tests whether it is possible to reference dependencies in the Groovy
+     * source files that have to be resolved using the supplied class loader.</p>
+     *
+     * @throws Exception if an error occurs
+     */
+    public void testCompileFileWithDependencies() throws Exception {
+        writeFile("/src/main/groovy/org/apache/myfaces/extensions/scripting/DummyCompiler.groovy", new String[]{
+                "package org.apache.myfaces.extensions.scripting;                                   ",
+                "                                                                                   ",
+                "import java.io.File;                                                               ",
+                "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;                  ",
+                "import org.apache.myfaces.extensions.scripting.api.CompilationResult;         ",
+                "                                                                                   ",
+                "def class DummyCompiler implements Compiler {                                      ",
+                "                                                                                   ",
+                "   def CompilationResult compile(File s, File t, String f, ClassLoader c) {        ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "                                                                                   ",
+                "   def CompilationResult compile(File s, File t, File f, ClassLoader c) {          ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "}                                                                                  "
+        });
+
+        Compiler compiler = new GroovyCompiler();
+        CompilationResult result = compiler.compile(
+                new File(buildAbsolutePath("/src/main/groovy")),
+                new File(buildAbsolutePath("/target/test-classes")),
+                "org/apache/myfaces/extensions/scripting/DummyCompiler.groovy", getCurrentClassLoader());
+
+        assertFalse(result.hasErrors());
+        assertTrue(new File(
+                buildAbsolutePath("/target/test-classes/"), "org/apache/myfaces/extensions/scripting/DummyCompiler.class").exists());
+    }
+
+    // ------------------------------------------ Utility methods
+
+    /**
+     * <p>Returns the class loader that has loaded this class.</p>
+     *
+     * @return the class loader that has loaded this class
+     */
+    protected ClassLoader getCurrentClassLoader() {
+        return getClass().getClassLoader();
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/JavacCompilerTest.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.JavacCompiler;
+import org.apache.myfaces.extensions.scripting.sandbox.compiler.*;
+import org.junit.Ignore;
+
+/**
+ * <p>Test class for
+ * <code>org.apache.myfaces.extensions.scripting.sandbox.compiler.JavacCompiler</code></p>
+ */
+@Ignore
+public class JavacCompilerTest extends AbstractJavaCompilerTestCase {
+
+    // ------------------------------------------ AbstractJavaCompilerTestCase methods
+
+    protected org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler createCompiler() {
+        return new JavacCompiler();
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/Jsr199CompilerTest.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import org.junit.Ignore;
+
+/**
+ * <p>Test class for
+ * <code>org.apache.myfaces.extensions.scripting.loaders.java.compiler.Jsr199Compiler</code></p>
+ */
+@Ignore
+public class Jsr199CompilerTest extends AbstractJavaCompilerTestCase {
+
+    // ------------------------------------------ AbstractJavaCompilerTestCase methods
+
+    protected org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler createCompiler() {
+        //return new Jsr199Compiler();
+        return null;
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/OverridingClassLoaderTest.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import junit.framework.TestCase;
+import org.apache.myfaces.extensions.scripting.sandbox.loader.support.OverridingClassLoader;
+
+/**
+ * <p>Test class for the class
+ * <code>org.apache.myfaces.extensions.scripting.sandbox.loader.support.OverridingClassLoader</code></p>
+ */
+public class OverridingClassLoaderTest extends TestCase {
+
+    // ------------------------------------------ Test methods
+
+    /**
+     * <p>Tests whether it is possible to override class definitions using the OverridingClassLoader,
+     * i.e. it tests if you can produce multiple different Class objects using different class loaders
+     * (which is not really a surprising thing at all).</p>
+     *
+     * @throws Exception if an unexpected error occurs
+     */
+    public void testOverrideClass() throws Exception {
+        ClassLoader classLoader = new OverridingClassLoader(
+                Dummy.class.getName(), OverridingClassLoaderTest.class.getClassLoader());
+
+        Class dummyClass = classLoader.loadClass(Dummy.class.getName());
+        assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
+                Dummy.class, dummyClass);
+
+        // .. and another time
+        classLoader = new OverridingClassLoader(Dummy.class.getName(), classLoader);
+        Class secondDummyClass = classLoader.loadClass(Dummy.class.getName());
+        assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
+                Dummy.class, secondDummyClass);
+        assertNotSame("The OverridingClassLoader didn't return a different Class instance.",
+                dummyClass, secondDummyClass);
+    }
+
+    /**
+     * <p>Tests whether the OverridingClassLoader delegates the parent class loader correctly.</p>
+     *
+     * @throws Exception if an unexpected error occurs
+     */
+    public void testOverrideDifferentClass() throws Exception {
+        ClassLoader classLoader = new OverridingClassLoader(
+                Dummy.class.getName(), OverridingClassLoaderTest.class.getClassLoader());
+        assertSame("The OverridingClassLoader replaced a Class instance that he wasn't supposed to replace.",
+                Object.class, classLoader.loadClass("java.lang.Object"));
+    }
+
+    // ------------------------------------------ Dummy classes
+
+    /**
+     * <p>This class will be reloaded in some test cases.</p>
+     */
+    private static class Dummy {
+
+    }
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/PersonGreeter.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+/**
+ *
+ *
+ */
+public interface PersonGreeter {
+
+    public String sayHello(String name);
+
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/extensions/scripting/sandbox/ReloadingClassLoaderTest.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,278 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.sandbox;
+
+import org.apache.myfaces.extensions.scripting.core.support.AbstractGeneratorTestCase;
+import org.apache.myfaces.extensions.scripting.sandbox.loader.ReloadingClassLoader;
+import org.junit.Ignore;
+
+import java.io.File;
+
+/**
+ * <p>Test class for
+ * <code>org.apache.myfaces.extensions.scripting.sandbox.loader.ReloadingClassLoader</code></p>
+ */
+@Ignore
+public class ReloadingClassLoaderTest extends AbstractGeneratorTestCase {
+
+    // ------------------------------------------ Test methods
+
+    public void testCompileAndLoadFile() throws Exception {
+        // Compile a dynamically generated class ..
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello World\";                     ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        // .. and try to load it afterwards.
+        Class greeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(greeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", greeterClass.getName());
+
+        Object greeter = greeterClass.newInstance();
+        String greeting = (String) greeter.getClass().getMethod("sayHello").invoke(greeter);
+        assertEquals("Hello World", greeting);
+    }
+
+    public void testCompileAndLoadFileMultipleTimes() throws Exception {
+        // Compile a dynamically generated class ..
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello World\";                     ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        // .. and try to load it afterwards ..
+        Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(firstGreeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
+
+        // .. more than once using the same classloader.
+        Class secondGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(secondGreeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", secondGreeterClass.getName());
+
+        assertSame(firstGreeterClass, secondGreeterClass);
+    }
+
+    public void testRecompileAndLoadFile() throws Exception {
+        // Compile a dynamically generated class.
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello World\";                     ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(firstGreeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
+
+        Object firstGreeter = firstGreeterClass.newInstance();
+        String greeting = (String) firstGreeterClass.getMethod("sayHello").invoke(firstGreeter);
+        assertEquals("Hello World", greeting);
+
+        Thread.sleep(1000);
+
+        // Modify the source code
+        // Compile a dynamically generated class ..
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello Universe\";                  ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        // Reload the class and verify it again
+        Class secondGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(secondGreeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", secondGreeterClass.getName());
+
+        // However, it has to be a new Class object
+        assertNotSame(firstGreeterClass, secondGreeterClass);
+
+        Object secondGreeter = secondGreeterClass.newInstance();
+        greeting = (String) secondGreeterClass.getMethod("sayHello").invoke(secondGreeter);
+        assertEquals("Hello Universe", greeting);
+    }
+
+    public void testOverrideFile() throws Exception {
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+        Greeter greeter = (Greeter) classLoader.loadClass(
+                "org.apache.myfaces.extensions.scripting.sandbox.DefaultGreeter").newInstance();
+        assertEquals("Hello", greeter.sayHello());
+
+        // Compile a dynamically generated class.
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/loader/DefaultGreeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting.sandbox.loader;    ",
+                "                                                           ",
+                "public class DefaultGreeter implements Greeter {           ",
+                "                                                           ",
+                "   public String sayHello() {                              ",
+                "       return \"Hi\";                                      ",
+                "   }                                                       ",
+                "}                                                          "
+        });
+
+        greeter = (Greeter) classLoader.loadClass(
+                "org.apache.myfaces.extensions.scripting.sandbox.DefaultGreeter").newInstance();
+        assertEquals("Hi", greeter.sayHello());
+    }
+
+    public void testOverrideFileAndCheckDependentClass() throws Exception {
+        ReloadingClassLoader classLoader = buildClassLoader("/target/test-classes");
+        PersonGreeter greeter = (PersonGreeter) classLoader.loadClass(
+                "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
+        assertEquals("Hello John Doe!", greeter.sayHello("John Doe"));
+
+        // Compile a dynamically generated class.
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/loader/DefaultGreeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting.sandbox.loader;    ",
+                "                                                           ",
+                "public class DefaultGreeter implements Greeter {           ",
+                "                                                           ",
+                "   public String sayHello() {                              ",
+                "       return \"Hi\";                                      ",
+                "   }                                                       ",
+                "}                                                          "
+        });
+
+        // Note that the person greeter still uses the outdated version of the class file.
+        greeter = (PersonGreeter) classLoader.loadClass(
+                "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
+        assertEquals("Hello John Doe!", greeter.sayHello("John Doe"));
+
+        // However, now we're forcefully reloading this class in order to reflect the changes.
+        classLoader.reloadClass("org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter");
+
+        // Note that the person greeter still uses the outdated version of the class file.
+        greeter = (PersonGreeter) classLoader.loadClass(
+                "org.apache.myfaces.extensions.scripting.sandbox.DefaultPersonGreeter").newInstance();
+        assertEquals("Hi John Doe!", greeter.sayHello("John Doe"));
+    }
+
+    public void testCompileAndLoadFileWithDependencies() throws Exception {
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/DummyCompiler.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;                                   ",
+                "                                                                                   ",
+                "import java.io.File;                                                               ",
+                "import org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler;                  ",
+                "import org.apache.myfaces.extensions.scripting.api.CompilationResult;         ",
+                "                                                                                   ",
+                "public class DummyCompiler implements Compiler {                                   ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, String f, ClassLoader c) {     ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "                                                                                   ",
+                "   public CompilationResult compile(File s, File t, File f, ClassLoader c) {       ",
+                "       return null;                                                                ",
+                "   }                                                                               ",
+                "}                                                                                  "
+        });
+
+        // Create a new class loader to load the dynamically compiled class
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        // Load the dynamically compiled class
+        Class dummyCompilerClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.DummyCompiler");
+        assertNotNull(dummyCompilerClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.DummyCompiler", dummyCompilerClass.getName());
+    }
+
+    public void testLoadParentClassFile() throws Exception {
+        ClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        Class compilerInterface = classLoader.loadClass("org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler");
+        assertNotNull(compilerInterface);
+        assertEquals("org.apache.myfaces.extensions.scripting.sandbox.compiler.Compiler", compilerInterface.getName());
+    }
+
+    public void testOutdatedCheck() throws Exception {
+        // Compile a dynamically generated class ..
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello World\";                     ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        ReloadingClassLoader classLoader = buildClassLoader("/target/test-classes");
+
+        Class firstGreeterClass = classLoader.loadClass("org.apache.myfaces.extensions.scripting.Greeter");
+        assertNotNull(firstGreeterClass);
+        assertEquals("org.apache.myfaces.extensions.scripting.Greeter", firstGreeterClass.getName());
+
+        assertFalse(classLoader.isOutdated(firstGreeterClass));
+
+        Thread.sleep(1000);
+
+        // Modify the source code ..
+        compileFile("/src/main/java", "/target/test-classes", "org/apache/myfaces/extensions/scripting/Greeter.java", new String[]{
+                "package org.apache.myfaces.extensions.scripting;   ",
+                "                                                   ",
+                "public class Greeter {                             ",
+                "                                                   ",
+                "   public String sayHello() {                      ",
+                "       return \"Hello Universe\";                  ",
+                "   }                                               ",
+                "}                                                  "
+        });
+
+        // .. and test whether the classloader recognizes that we've got an outdated Class reference here.
+        assertTrue(classLoader.isOutdated(firstGreeterClass));
+    }
+
+    // ------------------------------------------ Utility methods
+
+    protected ReloadingClassLoader buildClassLoader(String compilationDirectory) {
+        return new ReloadingClassLoader(getClass().getClassLoader(),
+                new File(buildAbsolutePath(compilationDirectory)));
+    }
+
+}
\ No newline at end of file

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/brokenwebapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/brokenwebapp/WEB-INF/web.xml?rev=933379&r1=933378&r2=933379&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/brokenwebapp/WEB-INF/web.xml (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/brokenwebapp/WEB-INF/web.xml Mon Apr 12 19:43:30 2010
@@ -29,7 +29,7 @@
         <description>a comma separated whitelist of root packages which are compiled those and nothing else
             will be compiled during all compile stages, all other files stay permanently as they are
         </description>
-        <param-name>org.apache.myfaces.scripting.PGK_WHITELIST</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.PGK_WHITELIST</param-name>
         <param-value>org.apache.myfaces.groovyloader.blog</param-value>
     </context-param>
     -->
@@ -40,7 +40,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.groovy.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name>
         <param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/groovy</param-value>
     </context-param>
 
@@ -49,7 +49,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.java.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name>
         <param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/java</param-value>
     </context-param>
 

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/webapp/WEB-INF/web.xml?rev=933379&r1=933378&r2=933379&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/webapp/WEB-INF/web.xml (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/resources/webapp/WEB-INF/web.xml Mon Apr 12 19:43:30 2010
@@ -28,7 +28,7 @@
             Initializes the plugins for our groovy handlers
         </description>
         <param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name>
-        <param-value>org.apache.myfaces.scripting.servlet.StartupServletContextPluginChainLoader</param-value>
+        <param-value>org.apache.myfaces.extensions.scripting.servlet.StartupServletContextPluginChainLoader</param-value>
     </context-param>
 
 
@@ -36,7 +36,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.groovy.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name>
         <param-value>
             /Users/werpu2/development/workspace/extensions-scripting3/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy
         </param-value>
@@ -47,7 +47,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.java.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name>
         <param-value>
             /Users/werpu2/development/workspace/extensions-scripting3/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java
         </param-value>
@@ -55,7 +55,7 @@
 
     <context-param>
         <description>resource paths for our custom JSF2 resource resolver</description>
-        <param-name>org.apache.myfaces.scripting.resources.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.resources.LOADER_PATHS</param-name>
         <param-value>
             /Users/werpu2/development/workspace/extensions-scripting3/extscript-examples/myfaces20-example/src/main/webapp
         </param-value>
@@ -66,7 +66,7 @@
             source dir
         </description>
         <param-name>facelets.RESOURCE_RESOLVER</param-name>
-        <param-value>org.apache.myfaces.scripting.facelet.ReroutingResourceResolver</param-value>
+        <param-value>org.apache.myfaces.extensions.scripting.facelet.ReroutingResourceResolver</param-value>
     </context-param>
     
     <!--
@@ -74,7 +74,7 @@
         <description>a comma separated whitelist of root packages which are compiled those and nothing else
             will be compiled during all compile stages, all other files stay permanently as they are
         </description>
-        <param-name>org.apache.myfaces.scripting.PGK_WHITELIST</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.PGK_WHITELIST</param-name>
         <param-value>org.apache.myfaces.groovyloader.blog</param-value>
     </context-param>
     -->
@@ -85,7 +85,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.groovy.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name>
         <param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/groovy</param-value>
     </context-param>
 
@@ -94,7 +94,7 @@
         <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
             of the deployment dir
         </description>
-        <param-name>org.apache.myfaces.scripting.java.LOADER_PATHS</param-name>
+        <param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name>
         <param-value>D:/dev/work/ideaprojects/threads/extscript/examples/myfaces20-example/src/main/webapp/WEB-INF/java</param-value>
     </context-param>
 
@@ -125,7 +125,7 @@
 
     <filter>
         <filter-name>scriptingFilter</filter-name>
-        <filter-class>org.apache.myfaces.scripting.servlet.ScriptingServletFilter</filter-class>
+        <filter-class>org.apache.myfaces.extensions.scripting.servlet.ScriptingServletFilter</filter-class>
     </filter>
     <filter-mapping>
         <filter-name>scriptingFilter</filter-name>

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/faces-config.NavData
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/faces-config.NavData?rev=933379&view=auto
==============================================================================
    (empty)

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.facelet;
+
+import com.sun.facelets.impl.DefaultResourceResolver;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * decorated Facelet resource resolver to reroute
+ * the resource requests to our source path if possible
+ */
+public class ReroutingResourceResolver extends DefaultResourceResolver {
+
+    DefaultResourceResolver _delegate = new DefaultResourceResolver();
+    volatile boolean _initiated = false;
+    List<String> _resourceDirs = null;
+
+    Logger log = Logger.getLogger(this.getClass().getName());
+
+    @Override
+    public URL resolveUrl(String path) {
+
+        if (!_initiated) {
+            _resourceDirs = WeavingContext.getConfiguration().getResourceDirs();
+            _initiated = true;
+        }
+
+        if (_resourceDirs != null && !_resourceDirs.isEmpty()) {
+            for (String resourceDir : _resourceDirs) {
+                File resource = new File(resourceDir + path);
+                if (resource.exists()) try {
+                    return resource.toURI().toURL();
+                } catch (MalformedURLException e) {
+                    log.log(Level.SEVERE,"", e);
+                }
+            }
+        }
+
+        return _delegate.resolveUrl(path);
+    }
+}
+

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingApplicationFactory.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.ApplicationProxy;
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.application.ApplicationFactory;
+import javax.faces.application.Application;
+
+/**
+ * Application factory which introduces
+ * scripting proxies for their artefacts
+ * <p/>
+ * We use a mix of AOP and helper constructs
+ * to reach the goal to be dynamic.
+ * For most artefacts we just need to
+ * check if the object is a Groovy object
+ * and then reload at their connection interfaces
+ * <p/>
+ * Some artefacts have a longer lifespan and/or are stateless
+ * for those we have to work with reloading AOP
+ *
+ * @author Werner Punz
+ */
+public class ScriptingApplicationFactory extends ApplicationFactory implements Decorated {
+
+    ApplicationFactory _delegate;
+    boolean scriptingEnabled = false;
+
+    public ScriptingApplicationFactory(ApplicationFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public Application getApplication() {
+        Application retVal = _delegate.getApplication();  //To change body of implemented methods use File | Settings | File Templates.
+
+        if (WeavingContext.isScriptingEnabled() && !(retVal instanceof ApplicationProxy))
+            retVal = new ApplicationProxy(retVal);
+
+        return retVal;
+    }
+
+    public void setApplication(Application application) {
+        if (WeavingContext.isScriptingEnabled() && !(application instanceof ApplicationProxy))
+            application = new ApplicationProxy(application);
+
+        _delegate.setApplication(application);
+    }
+
+    public Object getDelegate() {
+        return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingFacesContextFactory.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.FacesContextProxy;
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.FacesException;
+
+/**
+ * Faces context weaver which builds
+ * our reloading proxy around the current faces context
+ *
+ * @author Werner Punz
+ */
+public class ScriptingFacesContextFactory extends javax.faces.context.FacesContextFactory implements Decorated {
+
+    public FacesContextFactory _delegate;
+    boolean scriptingEnabled = false;
+
+    public ScriptingFacesContextFactory(FacesContextFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public void setDelegate(FacesContextFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public FacesContext getFacesContext(Object o, Object o1, Object o2, Lifecycle lifecycle) throws FacesException {
+        FacesContext retVal = _delegate.getFacesContext(o, o1, o2, lifecycle);  //To change body of implemented methods use File | Settings | File Templates.
+
+        if (WeavingContext.isScriptingEnabled() && !(retVal instanceof FacesContextProxy))
+            return new FacesContextProxy(retVal);
+        return retVal;
+    }
+
+    public Object getDelegate() {
+        return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingLifecycleFactory.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.LifefcycleProxy;
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.lifecycle.Lifecycle;
+import java.util.Iterator;
+
+/**
+ * Lifecyclefactory which introduces scripting proxies
+ * for their artefacts
+ *
+ * @author Werner Punz
+ */
+public class ScriptingLifecycleFactory extends LifecycleFactory implements Decorated {
+
+    LifecycleFactory _delegate;
+    boolean scriptingEnabled = false;
+
+    public ScriptingLifecycleFactory(LifecycleFactory delegate) {
+        _delegate = delegate;
+    }
+
+    public void addLifecycle(String s, Lifecycle lifecycle) {
+        if (scriptingEnabled && !(lifecycle instanceof LifefcycleProxy))
+            lifecycle = new LifefcycleProxy(lifecycle);
+        _delegate.addLifecycle(s, lifecycle);
+    }
+
+    public Lifecycle getLifecycle(String s) {
+        Lifecycle retVal = _delegate.getLifecycle(s);
+        if (WeavingContext.isScriptingEnabled() && !(retVal instanceof LifefcycleProxy))
+            retVal = new LifefcycleProxy(retVal);
+
+        return retVal;
+    }
+
+    public Iterator getLifecycleIds() {
+        return _delegate.getLifecycleIds();
+    }
+
+    public void setDelegate(LifecycleFactory delegate) {
+        this._delegate = delegate;
+    }
+
+    public Object getDelegate() {
+        return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/factories/ScriptingRenderkitFactory.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.implemetations.RenderkitProxy;
+
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.RenderKit;
+import javax.faces.context.FacesContext;
+import java.util.Iterator;
+
+/**
+ * Scripting enabled renderkit factory
+ *
+ * @author Werner Punz
+ */
+public class ScriptingRenderkitFactory extends RenderKitFactory implements Decorated {
+
+    boolean scriptingEnabled = false;
+
+    public ScriptingRenderkitFactory(RenderKitFactory delegate) {
+        _delegate = delegate;
+       
+    }
+
+    public void addRenderKit(String s, RenderKit renderKit) {
+        if (WeavingContext.isScriptingEnabled() && renderKit != null && !(renderKit instanceof RenderkitProxy))
+            renderKit = new RenderkitProxy(renderKit);
+
+        _delegate.addRenderKit(s, renderKit);
+    }
+
+    public RenderKit getRenderKit(FacesContext facesContext, String s) {
+        RenderKit retVal = _delegate.getRenderKit(facesContext, s);
+        if (WeavingContext.isScriptingEnabled() &&  retVal != null && !(retVal instanceof RenderkitProxy))
+            retVal = new RenderkitProxy(retVal);
+        return retVal;
+    }
+
+    public Iterator getRenderKitIds() {
+        return _delegate.getRenderKitIds();
+    }
+
+    public void setDelegate(RenderKitFactory delegate) {
+        _delegate = delegate;
+    }
+
+    RenderKitFactory _delegate = null;
+
+    public Object getDelegate() {
+        return _delegate;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+}