Author: cziegeler
Date: Tue Jul 1 16:01:13 2014
New Revision: 1607126
URL: http://svn.apache.org/r1607126
Log:
SLING-3724 : Provide option to always use current vm version for source and
target
Modified:
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
Modified:
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=1607126&r1=1607125&r2=1607126&view=diff
==============================================================================
---
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
(original)
+++
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
Tue Jul 1 16:01:13 2014
@@ -60,7 +60,6 @@ import org.apache.sling.commons.compiler
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
-import org.apache.sling.scripting.jsp.jasper.Options;
import org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext;
import
org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext.JspFactoryHandler;
import org.apache.sling.scripting.jsp.jasper.runtime.AnnotationProcessor;
@@ -131,7 +130,7 @@ public class JspScriptEngineFactory
private JspRuntimeContext jspRuntimeContext;
- private Options options;
+ private JspServletOptions options;
private JspServletContext jspServletContext;
@@ -343,8 +342,7 @@ public class JspScriptEngineFactory
jspServletContext = new JspServletContext(ioProvider,
slingServletContext, tldLocationsCache);
- servletConfig = new JspServletConfig(jspServletContext,
- properties);
+ servletConfig = new JspServletConfig(jspServletContext,
options.getProperties());
} finally {
// make sure the context loader is reset after setting up the
Modified:
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java?rev=1607126&r1=1607125&r2=1607126&view=diff
==============================================================================
---
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
(original)
+++
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
Tue Jul 1 16:01:13 2014
@@ -19,10 +19,8 @@
package org.apache.sling.scripting.jsp;
import java.util.Collections;
-import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Map;
-import java.util.TreeMap;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -35,26 +33,18 @@ class JspServletConfig implements Servle
private String servletName;
- private Map<String, String> properties;
+ private final Map<String, String> properties;
- JspServletConfig(ServletContext servletContext, Dictionary<?, ?> config) {
+ JspServletConfig(final ServletContext servletContext, final Map<String,
String> config) {
this.servletContext = servletContext;
// set the servlet name
- servletName = (String) config.get(Constants.SERVICE_DESCRIPTION);
+ servletName = config.get(Constants.SERVICE_DESCRIPTION);
if (servletName == null) {
servletName = "JSP Script Handler";
}
- // copy the "jasper." properties
- properties = new TreeMap<String, String>();
- for (Enumeration<?> ke = config.keys(); ke.hasMoreElements();) {
- String key = (String) ke.nextElement();
- if (key.startsWith("jasper.")) {
- properties.put(key.substring("jasper.".length()),
- String.valueOf(config.get(key)));
- }
- }
+ properties = config;
}
public String getInitParameter(String name) {
Modified:
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java?rev=1607126&r1=1607125&r2=1607126&view=diff
==============================================================================
---
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
(original)
+++
sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
Tue Jul 1 16:01:13 2014
@@ -18,7 +18,8 @@ package org.apache.sling.scripting.jsp;
import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.Properties;
+import java.util.Map;
+import java.util.TreeMap;
import javax.servlet.ServletContext;
@@ -43,7 +44,10 @@ public class JspServletOptions implement
/** Default source and target VM version (value is "1.6"). */
private static final String DEFAULT_VM_VERSION = "1.6";
- private Properties settings = new Properties();
+ /** Value for automatic source/target version setting. */
+ private static final String AUTOMATIC_VERSION = "auto";
+
+ private final Map<String, String> settings = new TreeMap<String, String>();
/**
* Should Ant fork its java compiles of JSP pages.
@@ -149,14 +153,16 @@ public class JspServletOptions implement
*/
private boolean displaySourceFragments = false;
- public String getProperty(String name) {
- return this.settings.getProperty(name);
+ private String getProperty(final String name) {
+ return this.settings.get(name);
}
- public void setProperty(String name, String value) {
- if (name != null && value != null) {
- this.settings.setProperty(name, value);
- }
+ private void setProperty(final String name, final String value) {
+ this.settings.put(name, value);
+ }
+
+ public Map<String, String> getProperties() {
+ return this.settings;
}
/**
@@ -316,10 +322,12 @@ public class JspServletOptions implement
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
if (key.startsWith("jasper.")) {
- Object value = config.get(key);
+ final Object value = config.get(key);
if (value != null) {
- setProperty(key.substring("jasper.".length()),
- value.toString());
+ final String strValue = String.valueOf(value).trim();
+ if ( strValue.length() > 0 ) {
+ setProperty(key.substring("jasper.".length()),
strValue);
+ }
}
}
@@ -478,13 +486,19 @@ public class JspServletOptions implement
}
String compilerTargetVM = getProperty("compilerTargetVM");
- if (compilerTargetVM != null && compilerTargetVM.trim().length() > 0 )
{
- this.compilerTargetVM = compilerTargetVM.trim();
+ if (compilerTargetVM != null ) {
+ if ( AUTOMATIC_VERSION.equalsIgnoreCase(compilerTargetVM) ) {
+ compilerTargetVM =
System.getProperty("java.vm.specification.version");
+ }
+ this.compilerTargetVM = compilerTargetVM;
}
String compilerSourceVM = getProperty("compilerSourceVM");
- if (compilerSourceVM != null && compilerSourceVM.trim().length() > 0) {
- this.compilerSourceVM = compilerSourceVM.trim();
+ if (compilerSourceVM != null ) {
+ if ( AUTOMATIC_VERSION.equalsIgnoreCase(compilerSourceVM) ) {
+ compilerSourceVM =
System.getProperty("java.vm.specification.version");
+ }
+ this.compilerSourceVM = compilerSourceVM;
}
String javaEncoding = getProperty("javaEncoding");
Modified:
sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1607126&r1=1607125&r2=1607126&view=diff
==============================================================================
---
sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++
sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Jul 1 16:01:13 2014
@@ -33,11 +33,13 @@ jsphandler.description The JSP Script Ha
jasper.compilerSourceVM.name = Source Version
jasper.compilerSourceVM.description = The JVM version for the java/JSP source.
If \
- left empty, the default version, 1.6., is used.
+ left empty, the default version, 1.6., is used. If the value "auto" is used,
the \
+ current vm version will be used.
jasper.compilerTargetVM.name = Target Version
jasper.compilerTargetVM.description = The taret JVM version for the compiled
classes. If \
- left empty, the default version, 1.6., is used.
+ left empty, the default version, 1.6., is used. If the value "auto" is used,
the \
+ current vm version will be used.
jasper.classdebuginfo.name = Generate Debug Info
jasper.classdebuginfo.description = Should the class file be compiled with \