incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r886755 - in /sling/trunk/contrib/scripting/scala: engine/ engine/src/main/java/org/apache/sling/scripting/scala/engine/ engine/src/test/java/org/apache/sling/scripting/scala/ interpreter/ interpreter/src/main/scala/org/apache/sling/scripti...
Date Thu, 03 Dec 2009 12:19:47 GMT
Author: cziegeler
Date: Thu Dec  3 12:19:47 2009
New Revision: 886755

URL: http://svn.apache.org/viewvc?rev=886755&view=rev
Log:
SLING-1214 : Fixes to Scala scripting engine - applied patch from Michael Dürig.

Modified:
    sling/trunk/contrib/scripting/scala/engine/pom.xml
    sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
    sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineFactoryTest.java
    sling/trunk/contrib/scripting/scala/interpreter/pom.xml
    sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/BundleFS.scala

Modified: sling/trunk/contrib/scripting/scala/engine/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/pom.xml?rev=886755&r1=886754&r2=886755&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/engine/pom.xml (original)
+++ sling/trunk/contrib/scripting/scala/engine/pom.xml Thu Dec  3 12:19:47 2009
@@ -50,6 +50,11 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-scr-plugin</artifactId>
             </plugin>                          
+
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>maven-sling-plugin</artifactId>
+            </plugin>
             
             <plugin>
                 <groupId>org.apache.felix</groupId>

Modified: sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java?rev=886755&r1=886754&r2=886755&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
(original)
+++ sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java
Thu Dec  3 12:19:47 2009
@@ -61,7 +61,7 @@
     public final static String[] SCALA_SCRIPT_EXTENSIONS = {"scala", "scs"};
     public final static String SCALA_MIME_TYPE = "application/x-scala";
     public final static String SHORT_NAME = "scala";
-    public final static String VERSION = "2.7.3";
+    public final static String VERSION = "2.7.7";
 
     /**
      * @scr.property
@@ -163,7 +163,7 @@
             if (url == null) {
                 url = bundles[k].getResource("");
             }
-            
+
             if (url != null) { // FIXME: log null values
                 if ("file".equals(url.getProtocol())) {
                     try {
@@ -195,7 +195,7 @@
         	}
         }
     }
-    
+
     private Node deepCreateNode(String path, Session session, String nodeType) throws RepositoryException
{
     	Node result = null;
     	if(session.itemExists(path)) {

Modified: sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineFactoryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineFactoryTest.java?rev=886755&r1=886754&r2=886755&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineFactoryTest.java
(original)
+++ sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineFactoryTest.java
Thu Dec  3 12:19:47 2009
@@ -46,7 +46,7 @@
 
     public void testScriptEngineFactoryLanguageVersion() {
         String version = new ScalaScriptEngineFactory().getLanguageVersion();
-        assertEquals("2.7.3", version);
+        assertEquals("2.7.7", version);
     }
 
 }

Modified: sling/trunk/contrib/scripting/scala/interpreter/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/interpreter/pom.xml?rev=886755&r1=886754&r2=886755&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/interpreter/pom.xml (original)
+++ sling/trunk/contrib/scripting/scala/interpreter/pom.xml Thu Dec  3 12:19:47 2009
@@ -55,7 +55,7 @@
                     </execution>
                 </executions>
                 <configuration>
-                    <scalaVersion>${scala.version}</scalaVersion>
+                    <scalaVersion>2.7.7</scalaVersion>
                 </configuration>
             </plugin>
 

Modified: sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/BundleFS.scala
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/BundleFS.scala?rev=886755&r1=886754&r2=886755&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/BundleFS.scala
(original)
+++ sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/BundleFS.scala
Thu Dec  3 12:19:47 2009
@@ -16,6 +16,7 @@
  */
 import scala.tools.nsc.io.AbstractFile
 import java.io.{File, InputStream, OutputStream, IOException}
+import java.util.NoSuchElementException
 import java.net.URL
 import org.osgi.framework.Bundle
 import org.apache.sling.scripting.scala.Utils.{valueOrElse, nullOrElse}
@@ -94,20 +95,49 @@
       def elements: Iterator[AbstractFile] = {
         new Iterator[AbstractFile]() {
           val dirs = bundle.getEntryPaths(fullName)
-          def hasNext = dirs.hasMoreElements
-          def next = {
-            val entry = dirs.nextElement.asInstanceOf[String]
-            var entryUrl = bundle.getResource("/" + entry)
-
-            // Bundle.getResource seems to be inconsistent with respect to requiring
-            // a trailing slash
-            if (entryUrl == null) 
-              entryUrl = bundle.getResource("/" + removeTralingSlash(entry))
-            
-            if (entry.endsWith(".class"))
-              new FileEntry(entryUrl, DirEntry.this)
-            else
-              new DirEntry(entryUrl, DirEntry.this)
+          var nextEntry = prefetch()
+          
+          def hasNext() = {
+            if (nextEntry == null)
+              nextEntry = prefetch()
+           
+            nextEntry != null
+          }
+          
+          def next() = {
+            if (hasNext()) {
+                val entry = nextEntry
+                nextEntry = null
+                entry
+            }
+            else {
+              throw new NoSuchElementException()
+            }
+          }
+          
+          private def prefetch() = {
+            if (dirs.hasMoreElements) {
+              val entry = dirs.nextElement.asInstanceOf[String]
+              var entryUrl = bundle.getResource("/" + entry)
+
+              // Bundle.getResource seems to be inconsistent with respect to requiring
+              // a trailing slash
+              if (entryUrl == null) 
+                entryUrl = bundle.getResource("/" + removeTralingSlash(entry))
+                
+              // If still null OSGi wont let use load that resource for some reason
+              if (entryUrl == null) {
+                null
+              }
+              else {
+                if (entry.endsWith(".class"))
+                  new FileEntry(entryUrl, DirEntry.this)
+                else
+                  new DirEntry(entryUrl, DirEntry.this)
+              }
+            }
+            else 
+              null
           }
           
           private def removeTralingSlash(s: String): String = 



Mime
View raw message