labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r739900 - in /labs/magma/trunk/website-velocity/src: main/java/org/apache/magma/website/velocity/ test/java/org/apache/magma/website/velocity/ test/resources/org/apache/magma/website/velocity/
Date Mon, 02 Feb 2009 01:38:07 GMT
Author: simoneg
Date: Mon Feb  2 01:38:07 2009
New Revision: 739900

URL: http://svn.apache.org/viewvc?rev=739900&view=rev
Log:
LABS-288 : better interception of method to avoid converting intermendiate values of expressions

Added:
    labs/magma/trunk/website-velocity/src/test/resources/org/apache/magma/website/velocity/testNested.vm
Modified:
    labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/FormatFields.aj
    labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/FakeBean.java
    labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/TestGettersFormatting.java

Modified: labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/FormatFields.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/FormatFields.aj?rev=739900&r1=739899&r2=739900&view=diff
==============================================================================
--- labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/FormatFields.aj
(original)
+++ labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/FormatFields.aj
Mon Feb  2 01:38:07 2009
@@ -18,11 +18,13 @@
 		&& cflow(rendering())
 		&& this(bean);
 	
+	private Object ret = null;
 	private String doreturn = null;
 
     after (MagmaBeanSupport bean) returning (Object val): calledForRendering(bean) {
     	BeanData beanData = bean.beanData();
     	PropertyInfo property = beanData.findProperty(((MethodSignature)thisJoinPointStaticPart.getSignature()).getMethod());
+    	ret = val;
     	if (property == null) {    		
     		return;
     	}
@@ -36,9 +38,10 @@
     	doreturn = property.toUser(val);
     }
     
-    Object around() : resolving() {
-    	Object unfiltered = proceed();
-    	if (doreturn != null) return doreturn;
+    Object around(Object acval) : call(* Object+.toString()) && withincode(* ASTReference.render(..))
&&
+    		target(acval) {
+    	Object unfiltered = proceed(acval);
+    	if (acval == ret && doreturn != null) return doreturn;
     	return unfiltered;
     }
 	

Modified: labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/FakeBean.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/FakeBean.java?rev=739900&r1=739899&r2=739900&view=diff
==============================================================================
--- labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/FakeBean.java
(original)
+++ labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/FakeBean.java
Mon Feb  2 01:38:07 2009
@@ -27,4 +27,7 @@
 		this.string = string;
 	}
 	
+	public FakeBean getMe() {
+		return this;
+	}
 }

Modified: labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/TestGettersFormatting.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/TestGettersFormatting.java?rev=739900&r1=739899&r2=739900&view=diff
==============================================================================
--- labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/TestGettersFormatting.java
(original)
+++ labs/magma/trunk/website-velocity/src/test/java/org/apache/magma/website/velocity/TestGettersFormatting.java
Mon Feb  2 01:38:07 2009
@@ -39,5 +39,18 @@
 		assertEquals("this is <b>bold</b>", str.trim());
 	}
 	
+	@Test
+	public void nested() throws Exception {
+		FakeBean fb = new FakeBean();
+		fb.setString("this is <b>bold</b>");
+		VelocityHtmlProducer prod = new VelocityHtmlProducer("testNested.vm");
+		prod.addParameter("bean", fb);
+		prod.setCreatingHandler(this);
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		prod.produce(baos);
+		String str = new String(baos.toByteArray(), "UTF-8");
+		assertEquals("this is &lt;b&gt;bold&lt;/b&gt;", str.trim());
+	}
+	
 
 }

Added: labs/magma/trunk/website-velocity/src/test/resources/org/apache/magma/website/velocity/testNested.vm
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-velocity/src/test/resources/org/apache/magma/website/velocity/testNested.vm?rev=739900&view=auto
==============================================================================
--- labs/magma/trunk/website-velocity/src/test/resources/org/apache/magma/website/velocity/testNested.vm
(added)
+++ labs/magma/trunk/website-velocity/src/test/resources/org/apache/magma/website/velocity/testNested.vm
Mon Feb  2 01:38:07 2009
@@ -0,0 +1 @@
+$bean.me.string
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message