Author: reto
Date: Wed Jun 20 15:28:41 2012
New Revision: 1352159

URL: http://svn.apache.org/viewvc?rev=1352159&view=rev
Log:
CLEREZZA-705: possiblity to disable the fastUpdate mode

Modified:
    
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/BundleRoot.scala
    
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/DevDsl.scala

Modified: 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/BundleRoot.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/BundleRoot.scala?rev=1352159&r1=1352158&r2=1352159&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/BundleRoot.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/BundleRoot.scala
 Wed Jun 20 15:28:41 2012
@@ -65,7 +65,8 @@ class BundleRoot {
                        if 
(location.startsWith(BundleRoot.sourceBundleUriPrefix)) {
                                val dir = new File(location.substring(
                                                
BundleRoot.sourceBundleUriPrefix.length))
-                               val sourceBundle = new SourceBundle(dir, bundle)
+                               //TODO encode fileFastUpdate in location
+                               val sourceBundle = new SourceBundle(dir, 
bundle, true)
                                sourceBundle.start()
                                sourceBundles += sourceBundle
                        }
@@ -79,15 +80,13 @@ class BundleRoot {
        /**
         * adds a SourceBundle for the sources in the specified dir
         */
-       def addSourceBundle(dir: File) = {
-               val sourceBundle = new SourceBundle(dir)
+       def addSourceBundle(dir: File, fileFastUpdate: Boolean) = {
+               val sourceBundle = new SourceBundle(dir, fileFastUpdate)
                sourceBundle.start()
                sourceBundles += sourceBundle
                sourceBundle
        }
 
-       @deprecated
-       def createSourceBundle(dir: File) = addSourceBundle(dir)
 
        /**
        * list of the available skletons
@@ -132,7 +131,7 @@ class BundleRoot {
                }
 
                processDir(skeletonNode, dir)
-               addSourceBundle(dir)
+               addSourceBundle(dir, true)
        }
 
        def bindCompilerService(cs: CompilerService) {
@@ -151,10 +150,10 @@ class BundleRoot {
                packageAdmin = null
        }
 
-       class SourceBundle(dir: File, existingBundle: Bundle) extends 
DaemonActor {
+       class SourceBundle(dir: File, existingBundle: Bundle, fileFastUpdate: 
Boolean) extends DaemonActor {
 
-               def this(dir: File) {
-                       this(dir, null)
+               def this(dir: File, fileFastUpdate: Boolean) {
+                       this(dir, null, fileFastUpdate)
                }
 
                var stopped = false
@@ -163,11 +162,12 @@ class BundleRoot {
                val sourcePath = Path.fromFile(new File(dir,"src"))
                var watchState = WatchState.empty
                var bundle: Bundle = existingBundle
+               if (fileFastUpdate) {
+                       val pathNode = new PermissionGrantingPathNode(new 
FilePathNode(new File(dir,"src/main/resources/CLEREZZA-INF/web-resources/")))
+                       val registration = 
bundleContext.registerService(Array(classOf[PathNode].getName), pathNode, null: 
java.util.Dictionary[_, _])
+                       //println("registered "+classOf[PathNode].getName+": 
"+registration)
+               }
                
-               val pathNode = new PermissionGrantingPathNode(new 
FilePathNode(new File(dir,"src/main/resources/CLEREZZA-INF/web-resources/")))
-               val registration = 
bundleContext.registerService(Array(classOf[PathNode].getName), pathNode, null: 
java.util.Dictionary[_, _])
-               println("registered "+classOf[PathNode].getName+": 
"+registration)
-
                def getFilesAsCharArrays(file: File): List[Array[Char]] = {
                        logger.debug("getting sources in "+file)
                        var result: List[Array[Char]] = Nil

Modified: 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/DevDsl.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/DevDsl.scala?rev=1352159&r1=1352158&r2=1352159&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/DevDsl.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/bundledevtool/src/main/scala/org/apache/clerezza/bundledevtool/DevDsl.scala
 Wed Jun 20 15:28:41 2012
@@ -28,6 +28,19 @@ import org.apache.clerezza.osgi.services
 
 class DevDsl(outputStream: OutputStream, bundleContext: BundleContext) {
 
+       sealed class FastUpdateMode;
+  
+       var fastUpdate = new FastUpdateMode;
+       var noFastUpdate = new FastUpdateMode();
+       
+       case class LocationSpec(location: String, fastUpdateMode: 
FastUpdateMode) {
+               def this(location: String) {
+                 this(location, fastUpdate)
+               }
+       }
+       
+       implicit def locationSpecBuilder(location: String) = new 
LocationSpec(location)
+       
        object Dev {
                private val serviceDsl = new ServicesDsl(bundleContext)
                import serviceDsl._
@@ -51,12 +64,12 @@ class DevDsl(outputStream: OutputStream,
                        }
                }
 
-               def load(location: String) {
-                       val dir = new File(location)
+               def load(locationSpec: LocationSpec) {
+                       val dir = new File(locationSpec.location)
                        if (!dir.isDirectory) {
-                               out println "No directory "+location+" found"
+                               out println "No directory 
"+locationSpec.location+" found"
                        } else {
-                               $[BundleRoot].addSourceBundle(dir)
+                               $[BundleRoot].addSourceBundle(dir, 
locationSpec.fastUpdateMode == fastUpdate)
                        }
                }
                
@@ -68,6 +81,10 @@ class DevDsl(outputStream: OutputStream,
                  out println "\tCreates a new project in /path/to/directory 
using the specified archetype"
                  out println "Dev load \"/path/to/directory\""
                  out println "\tLoads the project in /path/to/directory"
+                 out println "Dev load \"/path/to/directory\""
+                 out println "\tLoads the project in /path/to/directory 
enabling fast-updating of static files"
+                 out println "Dev load 
LocationSpec(\"/path/to/directory\",fastUpdate|noFastUpdate)"
+                 out println "\tLoads the project in /path/to/directory 
enabling or diabling fast-updating of static files"
                }
                
                override def toString = "Run 'Dev help' for usage instructions"


Reply via email to