incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1603792 - in /sling/trunk/bundles/scripting/javascript: pom.xml src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java
Date Thu, 19 Jun 2014 09:43:52 GMT
Author: bdelacretaz
Date: Thu Jun 19 09:43:52 2014
New Revision: 1603792

URL: http://svn.apache.org/r1603792
Log:
SLING-3635 - better OSGi metadata, and use PropertiesUtil

Modified:
    sling/trunk/bundles/scripting/javascript/pom.xml
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java

Modified: sling/trunk/bundles/scripting/javascript/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/pom.xml?rev=1603792&r1=1603791&r2=1603792&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/pom.xml (original)
+++ sling/trunk/bundles/scripting/javascript/pom.xml Thu Jun 19 09:43:52 2014
@@ -63,6 +63,9 @@
                             !org.mozilla.javascript.xml.impl.xmlbeans,
                             org.mozilla.javascript.*
                         </Private-Package>
+                        <Embed-Dependency>
+                            org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/PropertiesUtil.*"
+                        </Embed-Dependency>
                         <ScriptEngine-Name>${project.name}</ScriptEngine-Name>
                         <ScriptEngine-Version>${project.version}</ScriptEngine-Version>
                     </instructions>
@@ -122,6 +125,12 @@
             <version>2.0.2-incubator</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java?rev=1603792&r1=1603791&r2=1603792&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java
Thu Jun 19 09:43:52 2014
@@ -31,6 +31,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
 import org.apache.sling.scripting.javascript.RhinoHostObjectProvider;
 import org.apache.sling.scripting.javascript.SlingWrapper;
@@ -61,13 +62,17 @@ import org.slf4j.LoggerFactory;
  * The <code>RhinoJavaScriptEngineFactory</code> TODO
  *
  */
-@Component(metatype = true)
+@Component(
+        metatype = true,
+        label="Apache Sling Rhino Javascript Engine Factory",
+        description="Javascript engine based on Rino")
 @Service(value=javax.script.ScriptEngineFactory.class)
 @Reference(name="HostObjectProvider", referenceInterface=RhinoHostObjectProvider.class,
            cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC,
            bind="addHostObjectProvider", unbind="removeHostObjectProvider")
 @Property(
         name = RhinoJavaScriptEngineFactory.OPTIMIZATION_CONFIG,
+        label = "Rhino optimization level",
         intValue = RhinoJavaScriptEngineFactory.DEFAULT_OPTIMIZATION_LEVEL,
         description = "The level of optimization for the bytecode generated by Rhino. Provide
values between 0-9, 9 being the most aggressive level of optimization. A value of -1 will
run scripts in interpreted mode")
 public class RhinoJavaScriptEngineFactory extends AbstractScriptEngineFactory
@@ -333,11 +338,9 @@ public class RhinoJavaScriptEngineFactor
     }
 
     private int readOptimizationLevel(Dictionary<?, ?> dictionary) {
-        Object optLevelObj = dictionary.get(OPTIMIZATION_CONFIG);
-        int optLevel = optLevelObj == null ?
-                DEFAULT_OPTIMIZATION_LEVEL :
-                Integer.parseInt(String.valueOf(optLevelObj));
+        int optLevel = PropertiesUtil.toInteger(dictionary.get(OPTIMIZATION_CONFIG), DEFAULT_OPTIMIZATION_LEVEL);
         if (!Context.isValidOptimizationLevel(optLevel)) {
+            log.warn("Invalid optimization level {}, using default value", optLevel);
             optLevel = DEFAULT_OPTIMIZATION_LEVEL;
         }
         return optLevel;



Mime
View raw message