You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:04:16 UTC

[sling-org-apache-sling-scripting-java] annotated tag org.apache.sling.scripting.java-2.0.0 created (now 7213f4c)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git.


      at 7213f4c  (tag)
 tagging 9357a72d261c80305b3a7ede542ddd5a7033a163 (commit)
      by Carsten Ziegeler
      on Thu Dec 16 10:33:29 2010 +0000

- Log -----------------------------------------------------------------
org.apache.sling.scripting.java-2.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new b709f59  SLING-619 Add a scripting engine for java servlets.
     new 72382c3  Add descriptions for the configuration, fix type in config and add missing licence and notice files.
     new bc49398  SLING-619 - add README.txt with info on how to test this bundle
     new cbbc933  svn:ignore Eclipse files
     new c6be7e3  SLING-808 : Increase version to 5-incubator-SNAPSHOT
     new 3536bde  Update notice files to include 2009 in copyright statement.
     new 3574a99  SLING-829 Cosmetics to the bundle/project names
     new f6e4fab  SLING-829 Ensure Apache Sling prefix on all configuration names
     new b12c7b4  SLING-825 : Return the resource name as source file name.
     new 925cb36  SLING-865 : Move to bundles
     new 1c32a95  SLING-865 : Move to contrib
     new 8da570b  SLING-865 : Adjust reactor pom and svn information in each module.
     new c42dbbb  SLING-865 : Adjust path to parent pom and add profiles for samples and contrib
     new 202f6f3  Use release parent pom
     new dbb6ae9  Use new dev parent pom for contrib.
     new f85a876  Set parent pom to released version.
     new 2cf48b5  Move Sling to new TLP location
     new 2e639e2  SLING-1011 : Remove disclaimer file.
     new 73f8ccd  SLING-1011 : Adjust svn location
     new 3a4b8e1  SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
     new 758a535  SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
     new dda6e2f  Don't wrap Sling exception.
     new 04c964c  Correctly set version to 0.9.0
     new e815996  Improve exception messages.
     new 025f546  Do not silently swallow exception
     new d55d8f0  SLING-1050 : Use dynamic class loader instead of dynamic import package.
     new beb532d  Use new class loader writer.
     new 16c4505  Store script resource resolver in script context, return script resource with request resource resolver.
     new af551b1  Correct dependency
     new 76f52ae  SLING-1021 - Use the global scope for the script resource resolver to avoid having this in the bindings for the script.
     new 04fbce0  SLING-1021 : Use own sling scope to store private attributes.
     new 5445803  Use latest Sling API release.
     new 346e33c  Fix wrong org.apache.sling.commons.classloader version number
     new 07ac4e7  Update to latest Sling releases.
     new d4de31f  Update to latest release.
     new 7a1a68b  Use latest parent pom.
     new f8ca64a  [maven-release-plugin] prepare release org.apache.sling.scripting.java-1.0.0
     new 7ea3c6f  [maven-release-plugin] prepare for next development iteration
     new 45524e5  [maven-release-plugin] prepare release org.apache.sling.scripting.java-1.0.0
     new acd44c8  [maven-release-plugin] prepare for next development iteration
     new 51eaa96  SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
     new c02a383  SLING-1279 : Configuration properties for development mode and debuginfo should be of type boolean
     new a21c34a  SLING-1286 : Warning with invalid path during compilation
     new 27ed977  Use string builder instead of string buffer
     new 6b0aef2  Code cleanup
     new bfc4376  SLING-1385 : Recompile java scripts on modification and avoid periodic checks
     new c7eeecd  SLING-1385 : Recompile java scripts on modifications and avoid periodic check - fix error handling and sync problems.
     new cfd7362  SLING-874 : Use new commons compiler for java servlet scripting
     new 80e732c  SLING-874 : Use new commons compiler for java servlet scripting
     new 12aeb71  SLING-874 : Use new commons compiler for java servlet scripting
     new f6fb893  Use released parent pom.
     new d34558d  Set target vm version and remove obsolete notice/licence files.
     new 38524ca  Prepare release
     new f7373f5  [maven-release-plugin] prepare release org.apache.sling.scripting.java-2.0.0
     new 9357a72  [maven-scm] copy for tag org.apache.sling.scripting.java-2.0.0

The 55 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-scripting-java] 12/16: Use released parent pom.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit f6fb8932dc7b9a691f7a502b17ecc77d0cc2a7a5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 17 13:42:29 2010 +0000

    Use released parent pom.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@945149 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 12fb9a3..638ec40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>8</version>
+        <version>9</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 16/16: [maven-scm] copy for tag org.apache.sling.scripting.java-2.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 9357a72d261c80305b3a7ede542ddd5a7033a163
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:33:29 2010 +0000

    [maven-scm] copy for tag org.apache.sling.scripting.java-2.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.scripting.java-2.0.0@1049892 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 14/16: Prepare release

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 38524ca786449f9c525bdab020026c73016026d1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:27:19 2010 +0000

    Prepare release
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@1049881 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 638ec40..7bd64f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.compiler</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>2.0.0</version>
             <scope>provided</scope>
         </dependency>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 03/16: SLING-1279 : Configuration properties for development mode and debuginfo should be of type boolean

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit c02a383927a0a5c28f09c337d0ea1fe687da0ca5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 8 09:59:08 2010 +0000

    SLING-1279 : Configuration properties for development mode and debuginfo should be of type boolean
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@897149 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
index 729702f..605c0ca 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
@@ -54,9 +54,9 @@ import org.slf4j.LoggerFactory;
  * @scr.property name="java.javaEncoding" value="UTF-8"
  * @scr.property name="java.compilerSourceVM" value="1.5"
  * @scr.property name="java.compilerTargetVM" value="1.5"
- * @scr.property name="java.development" value="true"
+ * @scr.property name="java.development" value="true" type="Boolean"
  * @scr.property name="java.modificationTestInterval" value="-1"
- * @scr.property name="java.classdebuginfo" value="true"
+ * @scr.property name="java.classdebuginfo" value="true" type="Boolean"
  */
 public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 04/16: SLING-1286 : Warning with invalid path during compilation

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit a21c34a4c49e3bcc19325776dbdc8aeeeeb0ce04
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 15 07:50:37 2010 +0000

    SLING-1286 : Warning with invalid path during compilation
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@899552 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/scripting/java/jdt/CompilationUnit.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
index 6313495..c34a1c0 100644
--- a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
+++ b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
@@ -197,7 +197,15 @@ public class CompilationUnit
             return false;
         }
         String resourceName = result.replace('.', '/') + ".class";
-        InputStream is = options.getClassLoader().getResourceAsStream(resourceName);
+        if ( resourceName.startsWith("/") ) {
+            resourceName = resourceName.substring(1);
+        }
+        final InputStream is = options.getClassLoader().getResourceAsStream(resourceName);
+        if ( is != null ) {
+            try {
+                is.close();
+            } catch (IOException ignore) {}
+        }
         return is == null;
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 10/16: SLING-874 : Use new commons compiler for java servlet scripting

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 80e732ca4f8279ba9842be9b535d4a8b509c7097
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 19 08:57:05 2010 +0000

    SLING-874 : Use new commons compiler for java servlet scripting
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@925144 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 01/16: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit acd44c85e48f2f912fb530ac4d5201b9baef683d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Nov 26 15:56:22 2009 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@884611 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e65a1e3..15fafff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.scripting.java</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Scripting Java Support</name>
     <description>Support for scripting Java</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.scripting.java-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.scripting.java-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.scripting.java-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 05/16: Use string builder instead of string buffer

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 27ed977735b9cd5e399eebdd2b56efa3d0ffa66a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 15 08:38:47 2010 +0000

    Use string builder instead of string buffer
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@899563 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/scripting/java/CompilationContext.java  |  2 +-
 .../java/org/apache/sling/scripting/java/CompilerUtil.java   |  4 ++--
 .../org/apache/sling/scripting/java/jdt/CompilationUnit.java | 12 ++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
