You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/05/19 16:54:17 UTC

svn commit: r539766 - in /tapestry/tapestry4/trunk: tapestry-examples/TimeTracker/src/context/Home.html tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java

Author: jkuhnert
Date: Sat May 19 07:54:17 2007
New Revision: 539766

URL: http://svn.apache.org/viewvc?view=rev&rev=539766
Log:
Fixes OGNL-77.  Was stupidly trying to do class name generation of OGNL expressions when ClassFabUtils has some handy methods for this.

Modified:
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html?view=diff&rev=539766&r1=539765&r2=539766
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/Home.html Sat May 19 07:54:17 2007
@@ -4,9 +4,9 @@
 <span jwcid="@Border">
 
 <p>
-This is the Tapestry TimeTracker application. It is a demonstration of some of the new
-core features available in tapestry, as well as how a sample application might be built
-using them.
+    This is the Tapestry TimeTracker application. It is a demonstration of some of the new
+    core features available in tapestry, as well as how a sample application might be built
+    using them.
 </p>
 
 <form jwcid="taskForm@Form" class="container" clientValidationEnabled="true" >

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java?view=diff&rev=539766&r1=539765&r2=539766
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/HiveMindExpressionCompiler.java Sat May 19 07:54:17 2007
@@ -20,6 +20,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.service.ClassFab;
+import org.apache.hivemind.service.ClassFabUtils;
 import org.apache.hivemind.service.ClassFactory;
 import org.apache.hivemind.service.MethodSignature;
 import org.apache.tapestry.IRender;
@@ -35,8 +36,6 @@
 public class HiveMindExpressionCompiler extends ExpressionCompiler implements OgnlExpressionCompiler {
     
     private static final Log _log = LogFactory.getLog(HiveMindExpressionCompiler.class);
-
-    private double _globalCounter = 0;
     
     private ClassFactory _classFactory;
 
@@ -133,10 +132,9 @@
                 return;
 
             String getBody = null;
-            String setBody = null;
+            String setBody;
 
-            ClassFab classFab = _classFactory.newClass(expression.getClass().getName() + expression.hashCode()
-                                                       + ++_globalCounter + "Accessor", Object.class);
+            ClassFab classFab = _classFactory.newClass(ClassFabUtils.generateClassName(expression.getClass()), Object.class);
             classFab.addInterface(ExpressionAccessor.class);
 
             MethodSignature valueGetter = new MethodSignature(Object.class, "get", new Class[]{OgnlContext.class, Object.class}, null);
@@ -261,9 +259,7 @@
             }
 
             classFab.addMethod(Modifier.PUBLIC, valueGetter, generateOgnlGetter(classFab, valueGetter));
-
             classFab.addMethod(Modifier.PUBLIC, valueSetter, generateOgnlSetter(classFab, valueSetter));
-
             
             classFab.addConstructor(new Class[0], new Class[0], "{}");
 
@@ -289,8 +285,8 @@
     {
         String pre = "";
         String post = "";
-        String body = null;
-        String getterCode = null;
+        String body;
+        String getterCode;
 
         context.setRoot(root);
         context.setCurrentObject(root);
@@ -376,6 +372,9 @@
 
             body = body.replaceAll("\\.\\.", ".");
 
+            if (_log.isDebugEnabled())
+                _log.debug("createLocalReferences() body is:\n" + body);
+
             MethodSignature method = new MethodSignature(ref.getType(), ref.getName(), params, null);
             classFab.addMethod(Modifier.PUBLIC, method, body);
         }
@@ -392,7 +391,7 @@
         context.setCurrentObject(root);
         context.remove(PRE_CAST);
 
-        String body = null;
+        String body;
 
         String setterCode = expression.toSetSourceString(context, root);
         String castExpression = (String) context.get(PRE_CAST);
@@ -432,16 +431,12 @@
     String generateOgnlGetter(ClassFab newClass, MethodSignature valueGetter)
             throws Exception
     {
-        String body = "{ return _node.getValue($1, $2); }";
-
-        return body;
+        return "{ return _node.getValue($1, $2); }";
     }
 
     String generateOgnlSetter(ClassFab newClass, MethodSignature valueSetter)
             throws Exception
     {
-        String body = "{ _node.setValue($1, $2, $3); }";
-
-        return body;
+        return "{ _node.setValue($1, $2, $3); }";
     }
 }