r9643 - in helma-ng/trunk: apps/demo apps/demo/config modules/helma src/org/helma/javascript src/org/helma/repository

[email protected] Tue, 21 Apr 2009 18:51:52 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090421165152.5FCDF3D0D6@mia>
Author: hannes
Date: 2009-04-21 18:51:52 +0200 (Tue, 21 Apr 2009)
New Revision: 9643

Modified:
   helma-ng/trunk/apps/demo/config.js
   helma-ng/trunk/apps/demo/config/log4j.properties
   helma-ng/trunk/modules/helma/profiler.js
   helma-ng/trunk/src/org/helma/javascript/ModuleScope.java
   helma-ng/trunk/src/org/helma/repository/Trackable.java
Log:
Implement new middleware API in helma/profiler and fix a bug with failing prevention of infitite recursion caused by absolute path names in module's __path__ property.

Details at http://dev.helma.org/trac/helma/changeset/9643

Modified: helma-ng/trunk/apps/demo/config/log4j.properties
===================================================================
--- helma-ng/trunk/apps/demo/config/log4j.properties	2009-04-21 16:26:49 UTC (rev 9642)
+++ helma-ng/trunk/apps/demo/config/log4j.properties	2009-04-21 16:51:52 UTC (rev 9643)
@@ -12,4 +12,4 @@
 # Hint: set categories for module names you're working on to DEBUG level, e.g.:
 # log4j.category.main = DEBUG
 # log4j.category.helma.skin = DEBUG
-log4j.category.helma.webapp = DEBUG
+# log4j.category.helma.webapp = DEBUG

Modified: helma-ng/trunk/apps/demo/config.js
===================================================================
--- helma-ng/trunk/apps/demo/config.js	2009-04-21 16:26:49 UTC (rev 9642)
+++ helma-ng/trunk/apps/demo/config.js	2009-04-21 16:51:52 UTC (rev 9643)
@@ -9,7 +9,8 @@
 
 exports.middleware = [
     // 'helma/webapp/continuation',
-    'helma/logging'
+    'helma/logging',
+    'helma/profiler'
 ];
 
 exports.charset = 'utf8';

Modified: helma-ng/trunk/modules/helma/profiler.js
===================================================================
--- helma-ng/trunk/modules/helma/profiler.js	2009-04-21 16:26:49 UTC (rev 9642)
+++ helma-ng/trunk/modules/helma/profiler.js	2009-04-21 16:51:52 UTC (rev 9643)
@@ -4,7 +4,7 @@
 import('helma/logging');
 import('helma/shell');
 
-export('onRequest', 'onResponse', 'onError', 'Profiler');
+export('handleRequest', 'Profiler');
 
 var system = helma.system;
 var {write, writeln} = helma.shell;
@@ -18,7 +18,7 @@
     var maxFrames = 20;
     var profiler;
 
-    this.onRequest = function() {
+    this.handleRequest = function(req) {
         if (system.getOptimizationLevel() > -1) {
             system.setOptimizationLevel(-1);
             throw {retry: true};
@@ -27,23 +27,22 @@
             profiler = new Profiler();
         }
         system.getRhinoContext().setDebugger(profiler, null);
-    };
 
-    this.onResponse = this.onError = function(req, res) {
-        if (system.getOptimizationLevel() > -1) {
-            return;
-        }
+        var res = req.process();
+
         var result = profiler.getResult(maxFrames);
-        var b = new Buffer();
-        b.writeln();
-        b.writeln("     total  average  calls    path");
+        var buffer = new Buffer();
+        buffer.writeln();
+        buffer.writeln("     total  average  calls    path");
         for (var i = 1; i < result.maxLength; i++) {
             // b.write("—");
-            b.write("-");
+            buffer.write("-");
         }
-        b.writeln();
-        b.writeln(result.data);
-        log.info(b.toString());
+        buffer.writeln();
+        buffer.writeln(result.data);
+        log.info(buffer.toString());
+
+        return res;
     };
 }).apply(this);
 

Modified: helma-ng/trunk/src/org/helma/javascript/ModuleScope.java
===================================================================
--- helma-ng/trunk/src/org/helma/javascript/ModuleScope.java	2009-04-21 16:26:49 UTC (rev 9642)
+++ helma-ng/trunk/src/org/helma/javascript/ModuleScope.java	2009-04-21 16:51:52 UTC (rev 9643)
@@ -47,7 +47,7 @@
         defineProperty("exports", exports,  DONTENUM);
         defineProperty("__exports__", cx.newArray(this, 0), DONTENUM);
         defineProperty("__name__", moduleName, DONTENUM);
-        defineProperty("__path__", source.getPath(), DONTENUM);
+        defineProperty("__path__", source.getRelativePath(), DONTENUM);
     }
 
     public Repository getRepository() {

Modified: helma-ng/trunk/src/org/helma/repository/Trackable.java
===================================================================
--- helma-ng/trunk/src/org/helma/repository/Trackable.java	2009-04-21 16:26:49 UTC (rev 9642)
+++ helma-ng/trunk/src/org/helma/repository/Trackable.java	2009-04-21 16:51:52 UTC (rev 9643)
@@ -60,4 +60,10 @@
      */
     public String getModuleName();
 
+    /**
+     * Get the path of this resource relative to its root repository.
+     * @return the relative resource path
+     */
+    public String getRelativePath();
+
 }

_______________________________________________
Helma-CVS mailing list
[email protected]
http://helma.org/mailman/listinfo/helma-cvs