index 89af03d..ebf646c 100644
--- a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
+++ b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
@@ -211,7 +211,7 @@ public class CompilationContext {
     protected final static class CompilerException extends ServletException {
 
         public static CompilerException create(List<CompilerError> errors) {
-            final StringBuffer buffer = new StringBuffer();
+            final StringBuilder buffer = new StringBuilder();
             buffer.append("Compilation errors:\n");
             for(final CompilerError e : errors) {
                 buffer.append(e.getFile());
diff --git a/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java b/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java
index d415ed7..f7d2805 100644
--- a/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java
+++ b/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java
@@ -59,8 +59,8 @@ public class CompilerUtil {
      * @return Legal Java identifier corresponding to the given identifier
      */
     public static final String makeJavaIdentifier(String identifier) {
-        StringBuffer modifiedIdentifier =
-            new StringBuffer(identifier.length());
+        StringBuilder modifiedIdentifier =
+            new StringBuilder(identifier.length());
         if (!Character.isJavaIdentifierStart(identifier.charAt(0))) {
             modifiedIdentifier.append('_');
         }
diff --git a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
index c34a1c0..e491699 100644
--- a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
+++ b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
@@ -84,7 +84,7 @@ public class CompilationUnit
             final Reader reader = new BufferedReader(new InputStreamReader(fr, this.options.getJavaEncoding()));
             try {
                 char[] chars = new char[8192];
-                StringBuffer buf = new StringBuffer();
+                StringBuilder buf = new StringBuilder();
                 int count;
                 while ((count = reader.read(chars, 0, chars.length)) > 0) {
                     buf.append(chars, 0, count);
@@ -128,7 +128,7 @@ public class CompilationUnit
      * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[][])
      */
     public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         for (int i = 0; i < compoundTypeName.length; i++) {
             if (i > 0) {
                 result.append(".");
@@ -142,7 +142,7 @@ public class CompilationUnit
      * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[], char[][])
      */
     public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         for (int i = 0; i < packageName.length; i++) {
             if (i > 0) {
                 result.append(".");
@@ -213,7 +213,7 @@ public class CompilationUnit
      * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#isPackage(char[][], char[])
      */
     public boolean isPackage(char[][] parentPackageName, char[] packageName) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         if (parentPackageName != null) {
             for (int i = 0; i < parentPackageName.length; i++) {
                 if (i > 0) {
@@ -254,7 +254,7 @@ public class CompilationUnit
                 for (int i = 0; i < classFiles.length; i++) {
                     ClassFile classFile = classFiles[i];
                     char[][] compoundName = classFile.getCompoundName();
-                    StringBuffer className = new StringBuffer();
+                    StringBuilder className = new StringBuilder();
                     for (int j = 0;  j < compoundName.length; j++) {
                         if (j > 0) {
                             className.append(".");
@@ -262,7 +262,7 @@ public class CompilationUnit
                         className.append(compoundName[j]);
                     }
                     byte[] bytes = classFile.getBytes();
-                    final StringBuffer b = new StringBuffer(this.options.getDestinationPath());
+                    final StringBuilder b = new StringBuilder(this.options.getDestinationPath());
                     b.append('/');
                     b.append(className.toString().replace('.', '/'));
                     b.append(".class");

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 08/16: SLING-1385 : Recompile java scripts on modifications and avoid periodic check - fix error handling and sync problems.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit c7eeecd23b4b3d893ecce2f97df1dc7da966216a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 12 11:12:41 2010 +0000

    SLING-1385 : Recompile java scripts on modifications and avoid periodic check - fix error handling and sync problems.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@922216 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/scripting/java/CompilationContext.java   |  26 +++--
 .../scripting/java/JavaScriptEngineFactory.java    |   7 +-
 .../sling/scripting/java/ServletWrapper.java       | 106 +++++++++------------
 3 files changed, 59 insertions(+), 80 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
index 764d95b..6efe3f3 100644
--- a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
+++ b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sling.scripting.java;
 
-import java.io.FileNotFoundException;
 import java.util.List;
 
 import javax.servlet.ServletException;
@@ -135,8 +134,8 @@ public class CompilationContext {
         return this.lastModificationTest;
     }
 
-    public void setLastModificationTest(final long value) {
-        this.lastModificationTest = value;
+    public void clearLastModificationTest() {
+        this.lastModificationTest = 0;
     }
 
     /**
@@ -146,8 +145,6 @@ public class CompilationContext {
         if ( this.lastModificationTest > 0 ) {
             return false;
         }
-        this.lastModificationTest = System.currentTimeMillis();
-
         final long sourceLastModified = this.ioProvider.lastModified(getSourcePath());
 
         final long targetLastModified = this.ioProvider.lastModified(getCompleteClassPath());
@@ -173,33 +170,32 @@ public class CompilationContext {
 
     // ==================== Compile and reload ====================
 
-    public void compile() throws ServletException, FileNotFoundException {
+    public boolean compile() throws Exception {
         if (this.isOutDated()) {
             try {
                 final List<CompilerError> errors = this.compiler.compile();
                 if ( errors != null ) {
-                    //this.ioProvider.delete(getCompleteClassPath());
                     throw CompilerException.create(errors);
                 }
-                this.wrapper.setReload(true);
                 this.wrapper.setCompilationException(null);
-            } catch (ServletException se) {
-                this.wrapper.setCompilationException(se);
-                throw se;
+                return true;
             } catch (Exception ex) {
-                final ServletException se = new ServletException("Unable to compile servlet.", ex);
                 // Cache compilation exception
-                this.wrapper.setCompilationException(se);
-                throw se;
+                this.wrapper.setCompilationException(ex);
+                throw ex;
+            } finally {
+                this.lastModificationTest = System.currentTimeMillis();
             }
         }
+        this.lastModificationTest = System.currentTimeMillis();
+        return false;
     }
 
     /**
      * Load the class.
      */
     public Class<?> load()
-    throws ServletException, FileNotFoundException {
+    throws ServletException {
         final String name = this.getClassFilePath().substring(1).replace('/', '.');
         try {
             servletClass = this.options.getClassLoader().loadClass(name);
diff --git a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
index 2e1e4a6..d6f1f1a 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
@@ -168,10 +168,13 @@ public class JavaScriptEngineFactory
             this.eventHandlerRegistration.unregister();
             this.eventHandlerRegistration = null;
         }
+        if ( this.servletCache != null ) {
+            this.servletCache.destroy();
+            this.servletCache = null;
+        }
         ioProvider = null;
         javaServletContext = null;
         servletConfig = null;
-        servletCache = null;
         compilerOptions = null;
     }
 
@@ -279,7 +282,7 @@ public class JavaScriptEngineFactory
     private void handleModification(final String scriptName) {
         final ServletWrapper wrapper = this.servletCache.getWrapper(scriptName);
         if ( wrapper != null ) {
-            wrapper.getCompilationContext().setLastModificationTest(0);
+            wrapper.getCompilationContext().clearLastModificationTest();
         }
     }
 
diff --git a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
index 481d832..a315648 100644
--- a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
+++ b/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
@@ -50,13 +50,9 @@ public class ServletWrapper {
     /** The servlet config. */
     private ServletConfig config;
 
-    /** Reload flag. */
-    private boolean reload = true;
-
     private Servlet theServlet;
     private long available = 0L;
-    private boolean firstTime = true;
-    private ServletException compileException;
+    private Exception compileException;
     private CompilationContext ctxt;
 
     /**
@@ -73,53 +69,38 @@ public class ServletWrapper {
                 ioProvider, servletCache, this);
     }
 
-    /**
-     * Set the reload flag.
-     * @param reload
-     */
-    public void setReload(boolean reload) {
-        this.reload = reload;
-    }
-
     public CompilationContext getCompilationContext() {
         return this.ctxt;
     }
 
     /**
      * Get the servlet.
-     * @return The servlet.
      * @throws ServletException
      * @throws IOException
      * @throws FileNotFoundException
      */
-    private Servlet getServlet()
-    throws ServletException, IOException, FileNotFoundException {
-        if (reload) {
-            synchronized (this) {
-                if (reload) {
-                    destroy();
+    private void getServlet()
+    throws ServletException {
+        destroy();
 
-                    Servlet servlet = null;
+        Servlet servlet = null;
 
-                    try {
-                        final Class<?> servletClass = ctxt.load();
-                        servlet = (Servlet) servletClass.newInstance();
-                    } catch (IllegalAccessException e) {
-                        throw new ServletException(e);
-                    } catch (InstantiationException e) {
-                        throw new ServletException(e);
-                    } catch (Exception e) {
-                        throw new ServletException(e);
-                    }
+        try {
+            final Class<?> servletClass = ctxt.load();
+            servlet = (Servlet) servletClass.newInstance();
+        } catch (IllegalAccessException e) {
+            throw new ServletException(e);
+        } catch (InstantiationException e) {
+            throw new ServletException(e);
+        } catch (ServletException se) {
+            throw se;
+        } catch (Exception e) {
+            throw new ServletException(e);
+        }
 
-                    servlet.init(config);
+        servlet.init(config);
 
-                    theServlet = servlet;
-                    reload = false;
-                }
-            }
-        }
-        return theServlet;
+        theServlet = servlet;
     }
 
     /**
@@ -127,7 +108,7 @@ public class ServletWrapper {
      *
      * @param je The compilation exception
      */
-    public void setCompilationException(ServletException je) {
+    public void setCompilationException(final Exception je) {
         this.compileException = je;
     }
 
@@ -164,10 +145,9 @@ public class ServletWrapper {
      * @throws IOException
      * @throws FileNotFoundException
      */
-    public void service(HttpServletRequest request,
+    private void service(HttpServletRequest request,
                         HttpServletResponse response)
-    throws ServletException, IOException, FileNotFoundException {
-
+    throws ServletException, IOException {
         try {
 
             if (ctxt.isRemoved()) {
@@ -180,43 +160,43 @@ public class ServletWrapper {
                     response.sendError
                         (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
                          "Servlet unavailable.");
+                    logger.error("Java servlet {} is unavailable.", this.servletUri);
                     return;
                 }
                 // Wait period has expired. Reset.
                 available = 0;
             }
 
-            /*
-             * (1) Compile
-             */
-            if (firstTime || ctxt.getLastModificationTest() == 0 ) {
+            // check for compilation
+            if (ctxt.getLastModificationTest() == 0 ) {
                 synchronized (this) {
-                    firstTime = false;
-
-                    // The following sets reload to true, if necessary
-                    ctxt.compile();
-                }
-            } else {
-                if (compileException != null) {
-                    // Throw cached compilation exception
-                    throw compileException;
+                    if (ctxt.getLastModificationTest() == 0 ) {
+                        if ( ctxt.compile() ) {
+                            // (re)load the servlet class
+                            getServlet();
+                        }
+
+                    } else if (compileException != null) {
+                        // Throw cached compilation exception
+                        throw compileException;
+                    }
                 }
+            } else if (compileException != null) {
+                // Throw cached compilation exception
+                throw compileException;
             }
 
-            /*
-             * (2) (Re)load servlet class file
-             */
-            getServlet();
-
         } catch (FileNotFoundException ex) {
             ctxt.incrementRemoved();
             try {
                 response.sendError(HttpServletResponse.SC_NOT_FOUND,
                                   ex.getMessage());
+                logger.error("Java servlet {} not found.", this.servletUri);
             } catch (IllegalStateException ise) {
                 logger.error("Java servlet source not found." +
                        ex.getMessage(), ex);
             }
+            return;
         } catch (SlingException ex) {
             throw ex;
         } catch (ServletException ex) {
@@ -231,9 +211,7 @@ public class ServletWrapper {
 
         try {
 
-            /*
-             * (3) Service request
-             */
+            // invoke the servlet
             if (theServlet instanceof SingleThreadModel) {
                // sync on the wrapper so that the freshness
                // of the page is determined right before servicing
@@ -254,6 +232,8 @@ public class ServletWrapper {
             response.sendError
                 (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
                  ex.getMessage());
+            logger.error("Java servlet {} is unavailable.", this.servletUri);
+            return;
         } catch (SlingException ex) {
             throw ex;
         } catch (ServletException ex) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 09/16: SLING-874 : Use new commons compiler for java servlet scripting

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit cfd7362dec59153539584c428eb2d3740fca3a58
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 19 08:56:14 2010 +0000

    SLING-874 : Use new commons compiler for java servlet scripting
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@925142 13f79535-47bb-0310-9956-ffa450edef68
---
 NOTICE                                             |   2 +-
 pom.xml                                            |  27 +-
 .../sling/scripting/java/CompilationContext.java   | 233 ----------------
 .../apache/sling/scripting/java/CompilerError.java | 161 -----------
 .../org/apache/sling/scripting/java/Options.java   | 139 ----------
 .../sling/scripting/java/ServletWrapper.java       | 259 ------------------
 .../sling/scripting/java/impl/CompilationUnit.java | 180 +++++++++++++
 .../sling/scripting/java/impl/CompilerError.java   | 100 +++++++
 .../sling/scripting/java/impl/CompilerOptions.java |  49 ++++
 .../scripting/java/{ => impl}/CompilerUtil.java    |  22 +-
 .../java/{ => impl}/JavaScriptEngineFactory.java   |  99 ++++---
 .../java/{ => impl}/JavaServletConfig.java         |   2 +-
 .../java/{ => impl}/JavaServletContext.java        |   2 +-
 .../scripting/java/{ => impl}/ServletCache.java    |   2 +-
 .../sling/scripting/java/impl/ServletWrapper.java  | 242 +++++++++++++++++
 .../scripting/java/{ => impl}/SlingIOProvider.java | 110 +++++---
 .../sling/scripting/java/jdt/CompilationUnit.java  | 299 ---------------------
 .../scripting/java/jdt/EclipseJavaCompiler.java    | 118 --------
 src/main/resources/META-INF/NOTICE                 |   2 +-
 .../OSGI-INF/metatype/metatype.properties          |   4 -
 20 files changed, 714 insertions(+), 1338 deletions(-)

diff --git a/NOTICE b/NOTICE
index 4b1c970..2cce499 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Java Scripting Support
-Copyright 2008-2009 The Apache Software Foundation
+Copyright 2008-2010 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).
diff --git a/pom.xml b/pom.xml
index e8cdc34..db84dac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,21 +52,11 @@
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
-                        <Import-Package>
-                            !org.eclipse.*, *
-                        </Import-Package>
                         <Private-Package>
-                            org.apache.sling.scripting.java,
-                            org.apache.sling.scripting.java.jdt,
-                            org.eclipse.jdt.*
+                            org.apache.sling.scripting.java.impl
                         </Private-Package>
-
                         <ScriptEngine-Name>${pom.name}</ScriptEngine-Name>
                         <ScriptEngine-Version>${pom.version}</ScriptEngine-Version>
-
-                        <Embed-Dependency>
-                            jasper*
-                        </Embed-Dependency>
                     </instructions>
                 </configuration>
             </plugin>
@@ -78,9 +68,9 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-javadoc-plugin</artifactId>
                 <configuration>
-                  <!-- No javadocs -->
+                     <!-- No javadocs -->
                     <excludePackageNames>
-                        org.apache.sling.scripting
+                        org.apache.sling.scripting.java.impl
                     </excludePackageNames>
                 </configuration>
             </plugin>
@@ -92,23 +82,26 @@
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
             <version>2.0.8</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.api</artifactId>
             <version>2.0.2-incubator</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
             <version>1.0.0</version>
+            <scope>provided</scope>
         </dependency>
 
-     <!-- We use the same eclipse jdt as the jsp bundle -->
         <dependency>
-            <groupId>org.apache.tomcat</groupId>
-            <artifactId>jasper-jdt</artifactId>
-            <version>6.0.18</version>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.compiler</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
diff --git a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
deleted file mode 100644
index 6efe3f3..0000000
--- a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.sling.scripting.java;
-
-import java.util.List;
-
-import javax.servlet.ServletException;
-
-import org.apache.sling.scripting.java.jdt.EclipseJavaCompiler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class CompilationContext {
-
-    private Logger logger = LoggerFactory.getLogger(getClass());
-
-    /** The name of the generated class. */
-    private final String className;
-
-    /** The path to the servlet. */
-    private final String sourcePath;
-
-    /** The mapped path. */
-    private final String mappedSourcePath;
-
-    /** Compilation options. */
-    private final Options options;
-
-    /** The compiler instance. */
-    private final EclipseJavaCompiler compiler;
-
-    /** Sling IO Provider. */
-    private final SlingIOProvider ioProvider;
-
-    private ServletCache servletCache;
-
-    private volatile long lastModificationTest = 0L;
-    private int removed = 0;
-
-    private Class<?> servletClass;
-
-    private final ServletWrapper wrapper;
-
-    /**
-     * A new compilation context.
-     * @param sourcePath The path to the servlet source.
-     * @param options The compiler options
-     * @param provider The Sling IO Provider
-     * @param servletCache
-     */
-    public CompilationContext(final String sourcePath,
-                              final Options options,
-                              final SlingIOProvider provider,
-                              ServletCache servletCache,
-                              final ServletWrapper wrapper) {
-        this.sourcePath = sourcePath;
-        this.mappedSourcePath = CompilerUtil.mapSourcePath(this.sourcePath);
-        this.className = CompilerUtil.makeClassPath(this.mappedSourcePath);
-
-        this.options = options;
-        this.ioProvider = provider;
-        this.compiler = new EclipseJavaCompiler(this);
-
-        this.servletCache = servletCache;
-        this.wrapper = wrapper;
-    }
-
-    /**
-     * Options
-     */
-    public Options getCompilerOptions() {
-        return options;
-    }
-
-    /**
-     * Provider
-     */
-    public SlingIOProvider getIOProvider() {
-        return this.ioProvider;
-    }
-
-    /**
-     * Return the path to the java servlet source file
-     * @return The source file path.
-     */
-    public String getSourcePath() {
-        return this.sourcePath;
-    }
-
-    public String getJavaClassName() {
-        return this.mappedSourcePath.replace('/', '.');
-    }
-
-    /**
-     * Return the path to the generated class file.
-     * @return The class file path.
-     */
-    public String getClassFilePath() {
-        return this.className;
-    }
-
-    public void incrementRemoved() {
-        if (removed == 0 && servletCache != null) {
-            servletCache.removeWrapper(sourcePath);
-        }
-        removed++;
-    }
-
-    public boolean isRemoved() {
-        if (removed > 1 ) {
-            return true;
-        }
-        return false;
-    }
-
-    public long getLastModificationTest() {
-        return this.lastModificationTest;
-    }
-
-    public void clearLastModificationTest() {
-        this.lastModificationTest = 0;
-    }
-
-    /**
-     * Check if the compiled class file is older than the source file
-     */
-    public boolean isOutDated() {
-        if ( this.lastModificationTest > 0 ) {
-            return false;
-        }
-        final long sourceLastModified = this.ioProvider.lastModified(getSourcePath());
-
-        final long targetLastModified = this.ioProvider.lastModified(getCompleteClassPath());
-        if (targetLastModified < 0) {
-            return true;
-        }
-
-        if (targetLastModified < sourceLastModified) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Compiler: outdated: " + getClassFilePath() + " "
-                        + targetLastModified);
-            }
-            return true;
-        }
-
-        return false;
-
-    }
-
-    private String getCompleteClassPath() {
-        return options.getDestinationPath() + getClassFilePath() + ".class";
-    }
-
-    // ==================== Compile and reload ====================
-
-    public boolean compile() throws Exception {
-        if (this.isOutDated()) {
-            try {
-                final List<CompilerError> errors = this.compiler.compile();
-                if ( errors != null ) {
-                    throw CompilerException.create(errors);
-                }
-                this.wrapper.setCompilationException(null);
-                return true;
-            } catch (Exception ex) {
-                // Cache compilation exception
-                this.wrapper.setCompilationException(ex);
-                throw ex;
-            } finally {
-                this.lastModificationTest = System.currentTimeMillis();
-            }
-        }
-        this.lastModificationTest = System.currentTimeMillis();
-        return false;
-    }
-
-    /**
-     * Load the class.
-     */
-    public Class<?> load()
-    throws ServletException {
-        final String name = this.getClassFilePath().substring(1).replace('/', '.');
-        try {
-            servletClass = this.options.getClassLoader().loadClass(name);
-        } catch (ClassNotFoundException cex) {
-            throw new ServletException("Servlet class not found: " + name, cex);
-        } catch (Exception ex) {
-            throw new ServletException("Unable to compile servlet: " + name, ex);
-        }
-        removed = 0;
-        return servletClass;
-    }
-
-    protected final static class CompilerException extends ServletException {
-
-        public static CompilerException create(List<CompilerError> errors) {
-            final StringBuilder buffer = new StringBuilder();
-            buffer.append("Compilation errors:\n");
-            for(final CompilerError e : errors) {
-                buffer.append(e.getFile());
-                buffer.append(", line ");
-                buffer.append(e.getStartLine());
-                buffer.append(", column ");
-                buffer.append(e.getStartColumn());
-                buffer.append(" : " );
-                buffer.append(e.getMessage());
-                buffer.append("\n");
-            }
-            return new CompilerException(buffer.toString());
-        }
-
-        public CompilerException(final String message) {
-           super(message);
-        }
-    }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/CompilerError.java b/src/main/java/org/apache/sling/scripting/java/CompilerError.java
deleted file mode 100644
index e29f67c..0000000
--- a/src/main/java/org/apache/sling/scripting/java/CompilerError.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.sling.scripting.java;
-
-/**
- * This class encapsulates an error message produced by a programming language
- * processor (whether interpreted or compiled)
- * @version $Id$
- * @since 2.0
- */
-
-public class CompilerError {
-  /**
-   * Is this a severe error or a warning?
-   */
-  private boolean error;
-  /**
-   * The start line number of the offending program text
-   */
-  private int startline;
-  /**
-   * The start column number of the offending program text
-   */
-  private int startcolumn;
-  /**
-   * The end line number of the offending program text
-   */
-  private int endline;
-  /**
-   * The end column number of the offending program text
-   */
-  private int endcolumn;
-  /**
-   * The name of the file containing the offending program text
-   */
-  private String file;
-  /**
-   * The actual error text produced by the language processor
-   */
-  private String message;
-
-  /**
-   * The error message constructor.
-   *
-   * @param file The name of the file containing the offending program text
-   * @param error The actual error text produced by the language processor
-   * @param startline The start line number of the offending program text
-   * @param startcolumn The start column number of the offending program text
-   * @param endline The end line number of the offending program text
-   * @param endcolumn The end column number of the offending program text
-   * @param message The actual error text produced by the language processor
-   */
-  public CompilerError(
-    String file,
-    boolean error,
-    int startline,
-    int startcolumn,
-    int endline,
-    int endcolumn,
-    String message
-  )
-  {
-    this.file = file;
-    this.error = error;
-    this.startline = startline;
-    this.startcolumn = startcolumn;
-    this.endline = endline;
-    this.endcolumn = endcolumn;
-    this.message = message;
-  }
-
-  /**
-   * The error message constructor.
-   *
-   * @param message The actual error text produced by the language processor
-   */
-  public CompilerError(String message) {
-    this.message = message;
-  }
-
-  /**
-   * Return the filename associated with this compiler error.
-   *
-   * @return The filename associated with this compiler error
-   */
-  public String getFile() {
-    return file;
-  }
-
-  /**
-   * Assert whether this is a severe error or a warning
-   *
-   * @return Whether the error is severe
-   */
-  public boolean isError() {
-    return error;
-  }
-
-  /**
-   * Return the starting line number of the program text originating this error
-   *
-   * @return The starting line number of the program text originating this error
-   */
-  public int getStartLine() {
-    return startline;
-  }
-
-  /**
-   * Return the starting column number of the program text originating this
-   * error
-   *
-   * @return The starting column number of the program text originating this
-   * error
-   */
-  public int getStartColumn() {
-    return startcolumn;
-  }
-
-  /**
-   * Return the ending line number of the program text originating this error
-   *
-   * @return The ending line number of the program text originating this error
-   */
-  public int getEndLine() {
-    return endline;
-  }
-
-  /**
-   * Return the ending column number of the program text originating this
-   * error
-   *
-   * @return The ending column number of the program text originating this
-   * error
-   */
-  public int getEndColumn() {
-    return endcolumn;
-  }
-
-  /**
-   * Return the message produced by the language processor
-   *
-   * @return The message produced by the language processor
-   */
-  public String getMessage() {
-    return message;
-  }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/Options.java b/src/main/java/org/apache/sling/scripting/java/Options.java
deleted file mode 100644
index 4dea523..0000000
--- a/src/main/java/org/apache/sling/scripting/java/Options.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.sling.scripting.java;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import org.osgi.service.component.ComponentContext;
-
-
-/**
- * A class to hold all init parameters specific to the compiler
- */
-public class Options {
-
-    private static final String PROPERTY_JAVA_ENCODING = "javaEncoding";
-
-    private static final String PROPERTY_COMPILER_SOURCE_V_M = "compilerSourceVM";
-
-    private static final String PROPERTY_COMPILER_TARGET_V_M = "compilerTargetVM";
-
-    private static final String PROPERTY_CLASSDEBUGINFO = "classdebuginfo";
-
-    /** Default source and target VM version (value is "1.5"). */
-    private static final String DEFAULT_VM_VERSION = "1.5";
-
-    /**
-     * Do we want to include debugging information in the class file?
-     */
-    private final boolean classDebugInfo;
-
-    /**
-     * Compiler target VM.
-     */
-    private final String compilerTargetVM;
-
-    /**
-     * The compiler source VM.
-     */
-    private final String compilerSourceVM;
-
-    /**
-     * Java platform encoding to generate the servlet.
-     */
-    private final String javaEncoding;
-
-    /**
-     * Classloader
-     */
-    private final ClassLoader classLoader;
-
-    /**
-     * Create an compiler options object using data available from
-     * the component configuration.
-     */
-    public Options(final ComponentContext componentContext,
-                   final ClassLoader classLoader) {
-
-        this.classLoader = classLoader;
-
-        // generate properties
-        final Properties properties = new Properties();
-        // set default values first
-        properties.put(PROPERTY_CLASSDEBUGINFO, "true");
-        properties.put(PROPERTY_COMPILER_TARGET_V_M, DEFAULT_VM_VERSION);
-        properties.put(PROPERTY_COMPILER_SOURCE_V_M, DEFAULT_VM_VERSION);
-        properties.put(PROPERTY_JAVA_ENCODING, "UTF-8");
-
-        // now check component properties
-        Dictionary<?, ?> config = componentContext.getProperties();
-        Enumeration<?> enumeration = config.keys();
-        while (enumeration.hasMoreElements()) {
-            String key = (String) enumeration.nextElement();
-            if (key.startsWith("java.")) {
-                Object value = config.get(key);
-                if (value != null) {
-                    properties.put(key.substring("java.".length()),
-                        value.toString());
-                }
-            }
-        }
-
-        this.classDebugInfo = Boolean.valueOf(properties.get(PROPERTY_CLASSDEBUGINFO).toString());
-        this.compilerTargetVM = properties.get(PROPERTY_COMPILER_TARGET_V_M).toString();
-        this.compilerSourceVM = properties.get(PROPERTY_COMPILER_SOURCE_V_M).toString();
-        this.javaEncoding = properties.get(PROPERTY_JAVA_ENCODING).toString();
-    }
-
-    /**
-     * Return the destination directory.
-     */
-    public String getDestinationPath() {
-        return ":";
-    }
-
-    /**
-     * Should class files be compiled with debug information?
-     */
-    public boolean getClassDebugInfo() {
-        return this.classDebugInfo;
-    }
-
-    public ClassLoader getClassLoader() {
-        return this.classLoader;
-    }
-
-    /**
-     * @see Options#getCompilerTargetVM
-     */
-    public String getCompilerTargetVM() {
-        return this.compilerTargetVM;
-    }
-
-    /**
-     * @see Options#getCompilerSourceVM
-     */
-    public String getCompilerSourceVM() {
-        return this.compilerSourceVM;
-    }
-
-    public String getJavaEncoding() {
-        return this.javaEncoding;
-    }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
deleted file mode 100644
index a315648..0000000
--- a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * 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.sling.scripting.java;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.SingleThreadModel;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.sling.api.SlingException;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingIOException;
-import org.apache.sling.api.SlingServletException;
-import org.apache.sling.api.scripting.SlingBindings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
-
- */
-
-public class ServletWrapper {
-
-    /** The logger. */
-    private final Logger logger = LoggerFactory.getLogger(getClass());
-
-    private final String servletUri;
-
-    /** The servlet config. */
-    private ServletConfig config;
-
-    private Servlet theServlet;
-    private long available = 0L;
-    private Exception compileException;
-    private CompilationContext ctxt;
-
-    /**
-     * A wrapper for servlets.
-     */
-    public ServletWrapper(final ServletConfig config,
-                          final Options options,
-                          final SlingIOProvider ioProvider,
-                          final String servletPath,
-                          final ServletCache servletCache) {
-        this.config = config;
-        this.servletUri = servletPath;
-        this.ctxt = new CompilationContext(servletUri, options,
-                ioProvider, servletCache, this);
-    }
-
-    public CompilationContext getCompilationContext() {
-        return this.ctxt;
-    }
-
-    /**
-     * Get the servlet.
-     * @throws ServletException
-     * @throws IOException
-     * @throws FileNotFoundException
-     */
-    private void getServlet()
-    throws ServletException {
-        destroy();
-
-        Servlet servlet = null;
-
-        try {
-            final Class<?> servletClass = ctxt.load();
-            servlet = (Servlet) servletClass.newInstance();
-        } catch (IllegalAccessException e) {
-            throw new ServletException(e);
-        } catch (InstantiationException e) {
-            throw new ServletException(e);
-        } catch (ServletException se) {
-            throw se;
-        } catch (Exception e) {
-            throw new ServletException(e);
-        }
-
-        servlet.init(config);
-
-        theServlet = servlet;
-    }
-
-    /**
-     * Sets the compilation exception for this ServletWrapper.
-     *
-     * @param je The compilation exception
-     */
-    public void setCompilationException(final Exception je) {
-        this.compileException = je;
-    }
-
-    /**
-     * @param bindings
-     * @throws SlingIOException
-     * @throws SlingServletException
-     * @throws IllegalArgumentException if the Jasper Precompile controller
-     *             request parameter has an illegal value.
-     */
-    public void service(SlingBindings bindings) {
-        final SlingHttpServletRequest request = bindings.getRequest();
-        final Object oldValue = request.getAttribute(SlingBindings.class.getName());
-        try {
-            request.setAttribute(SlingBindings.class.getName(), bindings);
-            service(request, bindings.getResponse());
-        } catch (SlingException se) {
-            // rethrow as is
-            throw se;
-        } catch (IOException ioe) {
-            throw new SlingIOException(ioe);
-        } catch (ServletException se) {
-            throw new SlingServletException(se);
-        } finally {
-            request.setAttribute(SlingBindings.class.getName(), oldValue);
-        }
-    }
-
-    /**
-     * Call the servlet.
-     * @param request The current request.
-     * @param response The current response.
-     * @throws ServletException
-     * @throws IOException
-     * @throws FileNotFoundException
-     */
-    private void service(HttpServletRequest request,
-                        HttpServletResponse response)
-    throws ServletException, IOException {
-        try {
-
-            if (ctxt.isRemoved()) {
-                throw new FileNotFoundException(servletUri);
-            }
-
-            if ((available > 0L) && (available < Long.MAX_VALUE)) {
-                if (available > System.currentTimeMillis()) {
-                    response.setDateHeader("Retry-After", available);
-                    response.sendError
-                        (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
-                         "Servlet unavailable.");
-                    logger.error("Java servlet {} is unavailable.", this.servletUri);
-                    return;
-                }
-                // Wait period has expired. Reset.
-                available = 0;
-            }
-
-            // check for compilation
-            if (ctxt.getLastModificationTest() == 0 ) {
-                synchronized (this) {
-                    if (ctxt.getLastModificationTest() == 0 ) {
-                        if ( ctxt.compile() ) {
-                            // (re)load the servlet class
-                            getServlet();
-                        }
-
-                    } else if (compileException != null) {
-                        // Throw cached compilation exception
-                        throw compileException;
-                    }
-                }
-            } else if (compileException != null) {
-                // Throw cached compilation exception
-                throw compileException;
-            }
-
-        } catch (FileNotFoundException ex) {
-            ctxt.incrementRemoved();
-            try {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND,
-                                  ex.getMessage());
-                logger.error("Java servlet {} not found.", this.servletUri);
-            } catch (IllegalStateException ise) {
-                logger.error("Java servlet source not found." +
-                       ex.getMessage(), ex);
-            }
-            return;
-        } catch (SlingException ex) {
-            throw ex;
-        } catch (ServletException ex) {
-            throw ex;
-        } catch (IOException ex) {
-            throw ex;
-        } catch (IllegalStateException ex) {
-            throw ex;
-        } catch (Exception ex) {
-            throw new ServletException(ex);
-        }
-
-        try {
-
-            // invoke the servlet
-            if (theServlet instanceof SingleThreadModel) {
-               // sync on the wrapper so that the freshness
-               // of the page is determined right before servicing
-               synchronized (this) {
-                   theServlet.service(request, response);
-                }
-            } else {
-                theServlet.service(request, response);
-            }
-
-        } catch (UnavailableException ex) {
-            int unavailableSeconds = ex.getUnavailableSeconds();
-            if (unavailableSeconds <= 0) {
-                unavailableSeconds = 60;        // Arbitrary default
-            }
-            available = System.currentTimeMillis() +
-                (unavailableSeconds * 1000L);
-            response.sendError
-                (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
-                 ex.getMessage());
-            logger.error("Java servlet {} is unavailable.", this.servletUri);
-            return;
-        } catch (SlingException ex) {
-            throw ex;
-        } catch (ServletException ex) {
-            throw ex;
-        } catch (IOException ex) {
-            throw ex;
-        } catch (IllegalStateException ex) {
-            throw ex;
-        } catch (Exception ex) {
-            throw new ServletException(ex);
-        }
-    }
-
-    /**
-     * Destroy the servlet.
-     */
-    public void destroy() {
-        if (theServlet != null) {
-            theServlet.destroy();
-            theServlet = null;
-        }
-    }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
new file mode 100644
index 0000000..86660af
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
@@ -0,0 +1,180 @@
+/*
+ * 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.sling.scripting.java.impl;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sling.commons.compiler.ClassWriter;
+import org.apache.sling.commons.compiler.CompileUnit;
+import org.apache.sling.commons.compiler.CompilerEnvironment;
+import org.apache.sling.commons.compiler.ErrorHandler;
+
+
+public class CompilationUnit
+    implements CompileUnit, CompilerEnvironment, ErrorHandler, ClassWriter {
+
+    private final SlingIOProvider ioProvider;
+    private final String className;
+    private final String sourceFile;
+
+    /** The list of compile errors - this is created lazily. */
+    private List<CompilerError> errors;
+
+    public CompilationUnit(String sourceFile,
+                           String className,
+                           SlingIOProvider ioProvider) {
+        this.className = className;
+        this.sourceFile = sourceFile;
+        this.ioProvider = ioProvider;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompileUnit#getSourceFileName()
+     */
+    public String getSourceFileName() {
+        return getMainTypeName() + ".java";
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompileUnit#getSourceFileContents()
+     */
+    public char[] getSourceFileContents() {
+        char[] result = null;
+        InputStream fr = null;
+        try {
+            fr = ioProvider.getInputStream(this.sourceFile);
+            final Reader reader = new BufferedReader(new InputStreamReader(fr, ioProvider.getOptions().getJavaEncoding()));
+            try {
+                char[] chars = new char[8192];
+                StringBuilder buf = new StringBuilder();
+                int count;
+                while ((count = reader.read(chars, 0, chars.length)) > 0) {
+                    buf.append(chars, 0, count);
+                }
+                result = new char[buf.length()];
+                buf.getChars(0, result.length, result, 0);
+            } finally {
+                reader.close();
+            }
+        } catch (IOException e) {
+            this.onError(e.getMessage(), this.sourceFile, 0, 0);
+        }
+        return result;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompileUnit#getMainTypeName()
+     */
+    public String getMainTypeName() {
+        int dot = className.lastIndexOf('.');
+        if (dot > 0) {
+            return className.substring(dot + 1);
+        }
+        return className;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilerEnvironment#isPackage(java.lang.String)
+     */
+    public boolean isPackage(String result) {
+        if (result.equals(this.className)) {
+            return false;
+        }
+        String resourceName = result.replace('.', '/') + ".class";
+        if ( resourceName.startsWith("/") ) {
+            resourceName = resourceName.substring(1);
+        }
+        final InputStream is = this.ioProvider.getClassLoader().getResourceAsStream(resourceName);
+        if ( is != null ) {
+            try {
+                is.close();
+            } catch (IOException ignore) {}
+        }
+        return is == null;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilerEnvironment#findClass(java.lang.String)
+     */
+    public byte[] findClass(String name) throws Exception {
+        final String resourceName = name.replace('.', '/') + ".class";
+        final InputStream is = this.ioProvider.getClassLoader().getResourceAsStream(resourceName);
+        if (is != null) {
+            try {
+                byte[] buf = new byte[8192];
+                ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
+                int count;
+                while ((count = is.read(buf, 0, buf.length)) > 0) {
+                    baos.write(buf, 0, count);
+                }
+                baos.flush();
+                return baos.toByteArray();
+            } finally {
+                try {
+                    is.close();
+                } catch (IOException ignore) {}
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.CompilerEnvironment#cleanup()
+     */
+    public void cleanup() {
+        // EMPTY
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.ErrorHandler#onError(java.lang.String, java.lang.String, int, int)
+     */
+    public void onError(String msg, String sourceFile, int line, int position) {
+        if ( errors == null ) {
+            errors = new ArrayList<CompilerError>();
+        }
+        errors.add(new CompilerError(sourceFile, line, position, msg));
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.ErrorHandler#onWarning(java.lang.String, java.lang.String, int, int)
+     */
+    public void onWarning(String msg, String sourceFile, int line, int position) {
+        // we ignore warnings
+    }
+
+    /**
+     * @see org.apache.sling.commons.compiler.ClassWriter#write(java.lang.String, byte[])
+     */
+    public void write(String name, byte[] data) throws Exception {
+        final OutputStream os = this.ioProvider.getOutputStream('/' + name.replace('.', '/') + ".class");
+        os.write(data);
+        os.close();
+    }
+
+    /** Return the list of errors. */
+    public List<CompilerError> getErrors() throws IOException {
+        return errors;
+    }
+}
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java
new file mode 100644
index 0000000..4f7dcb9
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java
@@ -0,0 +1,100 @@
+/*
+ * 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.sling.scripting.java.impl;
+
+/**
+ * This class encapsulates an error message produced by a programming language
+ * processor (whether interpreted or compiled)
+ */
+public class CompilerError {
+
+    /**
+     * The start line number of the offending program text
+     */
+    private final int startline;
+
+    /**
+     * The start column number of the offending program text
+     */
+    private final int startcolumn;
+
+    /**
+     * The name of the file containing the offending program text
+     */
+    private final String file;
+
+    /**
+     * The actual error text produced by the language processor
+     */
+    private final String message;
+
+    /**
+     * The error message constructor.
+     *
+     * @param file The name of the file containing the offending program text
+     * @param startline The start line number of the offending program text
+     * @param startcolumn The start column number of the offending program text
+     * @param message The actual error text produced by the language processor
+     */
+    public CompilerError(final String file,
+                         final int startline,
+                         final int startcolumn,
+                         final String message) {
+        this.file = file;
+        this.startline = startline;
+        this.startcolumn = startcolumn;
+        this.message = message;
+    }
+
+    /**
+     * Return the filename associated with this compiler error.
+     *
+     * @return The filename associated with this compiler error
+     */
+    public String getFile() {
+        return file;
+    }
+
+    /**
+     * Return the starting line number of the program text originating this error
+     *
+     * @return The starting line number of the program text originating this error
+     */
+    public int getStartLine() {
+        return startline;
+    }
+
+    /**
+     * Return the starting column number of the program text originating this
+     * error
+     *
+     * @return The starting column number of the program text originating this
+     * error
+     */
+    public int getStartColumn() {
+        return startcolumn;
+    }
+
+    /**
+     * Return the message produced by the language processor
+     *
+     * @return The message produced by the language processor
+     */
+    public String getMessage() {
+        return message;
+    }
+}
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
new file mode 100644
index 0000000..18ce68e
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
@@ -0,0 +1,49 @@
+/*
+ * 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.sling.scripting.java.impl;
+
+import java.util.Dictionary;
+
+import org.apache.sling.commons.compiler.Options;
+
+public class CompilerOptions extends Options {
+
+    private String encoding;
+
+    /**
+     * Create an compiler options object using data available from
+     * the component configuration.
+     */
+    public static CompilerOptions createOptions(final Dictionary<String, Object> props) {
+        CompilerOptions opts = new CompilerOptions();
+
+        final Boolean classDebugInfo = (Boolean)props.get(JavaScriptEngineFactory.PROPERTY_CLASSDEBUGINFO);
+        opts.setGenerateDebugInfo(classDebugInfo != null ? classDebugInfo : true);
+
+        final String sourceVM = (String) props.get(JavaScriptEngineFactory.PROPERTY_COMPILER_SOURCE_V_M);
+        opts.setSourceVersion(sourceVM != null && sourceVM.length() > 0 ? sourceVM : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
+
+        final String encoding = (String) props.get(JavaScriptEngineFactory.PROPERTY_ENCODING);
+        opts.encoding = encoding != null && encoding.length() > 0 ? encoding : "UTF-8";
+
+        return opts;
+    }
+
+    public String getJavaEncoding() {
+        return this.encoding;
+    }
+}
diff --git a/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java
similarity index 86%
rename from src/main/java/org/apache/sling/scripting/java/CompilerUtil.java
rename to src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java
index f7d2805..3dd271f 100644
--- a/src/main/java/org/apache/sling/scripting/java/CompilerUtil.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 public class CompilerUtil {
 
@@ -38,27 +38,13 @@ public class CompilerUtil {
     }
 
     /**
-     * Create the class name from the source name
-     * @param sourcePath The source path
-     * @return The corresponding class file path.
-     */
-    public static String makeClassPath(String sourcePath) {
-        String str = sourcePath;
-        if (str.endsWith(".java")) {
-            str = str.substring(0, str.length() - 5);
-        }
-        return str;
-    }
-
-
-    /**
      * Converts the given identifier to a legal Java identifier
      *
      * @param identifier Identifier to convert
      *
      * @return Legal Java identifier corresponding to the given identifier
      */
-    public static final String makeJavaIdentifier(String identifier) {
+    private static final String makeJavaIdentifier(String identifier) {
         StringBuilder modifiedIdentifier =
             new StringBuilder(identifier.length());
         if (!Character.isJavaIdentifierStart(identifier.charAt(0))) {
@@ -83,7 +69,7 @@ public class CompilerUtil {
     /**
      * Mangle the specified character to create a legal Java class name.
      */
-    public static final String mangleChar(char ch) {
+    private static final String mangleChar(char ch) {
         char[] result = new char[5];
         result[0] = '_';
         result[1] = Character.forDigit((ch >> 12) & 0xf, 16);
@@ -108,7 +94,7 @@ public class CompilerUtil {
     /**
      * Test whether the argument is a Java keyword
      */
-    public static boolean isJavaKeyword(String key) {
+    private static boolean isJavaKeyword(String key) {
         int i = 0;
         int j = javaKeywords.length;
         while (i < j) {
diff --git a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
similarity index 77%
rename from src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
rename to src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
index d6f1f1a..81e167f 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 import static org.apache.sling.api.scripting.SlingBindings.SLING;
 
+import java.io.IOException;
 import java.io.Reader;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -28,9 +29,11 @@ import javax.script.ScriptEngine;
 import javax.script.ScriptException;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 
 import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingException;
+import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingIOException;
 import org.apache.sling.api.SlingServletException;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -40,14 +43,13 @@ import org.apache.sling.api.scripting.SlingScriptConstants;
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.commons.compiler.JavaCompiler;
 import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
 import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The Java engine
@@ -57,17 +59,22 @@ import org.slf4j.LoggerFactory;
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.service interface="javax.script.ScriptEngineFactory"
  *
- * @scr.property name="java.javaEncoding" value="UTF-8"
- * @scr.property name="java.compilerSourceVM" value="1.5"
- * @scr.property name="java.compilerTargetVM" value="1.5"
- * @scr.property name="java.classdebuginfo" value="true" type="Boolean"
+ * @scr.property nameRef="PROPERTY_COMPILER_SOURCE_V_M" valueRef="DEFAULT_VM_VERSION"
+ * @scr.property nameRef="PROPERTY_CLASSDEBUGINFO" value="true" type="Boolean"
+ * @scr.property nameRef="PROPERTY_ENCODING" value="UTF-8"
  */
 public class JavaScriptEngineFactory
     extends AbstractScriptEngineFactory
     implements EventHandler {
 
-    /** default logger */
-    private final Logger logger = LoggerFactory.getLogger(getClass());
+    public static final String PROPERTY_COMPILER_SOURCE_V_M = "java.compilerSourceVM";
+
+    public static final String PROPERTY_CLASSDEBUGINFO = "java.classdebuginfo";
+
+    public static final String PROPERTY_ENCODING = "java.javaEncoding";
+
+    /** Default source and target VM version (value is "1.5"). */
+    public static final String DEFAULT_VM_VERSION = "1.5";
 
     /**
      * @scr.reference
@@ -75,6 +82,11 @@ public class JavaScriptEngineFactory
     private DynamicClassLoaderManager dynamicClassLoaderManager;
 
     /**
+     * @scr.reference
+     */
+    private JavaCompiler javaCompiler;
+
+    /**
      * The class loader
      */
     private ClassLoader javaClassLoader;
@@ -91,11 +103,6 @@ public class JavaScriptEngineFactory
 
     private ServletConfig servletConfig;
 
-    private ServletCache servletCache;
-
-    /** Compiler options. */
-    private Options compilerOptions;
-
     private ServiceRegistration eventHandlerRegistration;
 
     public static final String SCRIPT_TYPE = "java";
@@ -132,17 +139,19 @@ public class JavaScriptEngineFactory
      * Activate this engine
      * @param componentContext
      */
+    @SuppressWarnings("unchecked")
     protected void activate(final ComponentContext componentContext) {
-        this.ioProvider = new SlingIOProvider(this.classLoaderWriter);
-        this.servletCache = new ServletCache();
-
+        this.ioProvider = new SlingIOProvider(this.classLoaderWriter,
+                                              this.javaCompiler,
+                                              this.javaClassLoader,
+                                              CompilerOptions.createOptions(componentContext.getProperties()));
         this.javaServletContext = new JavaServletContext(ioProvider,
             slingServletContext);
 
         this.servletConfig = new JavaServletConfig(javaServletContext,
             componentContext.getProperties());
-        this.compilerOptions = new Options(componentContext,
-                                           this.javaClassLoader);
+
+        // register event handler
         final Dictionary<String, String> props = new Hashtable<String, String>();
         props.put("event.topics","org/apache/sling/api/resource/*");
         props.put("service.description","Java Servlet Script Modification Handler");
@@ -150,9 +159,6 @@ public class JavaScriptEngineFactory
 
         this.eventHandlerRegistration = componentContext.getBundleContext()
                   .registerService(EventHandler.class.getName(), this, props);
-        if (logger.isDebugEnabled()) {
-            logger.debug("JavaServletScriptEngine.activate()");
-        }
     }
 
     /**
@@ -160,22 +166,16 @@ public class JavaScriptEngineFactory
      * @param componentContext
      */
     protected void deactivate(final ComponentContext componentContext) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("JavaServletScriptEngine.deactivate()");
-        }
-
         if ( this.eventHandlerRegistration != null ) {
             this.eventHandlerRegistration.unregister();
             this.eventHandlerRegistration = null;
         }
-        if ( this.servletCache != null ) {
-            this.servletCache.destroy();
-            this.servletCache = null;
+        if ( this.ioProvider != null ) {
+            this.ioProvider.destroy();
+            this.ioProvider = null;
         }
-        ioProvider = null;
         javaServletContext = null;
         servletConfig = null;
-        compilerOptions = null;
     }
 
     /**
@@ -189,19 +189,35 @@ public class JavaScriptEngineFactory
     private void callServlet(final Bindings bindings,
                              final SlingScriptHelper scriptHelper,
                              final ScriptContext context) {
+        // create a SlingBindings object
+        final SlingBindings slingBindings = new SlingBindings();
+        slingBindings.putAll(bindings);
+
         ResourceResolver resolver = (ResourceResolver) context.getAttribute(SlingScriptConstants.ATTR_SCRIPT_RESOURCE_RESOLVER,
                 SlingScriptConstants.SLING_SCOPE);
         if ( resolver == null ) {
             resolver = scriptHelper.getScript().getScriptResource().getResourceResolver();
         }
         ioProvider.setRequestResourceResolver(resolver);
+
+        final SlingHttpServletRequest request = slingBindings.getRequest();
+        final Object oldValue = request.getAttribute(SlingBindings.class.getName());
         try {
             final ServletWrapper servlet = getWrapperAdapter(scriptHelper);
-            // create a SlingBindings object
-            final SlingBindings slingBindings = new SlingBindings();
-            slingBindings.putAll(bindings);
-            servlet.service(slingBindings);
+
+            request.setAttribute(SlingBindings.class.getName(), bindings);
+            servlet.service(request, slingBindings.getResponse());
+        } catch (SlingException se) {
+            // rethrow as is
+            throw se;
+        } catch (IOException ioe) {
+            throw new SlingIOException(ioe);
+        } catch (ServletException se) {
+            throw new SlingServletException(se);
+        } catch (Exception ex) {
+            throw new SlingException(ex) {};
         } finally {
+            request.setAttribute(SlingBindings.class.getName(), oldValue);
             ioProvider.resetRequestResourceResolver();
         }
     }
@@ -211,20 +227,21 @@ public class JavaScriptEngineFactory
 
         SlingScript script = scriptHelper.getScript();
         final String scriptName = script.getScriptResource().getPath();
-        ServletWrapper wrapper = this.servletCache.getWrapper(scriptName);
+        ServletWrapper wrapper = this.ioProvider.getServletCache().getWrapper(scriptName);
         if (wrapper != null) {
             return wrapper;
         }
 
         synchronized (this) {
-            wrapper = this.servletCache.getWrapper(scriptName);
+            wrapper = this.ioProvider.getServletCache().getWrapper(scriptName);
             if (wrapper != null) {
                 return wrapper;
             }
 
             wrapper = new ServletWrapper(servletConfig,
-                    this.compilerOptions, ioProvider, scriptName, this.servletCache);
-            this.servletCache.addWrapper(scriptName, wrapper);
+                                         ioProvider,
+                                         scriptName);
+            this.ioProvider.getServletCache().addWrapper(scriptName, wrapper);
 
             return wrapper;
         }
@@ -280,9 +297,9 @@ public class JavaScriptEngineFactory
     }
 
     private void handleModification(final String scriptName) {
-        final ServletWrapper wrapper = this.servletCache.getWrapper(scriptName);
+        final ServletWrapper wrapper = this.ioProvider.getServletCache().getWrapper(scriptName);
         if ( wrapper != null ) {
-            wrapper.getCompilationContext().clearLastModificationTest();
+            wrapper.handleModification();
         }
     }
 
diff --git a/src/main/java/org/apache/sling/scripting/java/JavaServletConfig.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
similarity index 98%
rename from src/main/java/org/apache/sling/scripting/java/JavaServletConfig.java
rename to src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
index 48f305e..9949098 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaServletConfig.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 import java.util.Collections;
 import java.util.Dictionary;
diff --git a/src/main/java/org/apache/sling/scripting/java/JavaServletContext.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java
similarity index 99%
rename from src/main/java/org/apache/sling/scripting/java/JavaServletContext.java
rename to src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java
index 8b1969a..7f8a02d 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaServletContext.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 import java.io.InputStream;
 import java.net.MalformedURLException;
diff --git a/src/main/java/org/apache/sling/scripting/java/ServletCache.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java
similarity index 97%
rename from src/main/java/org/apache/sling/scripting/java/ServletCache.java
rename to src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java
index 9755621..02e01d5 100644
--- a/src/main/java/org/apache/sling/scripting/java/ServletCache.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 import java.util.Iterator;
 import java.util.Map;
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java
new file mode 100644
index 0000000..536f4c5
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java
@@ -0,0 +1,242 @@
+/*
+ * 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.sling.scripting.java.impl;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.SingleThreadModel;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.commons.compiler.CompileUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class wraps the java servlet and handles its compilation,
+ * instantiation, invocation und destruction.
+ */
+public class ServletWrapper {
+
+    /** The logger. */
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+
+    /** The servlet config. */
+    private final ServletConfig config;
+
+    /** Sling IO Provider. */
+    private final SlingIOProvider ioProvider;
+
+    /** The name of the generated class. */
+    private final String className;
+
+    /** The path to the servlet. */
+    private final String sourcePath;
+
+    private volatile long lastModificationTest = 0L;
+
+    private volatile Class<?> servletClass;
+
+    private volatile Servlet theServlet;
+
+    private long available = 0L;
+
+    private volatile Exception compileException;
+
+    /**
+     * A wrapper for servlets.
+     */
+    public ServletWrapper(final ServletConfig config,
+                          final SlingIOProvider ioProvider,
+                          final String servletPath) {
+        this.config = config;
+        this.ioProvider = ioProvider;
+        this.sourcePath = servletPath;
+        this.className = CompilerUtil.mapSourcePath(this.sourcePath).substring(1).replace('/', '.');
+    }
+
+    /**
+     * Get the servlet.
+     * @throws ServletException
+     * @throws IOException
+     * @throws FileNotFoundException
+     */
+    private void getServlet()
+    throws IllegalAccessException, InstantiationException, ClassNotFoundException, ServletException {
+        destroy();
+
+        this.servletClass = this.ioProvider.getClassLoader().loadClass(this.className);
+        final Servlet servlet = (Servlet) servletClass.newInstance();
+        servlet.init(config);
+
+        theServlet = servlet;
+    }
+
+    /**
+     * Call the servlet.
+     * @param request The current request.
+     * @param response The current response.
+     * @throws ServletException
+     * @throws IOException
+     */
+    public void service(HttpServletRequest request,
+                         HttpServletResponse response)
+    throws Exception {
+        try {
+            if ((available > 0L) && (available < Long.MAX_VALUE)) {
+                if (available > System.currentTimeMillis()) {
+                    response.setDateHeader("Retry-After", available);
+                    response.sendError
+                        (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
+                         "Servlet unavailable.");
+                    logger.error("Java servlet {} is unavailable.", this.sourcePath);
+                    return;
+                }
+                // Wait period has expired. Reset.
+                available = 0;
+            }
+
+            // check for compilation
+            if (this.lastModificationTest == 0 ) {
+                synchronized (this) {
+                    if (this.lastModificationTest == 0 ) {
+                        try {
+                            if ( this.compile() || this.theServlet == null ) {
+                                // clear exception
+                                this.compileException = null;
+                                // (re)load the servlet class
+                                getServlet();
+                            }
+                        } catch (Exception ex) {
+                            // store exception for futher access attempts
+                            this.compileException = ex;
+                            throw ex;
+                        } finally {
+                            this.lastModificationTest = System.currentTimeMillis();
+                        }
+                    } else if (compileException != null) {
+                        // Throw cached compilation exception
+                        throw compileException;
+                    }
+                }
+            } else if (compileException != null) {
+                // Throw cached compilation exception
+                throw compileException;
+            }
+
+            // invoke the servlet
+            if (theServlet instanceof SingleThreadModel) {
+                // sync on the wrapper so that the freshness
+                // of the page is determined right before servicing
+                synchronized (this) {
+                    theServlet.service(request, response);
+                }
+            } else {
+                theServlet.service(request, response);
+            }
+
+        } catch (UnavailableException ex) {
+            int unavailableSeconds = ex.getUnavailableSeconds();
+            if (unavailableSeconds <= 0) {
+                unavailableSeconds = 60;        // Arbitrary default
+            }
+            available = System.currentTimeMillis() +
+                (unavailableSeconds * 1000L);
+            response.sendError
+                (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
+                 ex.getMessage());
+            logger.error("Java servlet {} is unavailable.", this.sourcePath);
+            return;
+        }
+    }
+
+    /**
+     * Destroy the servlet.
+     */
+    public void destroy() {
+        if (theServlet != null) {
+            theServlet.destroy();
+            theServlet = null;
+        }
+    }
+
+    /** Handle the modification. */
+    public void handleModification() {
+        this.lastModificationTest = 0;
+    }
+
+    /**
+     * Check if the compiled class file is older than the source file
+     */
+    private boolean isOutDated() {
+        if ( this.lastModificationTest > 0 ) {
+            return false;
+        }
+        final long sourceLastModified = this.ioProvider.lastModified(this.sourcePath);
+
+        final long targetLastModified = this.ioProvider.lastModified('/' + this.className.replace('.', '/') + ".class");
+        if (targetLastModified < 0) {
+            return true;
+        }
+
+        return targetLastModified < sourceLastModified;
+    }
+
+    private boolean compile() throws Exception {
+        if (this.isOutDated()) {
+            final CompilationUnit unit = new CompilationUnit(this.sourcePath, className, ioProvider);
+            this.ioProvider.getCompiler().compile(new CompileUnit[] {unit}, unit, unit, unit, ioProvider.getOptions());
+
+            final List<CompilerError> errors = unit.getErrors();
+            if ( errors != null && errors.size() > 0 ) {
+                throw CompilerException.create(errors);
+            }
+            return true;
+        }
+        return false;
+    }
+
+    protected final static class CompilerException extends ServletException {
+
+        public static CompilerException create(List<CompilerError> errors) {
+            final StringBuilder buffer = new StringBuilder();
+            buffer.append("Compilation errors:\n");
+            for(final CompilerError e : errors) {
+                buffer.append(e.getFile());
+                buffer.append(", line ");
+                buffer.append(e.getStartLine());
+                buffer.append(", column ");
+                buffer.append(e.getStartColumn());
+                buffer.append(" : " );
+                buffer.append(e.getMessage());
+                buffer.append("\n");
+            }
+            return new CompilerException(buffer.toString());
+        }
+
+        public CompilerException(final String message) {
+           super(message);
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/scripting/java/SlingIOProvider.java b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
similarity index 66%
rename from src/main/java/org/apache/sling/scripting/java/SlingIOProvider.java
rename to src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
index 4e07e44..836ac2e 100644
--- a/src/main/java/org/apache/sling/scripting/java/SlingIOProvider.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.scripting.java;
+package org.apache.sling.scripting.java.impl;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -31,6 +31,7 @@ import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
+import org.apache.sling.commons.compiler.JavaCompiler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -39,16 +40,43 @@ import org.slf4j.LoggerFactory;
  */
 public class SlingIOProvider  {
 
-    /** default log */
-    private final Logger log = LoggerFactory.getLogger(SlingIOProvider.class);
+    /** Default logger */
+    private final Logger logger = LoggerFactory.getLogger(SlingIOProvider.class);
 
     private ThreadLocal<ResourceResolver> requestResourceResolver;
 
     private final ClassLoaderWriter classLoaderWriter;
 
-    SlingIOProvider(final ClassLoaderWriter classLoaderWriter) {
+    private final JavaCompiler compiler;
+
+    private final CompilerOptions options;
+
+    /**
+     * Classloader
+     */
+    private final ClassLoader classLoader;
+
+    /**
+     * Servlet cache.
+     */
+    private final ServletCache servletCache = new ServletCache();
+
+    /**
+     * Constructor.
+     */
+    SlingIOProvider(final ClassLoaderWriter classLoaderWriter,
+                    final JavaCompiler compiler,
+                    final ClassLoader classLoader,
+                    final CompilerOptions options) {
         this.requestResourceResolver = new ThreadLocal<ResourceResolver>();
         this.classLoaderWriter = classLoaderWriter;
+        this.compiler = compiler;
+        this.classLoader = classLoader;
+        this.options = options;
+    }
+
+    void destroy() {
+        this.servletCache.destroy();
     }
 
     void setRequestResourceResolver(ResourceResolver resolver) {
@@ -61,6 +89,22 @@ public class SlingIOProvider  {
 
     // ---------- IOProvider interface -----------------------------------------
 
+    public JavaCompiler getCompiler() {
+        return this.compiler;
+    }
+
+    public ClassLoader getClassLoader() {
+        return this.classLoader;
+    }
+
+    public CompilerOptions getOptions() {
+        return this.options;
+    }
+
+    public ServletCache getServletCache() {
+        return this.servletCache;
+    }
+
     /**
      * Returns an InputStream for the file name which is looked up with the
      * ResourceProvider and retrieved from the Resource if the StreamProvider
@@ -68,11 +112,7 @@ public class SlingIOProvider  {
      */
     public InputStream getInputStream(String fileName)
     throws FileNotFoundException, IOException {
-        if ( fileName.startsWith(":") ) {
-            return this.classLoaderWriter.getInputStream(fileName.substring(1));
-        }
         try {
-
             Resource resource = getResourceInternal(fileName);
             if (resource == null) {
                 throw new FileNotFoundException("Cannot find " + fileName);
@@ -98,8 +138,8 @@ public class SlingIOProvider  {
      * returned.
      */
     public long lastModified(String fileName) {
-        if ( fileName.startsWith(":") ) {
-            return this.classLoaderWriter.getLastModified(fileName.substring(1));
+        if ( fileName.endsWith(".class") ) {
+            return this.classLoaderWriter.getLastModified(fileName);
         }
         try {
             Resource resource = getResourceInternal(fileName);
@@ -110,7 +150,7 @@ public class SlingIOProvider  {
             }
 
         } catch (SlingException se) {
-            log.error("Cannot get last modification time for " + fileName, se);
+            logger.error("Cannot get last modification time for " + fileName, se);
         }
 
         // fallback to "non-existant" in case of problems
@@ -121,36 +161,31 @@ public class SlingIOProvider  {
      * Returns an output stream to write to the repository.
      */
     public OutputStream getOutputStream(String fileName) {
-        return this.classLoaderWriter.getOutputStream(fileName.substring(1));
+        return this.classLoaderWriter.getOutputStream(fileName);
     }
 
-    /* package */URL getURL(String path) throws MalformedURLException {
+    public URL getURL(String path) throws MalformedURLException {
         try {
-            Resource resource = getResourceInternal(path);
-            return (resource != null) ? resource.adaptTo(URL.class) : null;
+            final Resource resource = getResourceInternal(path);
+            return resource != null ? resource.adaptTo(URL.class) : null;
         } catch (SlingException se) {
             throw (MalformedURLException) new MalformedURLException(
                 "Cannot get URL for " + path).initCause(se);
         }
     }
 
-    /* package */Set<String> getResourcePaths(String path) {
-        Set<String> paths = new HashSet<String>();
-
-        ResourceResolver resolver = requestResourceResolver.get();
-        if (resolver != null) {
-            try {
-                Resource resource = resolver.getResource(cleanPath(path));
-                if (resource != null) {
-                    Iterator<Resource> entries = resolver.listChildren(resource);
-                    while (entries.hasNext()) {
-                        paths.add(entries.next().getPath());
-                    }
+    public Set<String> getResourcePaths(final String path) {
+        final Set<String> paths = new HashSet<String>();
+        try {
+            final Resource resource = getResourceInternal(path);
+            if (resource != null) {
+                final Iterator<Resource> entries = resource.getResourceResolver().listChildren(resource);
+                while (entries.hasNext()) {
+                    paths.add(entries.next().getPath());
                 }
-            } catch (SlingException se) {
-                log.warn("getResourcePaths: Cannot list children of " + path,
-                    se);
             }
+        } catch (SlingException se) {
+            logger.warn("Unable to get resource at path " + path, se);
         }
 
         return paths.isEmpty() ? null : paths;
@@ -159,23 +194,10 @@ public class SlingIOProvider  {
     private Resource getResourceInternal(String path) throws SlingException {
         ResourceResolver resolver = requestResourceResolver.get();
         if (resolver != null) {
-            return resolver.getResource(cleanPath(path));
+            return resolver.getResource(path);
         }
 
         return null;
     }
 
-    // ---------- internal -----------------------------------------------------
-
-    private String cleanPath(String path) {
-        // replace backslash by slash
-        path = path.replace('\\', '/');
-
-        // cut off trailing slash
-        while (path.endsWith("/")) {
-            path = path.substring(0, path.length() - 1);
-        }
-
-        return path;
-    }
 }
diff --git a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
deleted file mode 100644
index cbcae2c..0000000
--- a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * 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.sling.scripting.java.jdt;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.apache.sling.scripting.java.CompilerError;
-import org.apache.sling.scripting.java.Options;
-import org.apache.sling.scripting.java.SlingIOProvider;
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.CompilationResult;
-import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
-import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-
-
-public class CompilationUnit
-    implements ICompilationUnit, INameEnvironment, ICompilerRequestor {
-
-    private final Options options;
-    private final SlingIOProvider ioProvider;
-    private final String className;
-    private final String sourceFile;
-
-    /** The list of compile errors. */
-    private final List<CompilerError> errors = new LinkedList<CompilerError>();
-
-    public CompilationUnit(String sourceFile,
-                           String className,
-                           Options options,
-                           SlingIOProvider ioProvider) {
-        this.className = className;
-        this.sourceFile = sourceFile;
-        this.ioProvider = ioProvider;
-        this.options = options;
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.IDependent#getFileName()
-     */
-    public char[] getFileName() {
-        int slash = sourceFile.lastIndexOf('/');
-        if (slash > 0) {
-            return sourceFile.substring(slash + 1).toCharArray();
-        }
-        return sourceFile.toCharArray();
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getContents()
-     */
-    public char[] getContents() {
-        char[] result = null;
-        InputStream fr = null;
-        try {
-            fr = ioProvider.getInputStream(this.sourceFile);
-            final Reader reader = new BufferedReader(new InputStreamReader(fr, this.options.getJavaEncoding()));
-            try {
-                char[] chars = new char[8192];
-                StringBuilder buf = new StringBuilder();
-                int count;
-                while ((count = reader.read(chars, 0, chars.length)) > 0) {
-                    buf.append(chars, 0, count);
-                }
-                result = new char[buf.length()];
-                buf.getChars(0, result.length, result, 0);
-            } finally {
-                reader.close();
-            }
-        } catch (IOException e) {
-            handleError(-1, -1, e.getMessage());
-        }
-        return result;
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getMainTypeName()
-     */
-    public char[] getMainTypeName() {
-        int dot = className.lastIndexOf('.');
-        if (dot > 0) {
-            return className.substring(dot + 1).toCharArray();
-        }
-        return className.toCharArray();
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName()
-     */
-    public char[][] getPackageName() {
-        StringTokenizer izer = new StringTokenizer(className.replace('/', '.'), ".");
-        char[][] result = new char[izer.countTokens()-1][];
-        for (int i = 0; i < result.length; i++) {
-            String tok = izer.nextToken();
-            result[i] = tok.toCharArray();
-        }
-        return result;
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[][])
-     */
-    public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
-        StringBuilder result = new StringBuilder();
-        for (int i = 0; i < compoundTypeName.length; i++) {
-            if (i > 0) {
-                result.append(".");
-            }
-            result.append(compoundTypeName[i]);
-        }
-        return findType(result.toString());
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[], char[][])
-     */
-    public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
-        StringBuilder result = new StringBuilder();
-        for (int i = 0; i < packageName.length; i++) {
-            if (i > 0) {
-                result.append(".");
-            }
-            result.append(packageName[i]);
-        }
-        result.append(".");
-        result.append(typeName);
-        return findType(result.toString());
-    }
-
-    /**
-     * @param className
-     * @return
-     */
-    private NameEnvironmentAnswer findType(String className) {
-        try {
-            if (className.equals(this.className)) {
-                ICompilationUnit compilationUnit = this;
-                return new NameEnvironmentAnswer(compilationUnit, null);
-            }
-            String resourceName = className.replace('.', '/') + ".class";
-            InputStream is = options.getClassLoader().getResourceAsStream(resourceName);
-            if (is != null) {
-                byte[] classBytes;
-                byte[] buf = new byte[8192];
-                ByteArrayOutputStream baos =
-                    new ByteArrayOutputStream(buf.length);
-                int count;
-                while ((count = is.read(buf, 0, buf.length)) > 0) {
-                    baos.write(buf, 0, count);
-                }
-                baos.flush();
-                classBytes = baos.toByteArray();
-                char[] fileName = className.toCharArray();
-                ClassFileReader classFileReader =
-                    new ClassFileReader(classBytes, fileName,
-                                        true);
-                return
-                    new NameEnvironmentAnswer(classFileReader, null);
-            }
-        } catch (IOException exc) {
-            handleError(-1, -1, exc.getMessage());
-        } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException exc) {
-            handleError(-1, -1, exc.getMessage());
-        }
-        return null;
-    }
-
-    private boolean isPackage(String result) {
-        if (result.equals(this.className)) {
-            return false;
-        }
-        String resourceName = result.replace('.', '/') + ".class";
-        if ( resourceName.startsWith("/") ) {
-            resourceName = resourceName.substring(1);
-        }
-        final InputStream is = options.getClassLoader().getResourceAsStream(resourceName);
-        if ( is != null ) {
-            try {
-                is.close();
-            } catch (IOException ignore) {}
-        }
-        return is == null;
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#isPackage(char[][], char[])
-     */
-    public boolean isPackage(char[][] parentPackageName, char[] packageName) {
-        if (Character.isUpperCase(packageName[0])) {
-            return false;
-        }
-        final StringBuilder builder = new StringBuilder();
-        if (parentPackageName != null) {
-            for (int i = 0; i < parentPackageName.length; i++) {
-                if (i > 0) {
-                    builder.append(".");
-                }
-                builder.append(parentPackageName[i]);
-            }
-        }
-        if (!isPackage(builder.toString())) {
-            return false;
-        }
-        builder.append(".");
-        builder.append(packageName);
-
-        return isPackage(builder.toString());
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#cleanup()
-     */
-    public void cleanup() {
-        // EMPTY
-    }
-
-    /**
-     * @see org.eclipse.jdt.internal.compiler.ICompilerRequestor#acceptResult(org.eclipse.jdt.internal.compiler.CompilationResult)
-     */
-    public void acceptResult(CompilationResult result) {
-        try {
-            if (result.hasErrors()) {
-                IProblem[] errors = result.getErrors();
-                for (int i = 0; i < errors.length; i++) {
-                    IProblem error = errors[i];
-                    handleError(error.getSourceLineNumber(), -1, error.getMessage());
-                }
-            } else {
-                ClassFile[] classFiles = result.getClassFiles();
-                for (int i = 0; i < classFiles.length; i++) {
-                    ClassFile classFile = classFiles[i];
-                    char[][] compoundName = classFile.getCompoundName();
-                    StringBuilder className = new StringBuilder();
-                    for (int j = 0;  j < compoundName.length; j++) {
-                        if (j > 0) {
-                            className.append(".");
-                        }
-                        className.append(compoundName[j]);
-                    }
-                    byte[] bytes = classFile.getBytes();
-                    final StringBuilder b = new StringBuilder(this.options.getDestinationPath());
-                    b.append('/');
-                    b.append(className.toString().replace('.', '/'));
-                    b.append(".class");
-                    OutputStream fout = ioProvider.getOutputStream(b.toString());
-                    BufferedOutputStream bos = new BufferedOutputStream(fout);
-                    bos.write(bytes);
-                    bos.close();
-                }
-            }
-        } catch (IOException exc) {
-            handleError(-1, -1, exc.getLocalizedMessage());
-        }
-    }
-
-    private void handleError(int line, int column, Object errorMessage) {
-        if (column < 0) {
-            column = 0;
-        }
-        errors.add(new CompilerError(this.sourceFile,
-                                     true,
-                                     line,
-                                     column,
-                                     line,
-                                     column,
-                                     errorMessage.toString()));
-    }
-
-    public List<CompilerError> getErrors() throws IOException {
-        return errors;
-    }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/jdt/EclipseJavaCompiler.java b/src/main/java/org/apache/sling/scripting/java/jdt/EclipseJavaCompiler.java
deleted file mode 100644
index 8ed73af..0000000
--- a/src/main/java/org/apache/sling/scripting/java/jdt/EclipseJavaCompiler.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.sling.scripting.java.jdt;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.sling.scripting.java.CompilationContext;
-import org.apache.sling.scripting.java.CompilerError;
-import org.apache.sling.scripting.java.Options;
-import org.apache.sling.scripting.java.SlingIOProvider;
-import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
-import org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-
-/**
- * Eclipse Java Compiler
- *
- * @version $Id$
- */
-public class EclipseJavaCompiler {
-
-    /** The io provider. */
-    private final SlingIOProvider ioProvider;
-
-    /** The compiler options. */
-    private final Options compilerOptions;
-
-    /** The compilation context. */
-    private final CompilationContext context;
-
-    /**
-     * Construct a new java compiler.
-     * @param context
-     */
-    public EclipseJavaCompiler(final CompilationContext context) {
-        this.ioProvider = context.getIOProvider();
-        this.compilerOptions = context.getCompilerOptions();
-        this.context = context;
-    }
-
-    private CompilerOptions getCompilerOptions() {
-        CompilerOptions options = new CompilerOptions();
-        final Map<String, String> settings = new HashMap<String, String>();
-        settings.put(CompilerOptions.OPTION_LineNumberAttribute,
-                CompilerOptions.GENERATE);
-        settings.put(CompilerOptions.OPTION_SourceFileAttribute,
-                CompilerOptions.GENERATE);
-        settings.put(CompilerOptions.OPTION_ReportDeprecation,
-                CompilerOptions.IGNORE);
-        settings.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE);
-        settings.put(CompilerOptions.OPTION_Encoding, this.compilerOptions.getJavaEncoding());
-        if (this.compilerOptions.getClassDebugInfo()) {
-            settings.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
-        }
-        if ( this.compilerOptions.getCompilerSourceVM().equals("1.6") ) {
-            settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
-        } else {
-            settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
-        }
-        if ( this.compilerOptions.getCompilerTargetVM().equals("1.6") ) {
-            settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
-            settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
-        } else {
-            settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
-            settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
-        }
-
-        options.set(settings);
-        return options;
-    }
-
-    /**
-     * Compile the java class.
-     * @return null if no error occured, a list of errors otherwise.
-     * @throws IOException
-     */
-    public List<CompilerError> compile() throws IOException {
-        final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems();
-        final IProblemFactory problemFactory = new DefaultProblemFactory(Locale.getDefault());
-        final CompilationUnit unit = new CompilationUnit(this.context.getSourcePath(),
-                 this.context.getJavaClassName(),
-                 this.context.getCompilerOptions(),
-                 this.ioProvider);
-
-        final Compiler compiler = new Compiler(unit,
-                                         policy,
-                                         getCompilerOptions(),
-                                         unit,
-                                         problemFactory);
-        compiler.compile(new CompilationUnit[] {unit});
-        if ( unit.getErrors().size() == 0 ) {
-            return null;
-        }
-        return unit.getErrors();
-    }
-
-}
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
index 4b1c970..2cce499 100644
--- a/src/main/resources/META-INF/NOTICE
+++ b/src/main/resources/META-INF/NOTICE
@@ -1,5 +1,5 @@
 Apache Sling Java Scripting Support
-Copyright 2008-2009 The Apache Software Foundation
+Copyright 2008-2010 The Apache Software Foundation
 
 Apache Sling is based on source code originally developed 
 by Day Software (http://www.day.com/).
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index dad70ff..8b87cf2 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -37,7 +37,3 @@ java.javaEncoding.description = Encoding to be used to read the source files. \
 java.compilerSourceVM.name = Source VM
 java.compilerSourceVM.description = Java Specification to be used to read \
  the source files.
-
-java.compilerTargetVM.name = Target VM
-java.compilerTargetVM.description = Java Specification to be used to generate \
- the compiled output.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 15/16: [maven-release-plugin] prepare release org.apache.sling.scripting.java-2.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit f7373f5df5011d83398184a1404d34892c5399f5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 10:33:08 2010 +0000

    [maven-release-plugin] prepare release org.apache.sling.scripting.java-2.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@1049890 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 7bd64f4..ac7c8cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.scripting.java</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>2.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Scripting Java Support</name>
     <description>Support for scripting Java</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.scripting.java-2.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.scripting.java-2.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.scripting.java-2.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 07/16: SLING-1385 : Recompile java scripts on modification and avoid periodic checks

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit bfc4376767c22c779d16078f9ad8369a1ac02308
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Feb 17 15:31:27 2010 +0000

    SLING-1385 : Recompile java scripts on modification and avoid periodic checks
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@911018 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/scripting/java/CompilationContext.java   | 20 ++++---
 .../scripting/java/JavaScriptEngineFactory.java    | 66 +++++++++++++++++-----
 .../org/apache/sling/scripting/java/Options.java   | 32 -----------
 .../sling/scripting/java/ServletWrapper.java       | 10 ++--
 .../OSGI-INF/metatype/metatype.properties          | 10 ----
 5 files changed, 68 insertions(+), 70 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
index ebf646c..764d95b 100644
--- a/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
+++ b/src/main/java/org/apache/sling/scripting/java/CompilationContext.java
@@ -52,7 +52,7 @@ public class CompilationContext {
 
     private ServletCache servletCache;
 
-    private long lastModificationTest = 0L;
+    private volatile long lastModificationTest = 0L;
     private int removed = 0;
 
     private Class<?> servletClass;
@@ -131,18 +131,22 @@ public class CompilationContext {
         return false;
     }
 
+    public long getLastModificationTest() {
+        return this.lastModificationTest;
+    }
+
+    public void setLastModificationTest(final long value) {
+        this.lastModificationTest = value;
+    }
+
     /**
      * Check if the compiled class file is older than the source file
      */
     public boolean isOutDated() {
-        if (this.options.getModificationTestInterval() > 0) {
-
-            if (this.lastModificationTest
-                + (this.options.getModificationTestInterval() * 1000) > System.currentTimeMillis()) {
-                return false;
-            }
-            this.lastModificationTest = System.currentTimeMillis();
+        if ( this.lastModificationTest > 0 ) {
+            return false;
         }
+        this.lastModificationTest = System.currentTimeMillis();
 
         final long sourceLastModified = this.ioProvider.lastModified(getSourcePath());
 
diff --git a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
index 605c0ca..2e1e4a6 100644
--- a/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/JavaScriptEngineFactory.java
@@ -19,6 +19,8 @@ package org.apache.sling.scripting.java;
 import static org.apache.sling.api.scripting.SlingBindings.SLING;
 
 import java.io.Reader;
+import java.util.Dictionary;
+import java.util.Hashtable;
 
 import javax.script.Bindings;
 import javax.script.ScriptContext;
@@ -27,6 +29,7 @@ import javax.script.ScriptException;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 
+import org.apache.sling.api.SlingConstants;
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingIOException;
 import org.apache.sling.api.SlingServletException;
@@ -39,7 +42,10 @@ import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
 import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,19 +55,19 @@ import org.slf4j.LoggerFactory;
  * @scr.component label="%javahandler.name" description="%javahandler.description"
  * @scr.property name="service.description" value="Java Servlet Script Handler"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.service
+ * @scr.service interface="javax.script.ScriptEngineFactory"
  *
  * @scr.property name="java.javaEncoding" value="UTF-8"
  * @scr.property name="java.compilerSourceVM" value="1.5"
  * @scr.property name="java.compilerTargetVM" value="1.5"
- * @scr.property name="java.development" value="true" type="Boolean"
- * @scr.property name="java.modificationTestInterval" value="-1"
  * @scr.property name="java.classdebuginfo" value="true" type="Boolean"
  */
-public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
+public class JavaScriptEngineFactory
+    extends AbstractScriptEngineFactory
+    implements EventHandler {
 
     /** default logger */
-    private final Logger log = LoggerFactory.getLogger(getClass());
+    private final Logger logger = LoggerFactory.getLogger(getClass());
 
     /**
      * @scr.reference
@@ -90,6 +96,8 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
     /** Compiler options. */
     private Options compilerOptions;
 
+    private ServiceRegistration eventHandlerRegistration;
+
     public static final String SCRIPT_TYPE = "java";
 
     /**
@@ -124,7 +132,7 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
      * Activate this engine
      * @param componentContext
      */
-    protected void activate(ComponentContext componentContext) {
+    protected void activate(final ComponentContext componentContext) {
         this.ioProvider = new SlingIOProvider(this.classLoaderWriter);
         this.servletCache = new ServletCache();
 
@@ -135,20 +143,31 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
             componentContext.getProperties());
         this.compilerOptions = new Options(componentContext,
                                            this.javaClassLoader);
-        if (log.isDebugEnabled()) {
-            log.debug("JavaServletScriptEngine.activate()");
+        final Dictionary<String, String> props = new Hashtable<String, String>();
+        props.put("event.topics","org/apache/sling/api/resource/*");
+        props.put("service.description","Java Servlet Script Modification Handler");
+        props.put("service.vendor","The Apache Software Foundation");
+
+        this.eventHandlerRegistration = componentContext.getBundleContext()
+                  .registerService(EventHandler.class.getName(), this, props);
+        if (logger.isDebugEnabled()) {
+            logger.debug("JavaServletScriptEngine.activate()");
         }
     }
 
     /**
      * Deactivate this engine
-     * @param oldComponentContext
+     * @param componentContext
      */
-    protected void deactivate(ComponentContext oldComponentContext) {
-        if (log.isDebugEnabled()) {
-            log.debug("JavaServletScriptEngine.deactivate()");
+    protected void deactivate(final ComponentContext componentContext) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("JavaServletScriptEngine.deactivate()");
         }
 
+        if ( this.eventHandlerRegistration != null ) {
+            this.eventHandlerRegistration.unregister();
+            this.eventHandlerRegistration = null;
+        }
         ioProvider = null;
         javaServletContext = null;
         servletConfig = null;
@@ -164,7 +183,6 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
      * @throws SlingServletException
      * @throws SlingIOException
      */
-    @SuppressWarnings("unchecked")
     private void callServlet(final Bindings bindings,
                              final SlingScriptHelper scriptHelper,
                              final ScriptContext context) {
@@ -185,8 +203,8 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
         }
     }
 
-    private ServletWrapper getWrapperAdapter(
-            SlingScriptHelper scriptHelper) throws SlingException {
+    private ServletWrapper getWrapperAdapter(final SlingScriptHelper scriptHelper)
+    throws SlingException {
 
         SlingScript script = scriptHelper.getScript();
         final String scriptName = script.getScriptResource().getPath();
@@ -247,6 +265,24 @@ public class JavaScriptEngineFactory extends AbstractScriptEngineFactory {
     }
     // ---------- Internal -----------------------------------------------------
 
+    /**
+     * @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
+     */
+    public void handleEvent(Event event) {
+        if ( SlingConstants.TOPIC_RESOURCE_CHANGED.equals(event.getTopic()) ) {
+            this.handleModification((String)event.getProperty(SlingConstants.PROPERTY_PATH));
+        } else if ( SlingConstants.TOPIC_RESOURCE_REMOVED.equals(event.getTopic()) ) {
+            this.handleModification((String)event.getProperty(SlingConstants.PROPERTY_PATH));
+        }
+    }
+
+    private void handleModification(final String scriptName) {
+        final ServletWrapper wrapper = this.servletCache.getWrapper(scriptName);
+        if ( wrapper != null ) {
+            wrapper.getCompilationContext().setLastModificationTest(0);
+        }
+    }
+
     private static class JavaScriptEngine extends AbstractSlingScriptEngine {
 
         JavaScriptEngine(JavaScriptEngineFactory factory) {
diff --git a/src/main/java/org/apache/sling/scripting/java/Options.java b/src/main/java/org/apache/sling/scripting/java/Options.java
index 375c348..4dea523 100644
--- a/src/main/java/org/apache/sling/scripting/java/Options.java
+++ b/src/main/java/org/apache/sling/scripting/java/Options.java
@@ -34,21 +34,12 @@ public class Options {
 
     private static final String PROPERTY_COMPILER_TARGET_V_M = "compilerTargetVM";
 
-    private static final String PROPERTY_DEVELOPMENT = "development";
-
-    private static final String PROPERTY_MODIFICATION_TEST_INTERVAL = "modificationTestInterval";
-
     private static final String PROPERTY_CLASSDEBUGINFO = "classdebuginfo";
 
     /** Default source and target VM version (value is "1.5"). */
     private static final String DEFAULT_VM_VERSION = "1.5";
 
     /**
-     * Is the engine being used in development mode?
-     */
-    private final boolean development;
-
-    /**
      * Do we want to include debugging information in the class file?
      */
     private final boolean classDebugInfo;
@@ -69,11 +60,6 @@ public class Options {
     private final String javaEncoding;
 
     /**
-     * Modification test interval.
-     */
-    private final int modificationTestInterval;
-
-    /**
      * Classloader
      */
     private final ClassLoader classLoader;
@@ -91,8 +77,6 @@ public class Options {
         final Properties properties = new Properties();
         // set default values first
         properties.put(PROPERTY_CLASSDEBUGINFO, "true");
-        properties.put(PROPERTY_DEVELOPMENT, "true");
-        properties.put(PROPERTY_MODIFICATION_TEST_INTERVAL, "-1");
         properties.put(PROPERTY_COMPILER_TARGET_V_M, DEFAULT_VM_VERSION);
         properties.put(PROPERTY_COMPILER_SOURCE_V_M, DEFAULT_VM_VERSION);
         properties.put(PROPERTY_JAVA_ENCODING, "UTF-8");
@@ -112,8 +96,6 @@ public class Options {
         }
 
         this.classDebugInfo = Boolean.valueOf(properties.get(PROPERTY_CLASSDEBUGINFO).toString());
-        this.modificationTestInterval = Integer.valueOf(properties.get(PROPERTY_MODIFICATION_TEST_INTERVAL).toString());
-        this.development = Boolean.valueOf(properties.get(PROPERTY_DEVELOPMENT).toString());
         this.compilerTargetVM = properties.get(PROPERTY_COMPILER_TARGET_V_M).toString();
         this.compilerSourceVM = properties.get(PROPERTY_COMPILER_SOURCE_V_M).toString();
         this.javaEncoding = properties.get(PROPERTY_JAVA_ENCODING).toString();
@@ -133,20 +115,6 @@ public class Options {
         return this.classDebugInfo;
     }
 
-    /**
-     * Modification test interval.
-     */
-    public int getModificationTestInterval() {
-        return this.modificationTestInterval;
-    }
-
-    /**
-     * Is the engine being used in development mode?
-     */
-    public boolean getDevelopment() {
-        return this.development;
-    }
-
     public ClassLoader getClassLoader() {
         return this.classLoader;
     }
diff --git a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
index 4d948f5..481d832 100644
--- a/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
+++ b/src/main/java/org/apache/sling/scripting/java/ServletWrapper.java
@@ -53,9 +53,6 @@ public class ServletWrapper {
     /** Reload flag. */
     private boolean reload = true;
 
-    /** Compiler options. */
-    private final Options options;
-
     private Servlet theServlet;
     private long available = 0L;
     private boolean firstTime = true;
@@ -72,7 +69,6 @@ public class ServletWrapper {
                           final ServletCache servletCache) {
         this.config = config;
         this.servletUri = servletPath;
-        this.options = options;
         this.ctxt = new CompilationContext(servletUri, options,
                 ioProvider, servletCache, this);
     }
@@ -85,6 +81,10 @@ public class ServletWrapper {
         this.reload = reload;
     }
 
+    public CompilationContext getCompilationContext() {
+        return this.ctxt;
+    }
+
     /**
      * Get the servlet.
      * @return The servlet.
@@ -189,7 +189,7 @@ public class ServletWrapper {
             /*
              * (1) Compile
              */
-            if (options.getDevelopment() || firstTime ) {
+            if (firstTime || ctxt.getLastModificationTest() == 0 ) {
                 synchronized (this) {
                     firstTime = false;
 
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index c6e2467..dad70ff 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -30,16 +30,6 @@ java.classdebuginfo.name = Generate Debug Info
 java.classdebuginfo.description = Should the class file be compiled with \
  debugging information? true or false, default true.
  
-java.modificationTestInterval.name = Modification Check Interval
-java.modificationTestInterval.description = Checks for modification for a \
- given Java file will be performed only once every \
- specified amount of seconds. Setting this to -1 will cause the source to be checked \
- on every access. Default is -1.
-
-java.development.name = Development Mode
-java.development.description = Is scripting used in development mode (will check \
- for modification on every access)? true or false, default true.
- 
 java.javaEncoding.name = Source Encoding
 java.javaEncoding.description = Encoding to be used to read the source files. \
  This defaults to UTF-8 and should only be changed in very specific circumstances.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 06/16: Code cleanup

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 6b0aef2d74615ca51a044415c29ff84e5eb8d13a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 18 21:13:47 2010 +0000

    Code cleanup
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@900561 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/scripting/java/jdt/CompilationUnit.java   | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
index e491699..cbcae2c 100644
--- a/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
+++ b/src/main/java/org/apache/sling/scripting/java/jdt/CompilationUnit.java
@@ -213,22 +213,25 @@ public class CompilationUnit
      * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#isPackage(char[][], char[])
      */
     public boolean isPackage(char[][] parentPackageName, char[] packageName) {
-        StringBuilder result = new StringBuilder();
+        if (Character.isUpperCase(packageName[0])) {
+            return false;
+        }
+        final StringBuilder builder = new StringBuilder();
         if (parentPackageName != null) {
             for (int i = 0; i < parentPackageName.length; i++) {
                 if (i > 0) {
-                    result.append(".");
+                    builder.append(".");
                 }
-                result.append(parentPackageName[i]);
+                builder.append(parentPackageName[i]);
             }
         }
-        String str = new String(packageName);
-        if (Character.isUpperCase(str.charAt(0)) && !isPackage(result.toString())) {
-                return false;
+        if (!isPackage(builder.toString())) {
+            return false;
         }
-        result.append(".");
-        result.append(str);
-        return isPackage(result.toString());
+        builder.append(".");
+        builder.append(packageName);
+
+        return isPackage(builder.toString());
     }
 
     /**

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 11/16: SLING-874 : Use new commons compiler for java servlet scripting

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 12aeb71addd6361560ae68b0feb472bd5a86b71b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Mar 24 08:12:53 2010 +0000

    SLING-874 : Use new commons compiler for java servlet scripting
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@926970 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |   8 +-
 .../sling/scripting/java/impl/CompilationUnit.java | 143 +++------------------
 .../sling/scripting/java/impl/CompilerError.java   | 100 --------------
 .../sling/scripting/java/impl/CompilerOptions.java |   6 +-
 .../java/impl/JavaScriptEngineFactory.java         |  57 +-------
 .../sling/scripting/java/impl/ServletWrapper.java  |  74 ++++-------
 .../sling/scripting/java/impl/SlingIOProvider.java |  39 +-----
 7 files changed, 50 insertions(+), 377 deletions(-)

diff --git a/pom.xml b/pom.xml
index db84dac..12fb9a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,17 +90,11 @@
             <version>2.0.2-incubator</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.classloader</artifactId>
-            <version>1.0.0</version>
-            <scope>provided</scope>
-        </dependency>
 
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.compiler</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
index 86660af..81d386f 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java
@@ -16,165 +16,54 @@
  */
 package org.apache.sling.scripting.java.impl;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sling.commons.compiler.ClassWriter;
-import org.apache.sling.commons.compiler.CompileUnit;
-import org.apache.sling.commons.compiler.CompilerEnvironment;
-import org.apache.sling.commons.compiler.ErrorHandler;
 
 
 public class CompilationUnit
-    implements CompileUnit, CompilerEnvironment, ErrorHandler, ClassWriter {
+    implements org.apache.sling.commons.compiler.CompilationUnit {
 
     private final SlingIOProvider ioProvider;
     private final String className;
     private final String sourceFile;
 
-    /** The list of compile errors - this is created lazily. */
-    private List<CompilerError> errors;
-
-    public CompilationUnit(String sourceFile,
-                           String className,
-                           SlingIOProvider ioProvider) {
+    public CompilationUnit(final String sourceFile,
+                           final String className,
+                           final SlingIOProvider ioProvider) {
         this.className = className;
         this.sourceFile = sourceFile;
         this.ioProvider = ioProvider;
     }
 
     /**
-     * @see org.apache.sling.commons.compiler.CompileUnit#getSourceFileName()
+     * @see org.apache.sling.commons.compiler.CompilationUnit#getMainClassName()
      */
-    public String getSourceFileName() {
-        return getMainTypeName() + ".java";
+    public String getMainClassName() {
+        return this.className;
     }
 
     /**
-     * @see org.apache.sling.commons.compiler.CompileUnit#getSourceFileContents()
+     * @see org.apache.sling.commons.compiler.CompilationUnit#getSource()
      */
-    public char[] getSourceFileContents() {
-        char[] result = null;
+    public Reader getSource() throws IOException {
         InputStream fr = null;
         try {
             fr = ioProvider.getInputStream(this.sourceFile);
-            final Reader reader = new BufferedReader(new InputStreamReader(fr, ioProvider.getOptions().getJavaEncoding()));
-            try {
-                char[] chars = new char[8192];
-                StringBuilder buf = new StringBuilder();
-                int count;
-                while ((count = reader.read(chars, 0, chars.length)) > 0) {
-                    buf.append(chars, 0, count);
-                }
-                result = new char[buf.length()];
-                buf.getChars(0, result.length, result, 0);
-            } finally {
-                reader.close();
-            }
+            return new InputStreamReader(fr, ioProvider.getOptions().getJavaEncoding());
         } catch (IOException e) {
-            this.onError(e.getMessage(), this.sourceFile, 0, 0);
-        }
-        return result;
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.CompileUnit#getMainTypeName()
-     */
-    public String getMainTypeName() {
-        int dot = className.lastIndexOf('.');
-        if (dot > 0) {
-            return className.substring(dot + 1);
-        }
-        return className;
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.CompilerEnvironment#isPackage(java.lang.String)
-     */
-    public boolean isPackage(String result) {
-        if (result.equals(this.className)) {
-            return false;
-        }
-        String resourceName = result.replace('.', '/') + ".class";
-        if ( resourceName.startsWith("/") ) {
-            resourceName = resourceName.substring(1);
-        }
-        final InputStream is = this.ioProvider.getClassLoader().getResourceAsStream(resourceName);
-        if ( is != null ) {
-            try {
-                is.close();
-            } catch (IOException ignore) {}
-        }
-        return is == null;
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.CompilerEnvironment#findClass(java.lang.String)
-     */
-    public byte[] findClass(String name) throws Exception {
-        final String resourceName = name.replace('.', '/') + ".class";
-        final InputStream is = this.ioProvider.getClassLoader().getResourceAsStream(resourceName);
-        if (is != null) {
-            try {
-                byte[] buf = new byte[8192];
-                ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
-                int count;
-                while ((count = is.read(buf, 0, buf.length)) > 0) {
-                    baos.write(buf, 0, count);
-                }
-                baos.flush();
-                return baos.toByteArray();
-            } finally {
-                try {
-                    is.close();
-                } catch (IOException ignore) {}
+            if ( fr != null ) {
+                try { fr.close(); } catch (IOException ignore) {}
             }
+            throw e;
         }
-        return null;
     }
 
     /**
-     * @see org.apache.sling.commons.compiler.CompilerEnvironment#cleanup()
+     * @see org.apache.sling.commons.compiler.CompilationUnit#getLastModified()
      */
-    public void cleanup() {
-        // EMPTY
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.ErrorHandler#onError(java.lang.String, java.lang.String, int, int)
-     */
-    public void onError(String msg, String sourceFile, int line, int position) {
-        if ( errors == null ) {
-            errors = new ArrayList<CompilerError>();
-        }
-        errors.add(new CompilerError(sourceFile, line, position, msg));
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.ErrorHandler#onWarning(java.lang.String, java.lang.String, int, int)
-     */
-    public void onWarning(String msg, String sourceFile, int line, int position) {
-        // we ignore warnings
-    }
-
-    /**
-     * @see org.apache.sling.commons.compiler.ClassWriter#write(java.lang.String, byte[])
-     */
-    public void write(String name, byte[] data) throws Exception {
-        final OutputStream os = this.ioProvider.getOutputStream('/' + name.replace('.', '/') + ".class");
-        os.write(data);
-        os.close();
-    }
-
-    /** Return the list of errors. */
-    public List<CompilerError> getErrors() throws IOException {
-        return errors;
+    public long getLastModified() {
+        return this.ioProvider.lastModified(this.sourceFile);
     }
 }
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java
deleted file mode 100644
index 4f7dcb9..0000000
--- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerError.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.sling.scripting.java.impl;
-
-/**
- * This class encapsulates an error message produced by a programming language
- * processor (whether interpreted or compiled)
- */
-public class CompilerError {
-
-    /**
-     * The start line number of the offending program text
-     */
-    private final int startline;
-
-    /**
-     * The start column number of the offending program text
-     */
-    private final int startcolumn;
-
-    /**
-     * The name of the file containing the offending program text
-     */
-    private final String file;
-
-    /**
-     * The actual error text produced by the language processor
-     */
-    private final String message;
-
-    /**
-     * The error message constructor.
-     *
-     * @param file The name of the file containing the offending program text
-     * @param startline The start line number of the offending program text
-     * @param startcolumn The start column number of the offending program text
-     * @param message The actual error text produced by the language processor
-     */
-    public CompilerError(final String file,
-                         final int startline,
-                         final int startcolumn,
-                         final String message) {
-        this.file = file;
-        this.startline = startline;
-        this.startcolumn = startcolumn;
-        this.message = message;
-    }
-
-    /**
-     * Return the filename associated with this compiler error.
-     *
-     * @return The filename associated with this compiler error
-     */
-    public String getFile() {
-        return file;
-    }
-
-    /**
-     * Return the starting line number of the program text originating this error
-     *
-     * @return The starting line number of the program text originating this error
-     */
-    public int getStartLine() {
-        return startline;
-    }
-
-    /**
-     * Return the starting column number of the program text originating this
-     * error
-     *
-     * @return The starting column number of the program text originating this
-     * error
-     */
-    public int getStartColumn() {
-        return startcolumn;
-    }
-
-    /**
-     * Return the message produced by the language processor
-     *
-     * @return The message produced by the language processor
-     */
-    public String getMessage() {
-        return message;
-    }
-}
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
index 18ce68e..056373a 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
@@ -32,14 +32,16 @@ public class CompilerOptions extends Options {
         CompilerOptions opts = new CompilerOptions();
 
         final Boolean classDebugInfo = (Boolean)props.get(JavaScriptEngineFactory.PROPERTY_CLASSDEBUGINFO);
-        opts.setGenerateDebugInfo(classDebugInfo != null ? classDebugInfo : true);
+        opts.put(Options.KEY_GENERATE_DEBUG_INFO, classDebugInfo != null ? classDebugInfo : true);
 
         final String sourceVM = (String) props.get(JavaScriptEngineFactory.PROPERTY_COMPILER_SOURCE_V_M);
-        opts.setSourceVersion(sourceVM != null && sourceVM.length() > 0 ? sourceVM : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
+        opts.put(Options.KEY_SOURCE_VERSION, sourceVM != null && sourceVM.length() > 0 ? sourceVM : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
 
         final String encoding = (String) props.get(JavaScriptEngineFactory.PROPERTY_ENCODING);
         opts.encoding = encoding != null && encoding.length() > 0 ? encoding : "UTF-8";
 
+        opts.put(Options.KEY_IGNORE_WARNINGS, true);
+
         return opts;
     }
 
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
index 81e167f..3795897 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
@@ -41,8 +41,6 @@ import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScript;
 import org.apache.sling.api.scripting.SlingScriptConstants;
 import org.apache.sling.api.scripting.SlingScriptHelper;
-import org.apache.sling.commons.classloader.ClassLoaderWriter;
-import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.apache.sling.commons.compiler.JavaCompiler;
 import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
 import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
@@ -79,24 +77,11 @@ public class JavaScriptEngineFactory
     /**
      * @scr.reference
      */
-    private DynamicClassLoaderManager dynamicClassLoaderManager;
-
-    /**
-     * @scr.reference
-     */
     private JavaCompiler javaCompiler;
 
-    /**
-     * The class loader
-     */
-    private ClassLoader javaClassLoader;
-
     /** @scr.reference */
     private ServletContext slingServletContext;
 
-    /** @scr.reference */
-    private ClassLoaderWriter classLoaderWriter;
-
     private SlingIOProvider ioProvider;
 
     private JavaServletContext javaServletContext;
@@ -141,9 +126,7 @@ public class JavaScriptEngineFactory
      */
     @SuppressWarnings("unchecked")
     protected void activate(final ComponentContext componentContext) {
-        this.ioProvider = new SlingIOProvider(this.classLoaderWriter,
-                                              this.javaCompiler,
-                                              this.javaClassLoader,
+        this.ioProvider = new SlingIOProvider(this.javaCompiler,
                                               CompilerOptions.createOptions(componentContext.getProperties()));
         this.javaServletContext = new JavaServletContext(ioProvider,
             slingServletContext);
@@ -248,44 +231,6 @@ public class JavaScriptEngineFactory
     }
 
     /**
-     * Bind the class load provider.
-     * @param repositoryClassLoaderProvider the new provider
-     */
-    protected void bindDynamicClassLoaderManager(DynamicClassLoaderManager rclp) {
-        if ( this.javaClassLoader != null ) {
-            this.ungetClassLoader();
-        }
-        this.getClassLoader(rclp);
-    }
-
-    /**
-     * Unbind the class loader provider.
-     * @param repositoryClassLoaderProvider the old provider
-     */
-    protected void unbindDynamicClassLoaderManager(DynamicClassLoaderManager rclp) {
-        if ( this.dynamicClassLoaderManager == rclp ) {
-            this.ungetClassLoader();
-        }
-    }
-
-    /**
-     * Get the class loader
-     */
-    private void getClassLoader(DynamicClassLoaderManager rclp) {
-        this.dynamicClassLoaderManager = rclp;
-        this.javaClassLoader = rclp.getDynamicClassLoader();
-    }
-
-    /**
-     * Unget the class loader
-     */
-    private void ungetClassLoader() {
-        this.dynamicClassLoaderManager = null;
-        this.javaClassLoader = null;
-    }
-    // ---------- Internal -----------------------------------------------------
-
-    /**
      * @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
      */
     public void handleEvent(Event event) {
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java
index 536f4c5..ba38f94 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java
@@ -17,7 +17,6 @@
 
 package org.apache.sling.scripting.java.impl;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.List;
 
@@ -29,7 +28,8 @@ import javax.servlet.UnavailableException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.sling.commons.compiler.CompileUnit;
+import org.apache.sling.commons.compiler.CompilationResult;
+import org.apache.sling.commons.compiler.CompilerMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,23 +77,6 @@ public class ServletWrapper {
     }
 
     /**
-     * Get the servlet.
-     * @throws ServletException
-     * @throws IOException
-     * @throws FileNotFoundException
-     */
-    private void getServlet()
-    throws IllegalAccessException, InstantiationException, ClassNotFoundException, ServletException {
-        destroy();
-
-        this.servletClass = this.ioProvider.getClassLoader().loadClass(this.className);
-        final Servlet servlet = (Servlet) servletClass.newInstance();
-        servlet.init(config);
-
-        theServlet = servlet;
-    }
-
-    /**
      * Call the servlet.
      * @param request The current request.
      * @param response The current response.
@@ -122,12 +105,9 @@ public class ServletWrapper {
                 synchronized (this) {
                     if (this.lastModificationTest == 0 ) {
                         try {
-                            if ( this.compile() || this.theServlet == null ) {
-                                // clear exception
-                                this.compileException = null;
-                                // (re)load the servlet class
-                                getServlet();
-                            }
+                            // clear exception
+                            this.compileException = null;
+                            this.compile();
                         } catch (Exception ex) {
                             // store exception for futher access attempts
                             this.compileException = ex;
@@ -186,48 +166,38 @@ public class ServletWrapper {
         this.lastModificationTest = 0;
     }
 
-    /**
-     * Check if the compiled class file is older than the source file
-     */
-    private boolean isOutDated() {
-        if ( this.lastModificationTest > 0 ) {
-            return false;
-        }
-        final long sourceLastModified = this.ioProvider.lastModified(this.sourcePath);
+    private void compile() throws Exception {
+        final CompilationUnit unit = new CompilationUnit(this.sourcePath, className, ioProvider);
+        final CompilationResult result = this.ioProvider.getCompiler().compile(new org.apache.sling.commons.compiler.CompilationUnit[] {unit},
+                ioProvider.getOptions());
 
-        final long targetLastModified = this.ioProvider.lastModified('/' + this.className.replace('.', '/') + ".class");
-        if (targetLastModified < 0) {
-            return true;
+        final List<CompilerMessage> errors = result.getErrors();
+        if ( errors != null && errors.size() > 0 ) {
+            throw CompilerException.create(errors);
         }
+        if ( result.didCompile() || this.theServlet == null ) {
+            destroy();
 
-        return targetLastModified < sourceLastModified;
-    }
+            this.servletClass = result.loadCompiledClass(this.className);
+            final Servlet servlet = (Servlet) servletClass.newInstance();
+            servlet.init(config);
 
-    private boolean compile() throws Exception {
-        if (this.isOutDated()) {
-            final CompilationUnit unit = new CompilationUnit(this.sourcePath, className, ioProvider);
-            this.ioProvider.getCompiler().compile(new CompileUnit[] {unit}, unit, unit, unit, ioProvider.getOptions());
+            theServlet = servlet;
 
-            final List<CompilerError> errors = unit.getErrors();
-            if ( errors != null && errors.size() > 0 ) {
-                throw CompilerException.create(errors);
-            }
-            return true;
         }
-        return false;
     }
 
     protected final static class CompilerException extends ServletException {
 
-        public static CompilerException create(List<CompilerError> errors) {
+        public static CompilerException create(List<CompilerMessage> errors) {
             final StringBuilder buffer = new StringBuilder();
             buffer.append("Compilation errors:\n");
-            for(final CompilerError e : errors) {
+            for(final CompilerMessage e : errors) {
                 buffer.append(e.getFile());
                 buffer.append(", line ");
-                buffer.append(e.getStartLine());
+                buffer.append(e.getLine());
                 buffer.append(", column ");
-                buffer.append(e.getStartColumn());
+                buffer.append(e.getColumn());
                 buffer.append(" : " );
                 buffer.append(e.getMessage());
                 buffer.append("\n");
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
index 836ac2e..fdba2e7 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java
@@ -19,7 +19,6 @@ package org.apache.sling.scripting.java.impl;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashSet;
@@ -30,7 +29,6 @@ import org.apache.sling.api.SlingException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.compiler.JavaCompiler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,18 +43,11 @@ public class SlingIOProvider  {
 
     private ThreadLocal<ResourceResolver> requestResourceResolver;
 
-    private final ClassLoaderWriter classLoaderWriter;
-
     private final JavaCompiler compiler;
 
     private final CompilerOptions options;
 
     /**
-     * Classloader
-     */
-    private final ClassLoader classLoader;
-
-    /**
      * Servlet cache.
      */
     private final ServletCache servletCache = new ServletCache();
@@ -64,14 +55,10 @@ public class SlingIOProvider  {
     /**
      * Constructor.
      */
-    SlingIOProvider(final ClassLoaderWriter classLoaderWriter,
-                    final JavaCompiler compiler,
-                    final ClassLoader classLoader,
+    SlingIOProvider(final JavaCompiler compiler,
                     final CompilerOptions options) {
         this.requestResourceResolver = new ThreadLocal<ResourceResolver>();
-        this.classLoaderWriter = classLoaderWriter;
         this.compiler = compiler;
-        this.classLoader = classLoader;
         this.options = options;
     }
 
@@ -93,10 +80,6 @@ public class SlingIOProvider  {
         return this.compiler;
     }
 
-    public ClassLoader getClassLoader() {
-        return this.classLoader;
-    }
-
     public CompilerOptions getOptions() {
         return this.options;
     }
@@ -113,12 +96,12 @@ public class SlingIOProvider  {
     public InputStream getInputStream(String fileName)
     throws FileNotFoundException, IOException {
         try {
-            Resource resource = getResourceInternal(fileName);
+            final Resource resource = getResourceInternal(fileName);
             if (resource == null) {
                 throw new FileNotFoundException("Cannot find " + fileName);
             }
 
-            InputStream stream = resource.adaptTo(InputStream.class);
+            final InputStream stream = resource.adaptTo(InputStream.class);
             if (stream == null) {
                 throw new FileNotFoundException("Cannot find " + fileName);
             }
@@ -138,14 +121,11 @@ public class SlingIOProvider  {
      * returned.
      */
     public long lastModified(String fileName) {
-        if ( fileName.endsWith(".class") ) {
-            return this.classLoaderWriter.getLastModified(fileName);
-        }
         try {
-            Resource resource = getResourceInternal(fileName);
+            final Resource resource = getResourceInternal(fileName);
             if (resource != null) {
-                ResourceMetadata meta = resource.getResourceMetadata();
-                long modTime = meta.getModificationTime();
+                final ResourceMetadata meta = resource.getResourceMetadata();
+                final long modTime = meta.getModificationTime();
                 return (modTime > 0) ? modTime : 0;
             }
 
@@ -157,13 +137,6 @@ public class SlingIOProvider  {
         return -1;
     }
 
-    /**
-     * Returns an output stream to write to the repository.
-     */
-    public OutputStream getOutputStream(String fileName) {
-        return this.classLoaderWriter.getOutputStream(fileName);
-    }
-
     public URL getURL(String path) throws MalformedURLException {
         try {
             final Resource resource = getResourceInternal(path);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 02/16: SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit 51eaa96218c5b3dce90e3a844c65a39f59a22395
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Tue Dec 1 07:32:34 2009 +0000

    SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@885680 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 15fafff..e8cdc34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>7</version>
+        <version>8</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-scripting-java] 13/16: Set target vm version and remove obsolete notice/licence files.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git

commit d34558d126415ccdcf7c1f5bc9ccc3f43122e676
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Dec 16 07:37:16 2010 +0000

    Set target vm version and remove obsolete notice/licence files.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@1049800 13f79535-47bb-0310-9956-ffa450edef68
---
 LICENSE                                            | 202 ------
 NOTICE                                             |   8 -
 .../sling/scripting/java/impl/CompilerOptions.java |   5 +
 .../java/impl/JavaScriptEngineFactory.java         |   5 +-
 src/main/resources/META-INF/LICENSE                | 681 ---------------------
 src/main/resources/META-INF/NOTICE                 |   8 -
 .../OSGI-INF/metatype/metatype.properties          |   4 +
 7 files changed, 13 insertions(+), 900 deletions(-)

diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed 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.
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 2cce499..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,8 +0,0 @@
-Apache Sling Java Scripting Support
-Copyright 2008-2010 The Apache Software Foundation
-
-Apache Sling is based on source code originally developed 
-by Day Software (http://www.day.com/).
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
index 056373a..ab7798e 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
@@ -22,6 +22,8 @@ import org.apache.sling.commons.compiler.Options;
 
 public class CompilerOptions extends Options {
 
+    private static final long serialVersionUID = 6526386931840426139L;
+
     private String encoding;
 
     /**
@@ -37,6 +39,9 @@ public class CompilerOptions extends Options {
         final String sourceVM = (String) props.get(JavaScriptEngineFactory.PROPERTY_COMPILER_SOURCE_V_M);
         opts.put(Options.KEY_SOURCE_VERSION, sourceVM != null && sourceVM.length() > 0 ? sourceVM : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
 
+        final String targetVM = (String) props.get(JavaScriptEngineFactory.PROPERTY_COMPILER_TARGET_V_M);
+        opts.put(Options.KEY_TARGET_VERSION, targetVM != null && targetVM.length() > 0 ? targetVM : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
+
         final String encoding = (String) props.get(JavaScriptEngineFactory.PROPERTY_ENCODING);
         opts.encoding = encoding != null && encoding.length() > 0 ? encoding : "UTF-8";
 
diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
index 3795897..c45944f 100644
--- a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
@@ -58,6 +58,7 @@ import org.osgi.service.event.EventHandler;
  * @scr.service interface="javax.script.ScriptEngineFactory"
  *
  * @scr.property nameRef="PROPERTY_COMPILER_SOURCE_V_M" valueRef="DEFAULT_VM_VERSION"
+ * @scr.property nameRef="PROPERTY_COMPILER_TARGET_V_M" valueRef="DEFAULT_VM_VERSION"
  * @scr.property nameRef="PROPERTY_CLASSDEBUGINFO" value="true" type="Boolean"
  * @scr.property nameRef="PROPERTY_ENCODING" value="UTF-8"
  */
@@ -67,6 +68,8 @@ public class JavaScriptEngineFactory
 
     public static final String PROPERTY_COMPILER_SOURCE_V_M = "java.compilerSourceVM";
 
+    public static final String PROPERTY_COMPILER_TARGET_V_M = "java.compilerTargetVM";
+
     public static final String PROPERTY_CLASSDEBUGINFO = "java.classdebuginfo";
 
     public static final String PROPERTY_ENCODING = "java.javaEncoding";
@@ -198,7 +201,7 @@ public class JavaScriptEngineFactory
         } catch (ServletException se) {
             throw new SlingServletException(se);
         } catch (Exception ex) {
-            throw new SlingException(ex) {};
+            throw new SlingException(null, ex);
         } finally {
             request.setAttribute(SlingBindings.class.getName(), oldValue);
             ioProvider.resetRequestResourceResolver();
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 884d3e7..0000000
--- a/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,681 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed 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.
-
-
-APACHE SLING SUBCOMPONENTS:
-
-Apache Sling includes subcomponents with separate copyright notices and
-license terms. Your use of these subcomponents is subject to the terms
-and conditions of the following licenses.
-
-Rhino
-
-                          MOZILLA PUBLIC LICENSE
-                                Version 1.1
-
-                              ---------------
-
-   1. Definitions.
-
-     1.0.1. "Commercial Use" means distribution or otherwise making the
-     Covered Code available to a third party.
-
-     1.1. "Contributor" means each entity that creates or contributes to
-     the creation of Modifications.
-
-     1.2. "Contributor Version" means the combination of the Original
-     Code, prior Modifications used by a Contributor, and the Modifications
-     made by that particular Contributor.
-
-     1.3. "Covered Code" means the Original Code or Modifications or the
-     combination of the Original Code and Modifications, in each case
-     including portions thereof.
-
-     1.4. "Electronic Distribution Mechanism" means a mechanism generally
-     accepted in the software development community for the electronic
-     transfer of data.
-
-     1.5. "Executable" means Covered Code in any form other than Source
-     Code.
-
-     1.6. "Initial Developer" means the individual or entity identified
-     as the Initial Developer in the Source Code notice required by Exhibit
-     A.
-
-     1.7. "Larger Work" means a work which combines Covered Code or
-     portions thereof with code not governed by the terms of this License.
-
-     1.8. "License" means this document.
-
-     1.8.1. "Licensable" means having the right to grant, to the maximum
-     extent possible, whether at the time of the initial grant or
-     subsequently acquired, any and all of the rights conveyed herein.
-
-     1.9. "Modifications" means any addition to or deletion from the
-     substance or structure of either the Original Code or any previous
-     Modifications. When Covered Code is released as a series of files, a
-     Modification is:
-          A. Any addition to or deletion from the contents of a file
-          containing Original Code or previous Modifications.
-
-          B. Any new file that contains any part of the Original Code or
-          previous Modifications.
-
-     1.10. "Original Code" means Source Code of computer software code
-     which is described in the Source Code notice required by Exhibit A as
-     Original Code, and which, at the time of its release under this
-     License is not already Covered Code governed by this License.
-
-     1.10.1. "Patent Claims" means any patent claim(s), now owned or
-     hereafter acquired, including without limitation,  method, process,
-     and apparatus claims, in any patent Licensable by grantor.
-
-     1.11. "Source Code" means the preferred form of the Covered Code for
-     making modifications to it, including all modules it contains, plus
-     any associated interface definition files, scripts used to control
-     compilation and installation of an Executable, or source code
-     differential comparisons against either the Original Code or another
-     well known, available Covered Code of the Contributor's choice. The
-     Source Code can be in a compressed or archival form, provided the
-     appropriate decompression or de-archiving software is widely available
-     for no charge.
-
-     1.12. "You" (or "Your")  means an individual or a legal entity
-     exercising rights under, and complying with all of the terms of, this
-     License or a future version of this License issued under Section 6.1.
-     For legal entities, "You" includes any entity which controls, is
-     controlled by, or is under common control with You. For purposes of
-     this definition, "control" means (a) the power, direct or indirect,
-     to cause the direction or management of such entity, whether by
-     contract or otherwise, or (b) ownership of more than fifty percent
-     (50%) of the outstanding shares or beneficial ownership of such
-     entity.
-
-   2. Source Code License.
-
-     2.1. The Initial Developer Grant.
-     The Initial Developer hereby grants You a world-wide, royalty-free,
-     non-exclusive license, subject to third party intellectual property
-     claims:
-          (a)  under intellectual property rights (other than patent or
-          trademark) Licensable by Initial Developer to use, reproduce,
-          modify, display, perform, sublicense and distribute the Original
-          Code (or portions thereof) with or without Modifications, and/or
-          as part of a Larger Work; and
-
-          (b) under Patents Claims infringed by the making, using or
-          selling of Original Code, to make, have made, use, practice,
-          sell, and offer for sale, and/or otherwise dispose of the
-          Original Code (or portions thereof).
-
-          (c) the licenses granted in this Section 2.1(a) and (b) are
-          effective on the date Initial Developer first distributes
-          Original Code under the terms of this License.
-
-          (d) Notwithstanding Section 2.1(b) above, no patent license is
-          granted: 1) for code that You delete from the Original Code; 2)
-          separate from the Original Code;  or 3) for infringements caused
-          by: i) the modification of the Original Code or ii) the
-          combination of the Original Code with other software or devices.
-
-     2.2. Contributor Grant.
-     Subject to third party intellectual property claims, each Contributor
-     hereby grants You a world-wide, royalty-free, non-exclusive license
-
-          (a)  under intellectual property rights (other than patent or
-          trademark) Licensable by Contributor, to use, reproduce, modify,
-          display, perform, sublicense and distribute the Modifications
-          created by such Contributor (or portions thereof) either on an
-          unmodified basis, with other Modifications, as Covered Code
-          and/or as part of a Larger Work; and
-
-          (b) under Patent Claims infringed by the making, using, or
-          selling of  Modifications made by that Contributor either alone
-          and/or in combination with its Contributor Version (or portions
-          of such combination), to make, use, sell, offer for sale, have
-          made, and/or otherwise dispose of: 1) Modifications made by that
-          Contributor (or portions thereof); and 2) the combination of
-          Modifications made by that Contributor with its Contributor
-          Version (or portions of such combination).
-
-          (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
-          effective on the date Contributor first makes Commercial Use of
-          the Covered Code.
-
-          (d)    Notwithstanding Section 2.2(b) above, no patent license is
-          granted: 1) for any code that Contributor has deleted from the
-          Contributor Version; 2)  separate from the Contributor Version;
-          3)  for infringements caused by: i) third party modifications of
-          Contributor Version or ii)  the combination of Modifications made
-          by that Contributor with other software  (except as part of the
-          Contributor Version) or other devices; or 4) under Patent Claims
-          infringed by Covered Code in the absence of Modifications made by
-          that Contributor.
-
-   3. Distribution Obligations.
-
-     3.1. Application of License.
-     The Modifications which You create or to which You contribute are
-     governed by the terms of this License, including without limitation
-     Section 2.2. The Source Code version of Covered Code may be
-     distributed only under the terms of this License or a future version
-     of this License released under Section 6.1, and You must include a
-     copy of this License with every copy of the Source Code You
-     distribute. You may not offer or impose any terms on any Source Code
-     version that alters or restricts the applicable version of this
-     License or the recipients' rights hereunder. However, You may include
-     an additional document offering the additional rights described in
-     Section 3.5.
-
-     3.2. Availability of Source Code.
-     Any Modification which You create or to which You contribute must be
-     made available in Source Code form under the terms of this License
-     either on the same media as an Executable version or via an accepted
-     Electronic Distribution Mechanism to anyone to whom you made an
-     Executable version available; and if made available via Electronic
-     Distribution Mechanism, must remain available for at least twelve (12)
-     months after the date it initially became available, or at least six
-     (6) months after a subsequent version of that particular Modification
-     has been made available to such recipients. You are responsible for
-     ensuring that the Source Code version remains available even if the
-     Electronic Distribution Mechanism is maintained by a third party.
-
-     3.3. Description of Modifications.
-     You must cause all Covered Code to which You contribute to contain a
-     file documenting the changes You made to create that Covered Code and
-     the date of any change. You must include a prominent statement that
-     the Modification is derived, directly or indirectly, from Original
-     Code provided by the Initial Developer and including the name of the
-     Initial Developer in (a) the Source Code, and (b) in any notice in an
-     Executable version or related documentation in which You describe the
-     origin or ownership of the Covered Code.
-
-     3.4. Intellectual Property Matters
-          (a) Third Party Claims.
-          If Contributor has knowledge that a license under a third party's
-          intellectual property rights is required to exercise the rights
-          granted by such Contributor under Sections 2.1 or 2.2,
-          Contributor must include a text file with the Source Code
-          distribution titled "LEGAL" which describes the claim and the
-          party making the claim in sufficient detail that a recipient will
-          know whom to contact. If Contributor obtains such knowledge after
-          the Modification is made available as described in Section 3.2,
-          Contributor shall promptly modify the LEGAL file in all copies
-          Contributor makes available thereafter and shall take other steps
-          (such as notifying appropriate mailing lists or newsgroups)
-          reasonably calculated to inform those who received the Covered
-          Code that new knowledge has been obtained.
-
-          (b) Contributor APIs.
-          If Contributor's Modifications include an application programming
-          interface and Contributor has knowledge of patent licenses which
-          are reasonably necessary to implement that API, Contributor must
-          also include this information in the LEGAL file.
-
-               (c)    Representations.
-          Contributor represents that, except as disclosed pursuant to
-          Section 3.4(a) above, Contributor believes that Contributor's
-          Modifications are Contributor's original creation(s) and/or
-          Contributor has sufficient rights to grant the rights conveyed by
-          this License.
-
-     3.5. Required Notices.
-     You must duplicate the notice in Exhibit A in each file of the Source
-     Code.  If it is not possible to put such notice in a particular Source
-     Code file due to its structure, then You must include such notice in a
-     location (such as a relevant directory) where a user would be likely
-     to look for such a notice.  If You created one or more Modification(s)
-     You may add your name as a Contributor to the notice described in
-     Exhibit A.  You must also duplicate this License in any documentation
-     for the Source Code where You describe recipients' rights or ownership
-     rights relating to Covered Code.  You may choose to offer, and to
-     charge a fee for, warranty, support, indemnity or liability
-     obligations to one or more recipients of Covered Code. However, You
-     may do so only on Your own behalf, and not on behalf of the Initial
-     Developer or any Contributor. You must make it absolutely clear than
-     any such warranty, support, indemnity or liability obligation is
-     offered by You alone, and You hereby agree to indemnify the Initial
-     Developer and every Contributor for any liability incurred by the
-     Initial Developer or such Contributor as a result of warranty,
-     support, indemnity or liability terms You offer.
-
-     3.6. Distribution of Executable Versions.
-     You may distribute Covered Code in Executable form only if the
-     requirements of Section 3.1-3.5 have been met for that Covered Code,
-     and if You include a notice stating that the Source Code version of
-     the Covered Code is available under the terms of this License,
-     including a description of how and where You have fulfilled the
-     obligations of Section 3.2. The notice must be conspicuously included
-     in any notice in an Executable version, related documentation or
-     collateral in which You describe recipients' rights relating to the
-     Covered Code. You may distribute the Executable version of Covered
-     Code or ownership rights under a license of Your choice, which may
-     contain terms different from this License, provided that You are in
-     compliance with the terms of this License and that the license for the
-     Executable version does not attempt to limit or alter the recipient's
-     rights in the Source Code version from the rights set forth in this
-     License. If You distribute the Executable version under a different
-     license You must make it absolutely clear that any terms which differ
-     from this License are offered by You alone, not by the Initial
-     Developer or any Contributor. You hereby agree to indemnify the
-     Initial Developer and every Contributor for any liability incurred by
-     the Initial Developer or such Contributor as a result of any such
-     terms You offer.
-
-     3.7. Larger Works.
-     You may create a Larger Work by combining Covered Code with other code
-     not governed by the terms of this License and distribute the Larger
-     Work as a single product. In such a case, You must make sure the
-     requirements of this License are fulfilled for the Covered Code.
-
-   4. Inability to Comply Due to Statute or Regulation.
-
-     If it is impossible for You to comply with any of the terms of this
-     License with respect to some or all of the Covered Code due to
-     statute, judicial order, or regulation then You must: (a) comply with
-     the terms of this License to the maximum extent possible; and (b)
-     describe the limitations and the code they affect. Such description
-     must be included in the LEGAL file described in Section 3.4 and must
-     be included with all distributions of the Source Code. Except to the
-     extent prohibited by statute or regulation, such description must be
-     sufficiently detailed for a recipient of ordinary skill to be able to
-     understand it.
-
-   5. Application of this License.
-
-     This License applies to code to which the Initial Developer has
-     attached the notice in Exhibit A and to related Covered Code.
-
-   6. Versions of the License.
-
-     6.1. New Versions.
-     Netscape Communications Corporation ("Netscape") may publish revised
-     and/or new versions of the License from time to time. Each version
-     will be given a distinguishing version number.
-
-     6.2. Effect of New Versions.
-     Once Covered Code has been published under a particular version of the
-     License, You may always continue to use it under the terms of that
-     version. You may also choose to use such Covered Code under the terms
-     of any subsequent version of the License published by Netscape. No one
-     other than Netscape has the right to modify the terms applicable to
-     Covered Code created under this License.
-
-     6.3. Derivative Works.
-     If You create or use a modified version of this License (which you may
-     only do in order to apply it to code which is not already Covered Code
-     governed by this License), You must (a) rename Your license so that
-     the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
-     "MPL", "NPL" or any confusingly similar phrase do not appear in your
-     license (except to note that your license differs from this License)
-     and (b) otherwise make it clear that Your version of the license
-     contains terms which differ from the Mozilla Public License and
-     Netscape Public License. (Filling in the name of the Initial
-     Developer, Original Code or Contributor in the notice described in
-     Exhibit A shall not of themselves be deemed to be modifications of
-     this License.)
-
-   7. DISCLAIMER OF WARRANTY.
-
-     COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
-     WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-     WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
-     DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
-     THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
-     IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
-     YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
-     COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
-     OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
-     ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-
-   8. TERMINATION.
-
-     8.1.  This License and the rights granted hereunder will terminate
-     automatically if You fail to comply with terms herein and fail to cure
-     such breach within 30 days of becoming aware of the breach. All
-     sublicenses to the Covered Code which are properly granted shall
-     survive any termination of this License. Provisions which, by their
-     nature, must remain in effect beyond the termination of this License
-     shall survive.
-
-     8.2.  If You initiate litigation by asserting a patent infringement
-     claim (excluding declatory judgment actions) against Initial Developer
-     or a Contributor (the Initial Developer or Contributor against whom
-     You file such action is referred to as "Participant")  alleging that:
-
-     (a)  such Participant's Contributor Version directly or indirectly
-     infringes any patent, then any and all rights granted by such
-     Participant to You under Sections 2.1 and/or 2.2 of this License
-     shall, upon 60 days notice from Participant terminate prospectively,
-     unless if within 60 days after receipt of notice You either: (i)
-     agree in writing to pay Participant a mutually agreeable reasonable
-     royalty for Your past and future use of Modifications made by such
-     Participant, or (ii) withdraw Your litigation claim with respect to
-     the Contributor Version against such Participant.  If within 60 days
-     of notice, a reasonable royalty and payment arrangement are not
-     mutually agreed upon in writing by the parties or the litigation claim
-     is not withdrawn, the rights granted by Participant to You under
-     Sections 2.1 and/or 2.2 automatically terminate at the expiration of
-     the 60 day notice period specified above.
-
-     (b)  any software, hardware, or device, other than such Participant's
-     Contributor Version, directly or indirectly infringes any patent, then
-     any rights granted to You by such Participant under Sections 2.1(b)
-     and 2.2(b) are revoked effective as of the date You first made, used,
-     sold, distributed, or had made, Modifications made by that
-     Participant.
-
-     8.3.  If You assert a patent infringement claim against Participant
-     alleging that such Participant's Contributor Version directly or
-     indirectly infringes any patent where such claim is resolved (such as
-     by license or settlement) prior to the initiation of patent
-     infringement litigation, then the reasonable value of the licenses
-     granted by such Participant under Sections 2.1 or 2.2 shall be taken
-     into account in determining the amount or value of any payment or
-     license.
-
-     8.4.  In the event of termination under Sections 8.1 or 8.2 above,
-     all end user license agreements (excluding distributors and resellers)
-     which have been validly granted by You or any distributor hereunder
-     prior to termination shall survive termination.
-
-   9. LIMITATION OF LIABILITY.
-
-     UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
-     (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
-     DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
-     OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
-     ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
-     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
-     WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
-     COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
-     INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
-     LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
-     RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
-     PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
-     EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
-     THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-   10. U.S. GOVERNMENT END USERS.
-
-     The Covered Code is a "commercial item," as that term is defined in
-     48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
-     software" and "commercial computer software documentation," as such
-     terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
-     C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
-     all U.S. Government End Users acquire Covered Code with only those
-     rights set forth herein.
-
-   11. MISCELLANEOUS.
-
-     This License represents the complete agreement concerning subject
-     matter hereof. If any provision of this License is held to be
-     unenforceable, such provision shall be reformed only to the extent
-     necessary to make it enforceable. This License shall be governed by
-     California law provisions (except to the extent applicable law, if
-     any, provides otherwise), excluding its conflict-of-law provisions.
-     With respect to disputes in which at least one party is a citizen of,
-     or an entity chartered or registered to do business in the United
-     States of America, any litigation relating to this License shall be
-     subject to the jurisdiction of the Federal Courts of the Northern
-     District of California, with venue lying in Santa Clara County,
-     California, with the losing party responsible for costs, including
-     without limitation, court costs and reasonable attorneys' fees and
-     expenses. The application of the United Nations Convention on
-     Contracts for the International Sale of Goods is expressly excluded.
-     Any law or regulation which provides that the language of a contract
-     shall be construed against the drafter shall not apply to this
-     License.
-
-   12. RESPONSIBILITY FOR CLAIMS.
-
-     As between Initial Developer and the Contributors, each party is
-     responsible for claims and damages arising, directly or indirectly,
-     out of its utilization of rights under this License and You agree to
-     work with Initial Developer and Contributors to distribute such
-     responsibility on an equitable basis. Nothing herein is intended or
-     shall be deemed to constitute any admission of liability.
-
-   13. MULTIPLE-LICENSED CODE.
-
-     Initial Developer may designate portions of the Covered Code as
-     "Multiple-Licensed".  "Multiple-Licensed" means that the Initial
-     Developer permits you to utilize portions of the Covered Code under
-     Your choice of the NPL or the alternative licenses, if any, specified
-     by the Initial Developer in the file described in Exhibit A.
-
-   EXHIBIT A -Mozilla Public License.
-
-     ``The contents of this file are subject to the Mozilla Public License
-     Version 1.1 (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.mozilla.org/MPL/
-
-     Software distributed under the License is distributed on an "AS IS"
-     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-     License for the specific language governing rights and limitations
-     under the License.
-
-     The Original Code is ______________________________________.
-
-     The Initial Developer of the Original Code is ________________________.
-     Portions created by ______________________ are Copyright (C) ______
-     _______________________. All Rights Reserved.
-
-     Contributor(s): ______________________________________.
-
-     Alternatively, the contents of this file may be used under the terms
-     of the _____ license (the  "[___] License"), in which case the
-     provisions of [______] License are applicable instead of those
-     above.  If you wish to allow use of your version of this file only
-     under the terms of the [____] License and not to allow others to use
-     your version of this file under the MPL, indicate your decision by
-     deleting  the provisions above and replace  them with the notice and
-     other provisions required by the [___] License.  If you do not delete
-     the provisions above, a recipient may use your version of this file
-     under either the MPL or the [___] License."
-
-     [NOTE: The text of this Exhibit A may differ slightly from the text of
-     the notices in the Source Code files of the Original Code. You should
-     use the text of this Exhibit A rather than the text found in the
-     Original Code Source Code for Your Modifications.]
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 2cce499..0000000
--- a/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,8 +0,0 @@
-Apache Sling Java Scripting Support
-Copyright 2008-2010 The Apache Software Foundation
-
-Apache Sling is based on source code originally developed 
-by Day Software (http://www.day.com/).
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index 8b87cf2..b5de3a5 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -37,3 +37,7 @@ java.javaEncoding.description = Encoding to be used to read the source files. \
 java.compilerSourceVM.name = Source VM
 java.compilerSourceVM.description = Java Specification to be used to read \
  the source files.
+
+java.compilerTargetVM.name = Target VM
+java.compilerTargetVM.description = Target Java version for compilation.
+ 
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.