sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1607130 - in /sling/trunk/contrib/scripting/java/src/main: java/org/apache/sling/scripting/java/impl/ resources/OSGI-INF/metatype/
Date Tue, 01 Jul 2014 16:14:51 GMT
Author: cziegeler
Date: Tue Jul  1 16:14:51 2014
New Revision: 1607130

URL: http://svn.apache.org/r1607130
Log:
SLING-3724 : Provide option to always use current vm version for source and target

Modified:
    sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
    sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
    sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
    sling/trunk/contrib/scripting/java/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java?rev=1607130&r1=1607129&r2=1607130&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
(original)
+++ sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java
Tue Jul  1 16:14:51 2014
@@ -26,6 +26,8 @@ public class CompilerOptions extends Opt
 
     private String encoding;
 
+    private static final String VERSION_AUTO = "auto";
+
     /**
      * Create an compiler options object using data available from
      * the component configuration.
@@ -37,10 +39,16 @@ public class CompilerOptions extends Opt
         opts.put(Options.KEY_GENERATE_DEBUG_INFO, classDebugInfo != null ? classDebugInfo
: true);
 
         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);
+        opts.put(Options.KEY_SOURCE_VERSION, sourceVM != null && sourceVM.trim().length()
> 0 ? sourceVM.trim() : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
+        if ( VERSION_AUTO.equalsIgnoreCase((String)opts.get(Options.KEY_SOURCE_VERSION))
) {
+            opts.put(Options.KEY_SOURCE_VERSION, System.getProperty("java.vm.specification.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);
+        opts.put(Options.KEY_TARGET_VERSION, targetVM != null && targetVM.trim().length()
> 0 ? targetVM.trim() : JavaScriptEngineFactory.DEFAULT_VM_VERSION);
+        if ( VERSION_AUTO.equalsIgnoreCase((String)opts.get(Options.KEY_TARGET_VERSION))
) {
+            opts.put(Options.KEY_TARGET_VERSION, System.getProperty("java.vm.specification.version"));
+        }
 
         final String encoding = (String) props.get(JavaScriptEngineFactory.PROPERTY_ENCODING);
         opts.encoding = encoding != null && encoding.length() > 0 ? encoding :
"UTF-8";

Modified: sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java?rev=1607130&r1=1607129&r2=1607130&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
(original)
+++ sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java
Tue Jul  1 16:14:51 2014
@@ -80,8 +80,8 @@ public class JavaScriptEngineFactory
 
     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";
+    /** Default source and target VM version (value is "1.6"). */
+    public static final String DEFAULT_VM_VERSION = "1.6";
 
     @Reference
     private JavaCompiler javaCompiler;
@@ -130,6 +130,7 @@ public class JavaScriptEngineFactory
     /**
      * @see javax.script.ScriptEngineFactory#getParameter(String)
      */
+    @Override
     public Object getParameter(String name) {
         if ("THREADING".equals(name)) {
             return "STATELESS";

Modified: sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java?rev=1607130&r1=1607129&r2=1607130&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
(original)
+++ sling/trunk/contrib/scripting/java/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java
Tue Jul  1 16:14:51 2014
@@ -56,10 +56,15 @@ public class JavaServletConfig implement
         // copy the "java." properties
         initParams = new HashMap<String, String>();
         for (Enumeration<?> ke = config.keys(); ke.hasMoreElements();) {
-            String key = (String) ke.nextElement();
+            final String key = (String) ke.nextElement();
             if (key.startsWith("java.")) {
-                initParams.put(key.substring("java.".length()),
-                    String.valueOf(config.get(key)));
+                final Object value = config.get(key);
+                if ( value != null ) {
+                    final String strValue = String.valueOf(value).trim();
+                    if ( strValue.length() > 0 ) {
+                        initParams.put(key.substring("java.".length()), strValue);
+                    }
+                }
             }
         }
     }

Modified: sling/trunk/contrib/scripting/java/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/java/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1607130&r1=1607129&r2=1607130&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/java/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/contrib/scripting/java/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Jul  1 16:14:51 2014
@@ -36,8 +36,11 @@ java.javaEncoding.description = Encoding
 
 java.compilerSourceVM.name = Source VM
 java.compilerSourceVM.description = Java Specification to be used to read \
- the source files.
+ the source files. If left empty, the default version, 1.6., is used. If the \
+ value "auto" is used, the current vm version will be used.
 
 java.compilerTargetVM.name = Target VM
-java.compilerTargetVM.description = Target Java version for compilation.
+java.compilerTargetVM.description = Target Java version for compilation. If left \ 
+ empty, the default version, 1.6., is used. If the value "auto" is used, the current \
+ vm version will be used.
  
\ No newline at end of file



Mime
View raw message