labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r747409 - in /labs/magma/trunk: email-simulator/src/main/java/org/apache/magma/email/ foundation-i18n/src/test/java/org/apache/magma/i18n/ foundation-website/src/main/java/org/apache/magma/website/ foundation-website/src/main/java/org/apach...
Date Tue, 24 Feb 2009 16:08:13 GMT
Author: simoneg
Date: Tue Feb 24 16:08:03 2009
New Revision: 747409

URL: http://svn.apache.org/viewvc?rev=747409&view=rev
Log:
LABS-291 : all HtmlProducers now use writers instead of streams, CompoundHtmlProducer definitively
eliminated in favor of new compounding system

Modified:
    labs/magma/trunk/email-simulator/src/main/java/org/apache/magma/email/InstallEmailListInDeveloper.aj
    labs/magma/trunk/foundation-i18n/src/test/java/org/apache/magma/i18n/MatchingTest.java
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/HtmlProducer.java
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/CompoundHtmlProducer.java
    labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/StringHtmlProducer.java
    labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/FakeHtmlProducer.java
    labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/HtmlWithLinkProducer.java
    labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/InjectProducerFromAspect.aj
    labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/SimpleWebHandler.java
    labs/magma/trunk/maps-google/src/main/java/org/apache/magma/maps/google/MappedSmartListProducer.java
    labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InlineMenuProducer.java
    labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InterceptWebMethods.aj
    labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AbstractCrudHandler.java
    labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminSideMenuProducer.java
    labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminTopMenuProducer.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
    labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/VelocityHtmlProducer.java

Modified: labs/magma/trunk/email-simulator/src/main/java/org/apache/magma/email/InstallEmailListInDeveloper.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/email-simulator/src/main/java/org/apache/magma/email/InstallEmailListInDeveloper.aj?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/email-simulator/src/main/java/org/apache/magma/email/InstallEmailListInDeveloper.aj
(original)
+++ labs/magma/trunk/email-simulator/src/main/java/org/apache/magma/email/InstallEmailListInDeveloper.aj
Tue Feb 24 16:08:03 2009
@@ -1,15 +1,16 @@
 package org.apache.magma.email;
 
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.developer.DeveloperHandler;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 import org.apache.magma.website.velocity.VelocityHtmlProducer;
 
 public aspect InstallEmailListInDeveloper {
 
 	HtmlProducer around() : execution(HtmlProducer+ DeveloperHandler.doPanel()) {
 		HtmlProducer base = proceed();
-		return new CompoundHtmlProducer(base, new VelocityHtmlProducer("emailPanel"));
+		base.compoundWith(new VelocityHtmlProducer("emailPanel"), CompoundType.AFTER);
+		return base;
 	}
 	
 	public EmailHolderWebHandler DeveloperHandler.handleEmails() {

Modified: labs/magma/trunk/foundation-i18n/src/test/java/org/apache/magma/i18n/MatchingTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-i18n/src/test/java/org/apache/magma/i18n/MatchingTest.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-i18n/src/test/java/org/apache/magma/i18n/MatchingTest.java
(original)
+++ labs/magma/trunk/foundation-i18n/src/test/java/org/apache/magma/i18n/MatchingTest.java
Tue Feb 24 16:08:03 2009
@@ -78,7 +78,7 @@
 	@Test
 	public void betterMatchAsPerBug184() throws Exception {
 		SubRunningContext mc = RunningContext.get();
-		mc.push("CompoundHtmlProducer");
+		mc.push("BahHtmlProducer");
 		mc.push("BeanFormProducer");
 		mc.push("UserBean");
 		mc.push("BeanFormProducer");

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/HtmlProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/HtmlProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/HtmlProducer.java
(original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/HtmlProducer.java
Tue Feb 24 16:08:03 2009
@@ -16,9 +16,14 @@
  */
 package org.apache.magma.website;
 
+import org.apache.magma.basics.MagmaException;
 import org.apache.magma.website.templating.Template;
 
+import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
 
 
 public abstract class HtmlProducer extends Producer implements Templatable, CompoundableProducer
{
@@ -33,6 +38,24 @@
 	
 	public abstract void head(Head head);
 	
+	@Override
+	public final void produce(OutputStream stream) {
+		Writer writer = null;
+		try {
+			writer = new OutputStreamWriter(stream, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			throw new MagmaException(e, "Something is very wrong if we cannot find UTF-8");
+		}
+		try {
+			produce(writer);
+			writer.flush();
+		} catch (IOException e) {
+			throw new MagmaException(e, "Error sending output");
+		}
+	}
+	
+	public abstract void produce(Writer writer) throws IOException;
+	
 	public void setTemplate(Template t) {
 		this.template = t;
 	}

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/CompoundHtmlProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/CompoundHtmlProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/CompoundHtmlProducer.java
(original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/CompoundHtmlProducer.java
Tue Feb 24 16:08:03 2009
@@ -21,7 +21,9 @@
 import org.apache.magma.website.templating.Template;
 import org.apache.magma.website.utils.URLRewritingStream;
 
+import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -62,6 +64,7 @@
 		}
 	}
 
+/*
 	@Override
 	public void produce(OutputStream stream) {
 		String prebase = null;
@@ -78,12 +81,16 @@
 			((URLRewritingStream)stream).setBaseUrl(prebase);
 		}
 	}
-	
+*/	
 	@Override
 	public Template getTemplate() {
 		if (super.template != null) return super.getTemplate();
 		if (this.producers.size() > 0) return this.producers.get(0).getTemplate();
 		return super.getTemplate();
 	}
+	
+	@Override
+	public void produce(Writer writer) throws IOException {
+	}
 
 }

Modified: labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/StringHtmlProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/StringHtmlProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/StringHtmlProducer.java
(original)
+++ labs/magma/trunk/foundation-website/src/main/java/org/apache/magma/website/producers/StringHtmlProducer.java
Tue Feb 24 16:08:03 2009
@@ -19,7 +19,9 @@
 import org.apache.magma.website.Head;
 import org.apache.magma.website.HtmlProducer;
 
+import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Writer;
 
 public class StringHtmlProducer extends HtmlProducer {
 
@@ -46,10 +48,10 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
-		if (body != null) stream.write(body.getBytes("UTF-8"));
+	public void produce(Writer writer) throws IOException {
+		writer.append(this.body);
 	}
-
+	
 	public String getHeads() {
 		return heads;
 	}

Modified: labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/FakeHtmlProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/FakeHtmlProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/FakeHtmlProducer.java
(original)
+++ labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/FakeHtmlProducer.java
Tue Feb 24 16:08:03 2009
@@ -26,6 +26,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Writer;
 
 
 public class FakeHtmlProducer extends ParametrizableHtmlProducerBase {
@@ -43,25 +44,21 @@
 		return instance;
 	}
 
-	public void produce(OutputStream stream) {
-		try {
-			String str = "[";
-			str += getCreatingMethod().getDeclaringClass().getSimpleName();
-			str += ".";
-			str += getCreatingMethod().getName();
-			str += "]";
-			I18nRenderingHelper i18nh = (I18nRenderingHelper) getParameters().getParameters().get("i18n");
-			str += i18nh.tr("test message");
-			if (params != null && params.length > 0) {
-				str += "(" + params[0] + ")";
-			}
-			stream.write(str.getBytes());
-		} catch (IOException e) {
-			throw new MagmaException(e, "Error writing output");
+	@Override
+	public void produce(Writer writer) throws IOException {
+		String str = "[";
+		str += getCreatingMethod().getDeclaringClass().getSimpleName();
+		str += ".";
+		str += getCreatingMethod().getName();
+		str += "]";
+		I18nRenderingHelper i18nh = (I18nRenderingHelper) getParameters().getParameters().get("i18n");
+		str += i18nh.tr("test message");
+		if (params != null && params.length > 0) {
+			str += "(" + params[0] + ")";
 		}
+		writer.append(str);
 	}
-
-
+	
 	public Object[] getParams() {
 		return params;
 	}

Modified: labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/HtmlWithLinkProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/HtmlWithLinkProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/HtmlWithLinkProducer.java
(original)
+++ labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/HtmlWithLinkProducer.java
Tue Feb 24 16:08:03 2009
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.Writer;
 import java.util.List;
 
 import org.apache.magma.basics.MagmaException;
@@ -20,13 +21,8 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
-		try {
-			String str = "<a href=\"inside\"/><a href=\"magma:/base\"/><a href=\"http://absolute.com/\"/>";
-			stream.write(str.getBytes());
-		} catch (IOException e) {
-			throw new MagmaException(e, "Error writing output");
-		}
+	public void produce(Writer writer) throws IOException {
+		writer.append("<a href=\"inside\"/><a href=\"magma:/base\"/><a href=\"http://absolute.com/\"/>");
 	}
 
 }

Modified: labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/InjectProducerFromAspect.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/InjectProducerFromAspect.aj?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/InjectProducerFromAspect.aj
(original)
+++ labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/InjectProducerFromAspect.aj
Tue Feb 24 16:08:03 2009
@@ -1,20 +1,20 @@
 package org.apache.magma.website.teststuff;
 
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HtmlProducer;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 
 public aspect InjectProducerFromAspect {
 
-	CompoundHtmlProducer around() : execution(CompoundHtmlProducer SimpleWebHandler.doTestAspectInjection())
{
-		CompoundHtmlProducer orig = proceed();
+	HtmlProducer around() : execution(HtmlProducer SimpleWebHandler.doTestAspectInjection())
{
+		HtmlProducer orig = proceed();
 		HtmlProducer added = new FakeHtmlProducer();
-		orig.addProducer(added);
+		orig.compoundWith(added, CompoundType.AFTER);
 		return orig;
 	}
 
-	after() returning(CompoundHtmlProducer orig) : execution(CompoundHtmlProducer SimpleWebHandler.doTestAspectInjection())
{
+	after() returning(HtmlProducer orig) : execution(HtmlProducer SimpleWebHandler.doTestAspectInjection())
{
 		HtmlProducer added = new FakeHtmlProducer();
-		orig.addProducer(added);
+		orig.compoundWith(added, CompoundType.AFTER);
 	}
 	
 }

Modified: labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/SimpleWebHandler.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/SimpleWebHandler.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/SimpleWebHandler.java
(original)
+++ labs/magma/trunk/foundation-website/src/test/java/org/apache/magma/website/teststuff/SimpleWebHandler.java
Tue Feb 24 16:08:03 2009
@@ -18,7 +18,6 @@
 
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.WebHandler;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 
 public class SimpleWebHandler extends WebHandler {
 
@@ -130,7 +129,7 @@
 		return null;
 	}
 	
-	public CompoundHtmlProducer doTestAspectInjection() {
-		return new CompoundHtmlProducer(new FakeHtmlProducer());
+	public HtmlProducer doTestAspectInjection() {
+		return new FakeHtmlProducer();
 	}
 }

Modified: labs/magma/trunk/maps-google/src/main/java/org/apache/magma/maps/google/MappedSmartListProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/maps-google/src/main/java/org/apache/magma/maps/google/MappedSmartListProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/maps-google/src/main/java/org/apache/magma/maps/google/MappedSmartListProducer.java
(original)
+++ labs/magma/trunk/maps-google/src/main/java/org/apache/magma/maps/google/MappedSmartListProducer.java
Tue Feb 24 16:08:03 2009
@@ -39,17 +39,17 @@
 		head.addDoOnload("mappize");
 		super.head(head);
 	}
-	
+
 	@Override
-	public void produce(OutputStream stream) {
-		stream.write("<div class=\"MagmaGoogleMapsList\">".getBytes("UTF-8"));
+	public void produce(Writer stream) throws IOException {
+		stream.write("<div class=\"MagmaGoogleMapsList\">");
 		super.produce(stream);
 		sendPrototype(stream);
-		stream.write("</div>".getBytes("UTF-8"));		
+		stream.write("</div>");		
 	}
-
-	protected void sendPrototype(OutputStream stream) throws IOException {
-		stream.write(prototype.getBytes("UTF-8"));
+	
+	protected void sendPrototype(Writer stream) throws IOException {
+		stream.write(prototype);
 	}
 
 	@Override

Modified: labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InlineMenuProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InlineMenuProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InlineMenuProducer.java
(original)
+++ labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InlineMenuProducer.java
Tue Feb 24 16:08:03 2009
@@ -1,7 +1,9 @@
 package org.apache.magma.website.admin;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -28,8 +30,7 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
-		OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
+	public void produce(Writer osw) throws IOException {
 		osw.write("<ul class=\"MagmaInlineAdminMenu\">");
 		for (Map.Entry<Object, List<AdminAction>> entry : founds.entrySet()) {
 			Object key = entry.getKey();
@@ -53,7 +54,6 @@
 			super.renderActions(entry.getValue(), (key instanceof Class ? null : key), osw);
 		}
 		osw.write("</ul>");
-		osw.flush();
 	}
 
 }

Modified: labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InterceptWebMethods.aj
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InterceptWebMethods.aj?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InterceptWebMethods.aj
(original)
+++ labs/magma/trunk/website-administration-inline/src/main/java/org/apache/magma/website/admin/InterceptWebMethods.aj
Tue Feb 24 16:08:03 2009
@@ -8,12 +8,12 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HandlerSetup;
 import org.apache.magma.website.RootWebHandler;
 import org.apache.magma.website.WebHandler;
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.Producer;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 import org.apache.magma.website.producers.ParametrizableProducer;
 import org.apache.magma.website.producers.ProducerParameters;
 import org.aspectj.lang.reflect.MethodSignature;
@@ -56,10 +56,7 @@
 			}
 			if (founds.size() > 0) {
 				AdminWebHandler awe = RootWebHandler.getInstance().handleAdministration();
-				ret = new CompoundHtmlProducer((HtmlProducer)ret, awe.hiddenInlineMenu(founds));
-				// TODO remove this, see LABS-257
-				//((HtmlProducer)ret).setCreatingHandler((WebHandler)thisJoinPoint.getThis());
-				//((HtmlProducer)ret).setCreatingMethod(((MethodSignature)thisJoinPoint.getSignature()).getMethod());
+				((HtmlProducer)ret).compoundWith(awe.hiddenInlineMenu(founds), CompoundType.AFTER);
 				return ret;
 			}
 		}

Modified: labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AbstractCrudHandler.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AbstractCrudHandler.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AbstractCrudHandler.java
(original)
+++ labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AbstractCrudHandler.java
Tue Feb 24 16:08:03 2009
@@ -4,12 +4,12 @@
 import org.apache.magma.basics.MagmaException;
 import org.apache.magma.database.Database;
 import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.WebHandler;
 import org.apache.magma.website.beansview.ShowBean;
 import org.apache.magma.website.beansview.SmartForm;
 import org.apache.magma.website.beansview.SmartList;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 import org.apache.magma.website.producers.StringHtmlProducer;
 
 public class AbstractCrudHandler<T> extends WebHandler {
@@ -40,8 +40,11 @@
 	}
 	
 	protected HtmlProducer doShow(T bean) {
-		HtmlProducer header = new StringHtmlProducer("<h1>" + new LocalizableString("Display
" +  myclass.getSimpleName()).toString() + "</h1>");
-		return new CompoundHtmlProducer(header, new ShowBean(bean, showCustomizer));
+		HtmlProducer ret = new ShowBean(bean, showCustomizer);
+		ret.compoundWith(
+				new StringHtmlProducer("<h1>" + new LocalizableString("Display " +  myclass.getSimpleName()).toString()
+ "</h1>")
+				, CompoundType.HEAD);
+		return ret;
 	}
 	
 	protected HtmlProducer doDelete(T bean) {

Modified: labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminSideMenuProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminSideMenuProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminSideMenuProducer.java
(original)
+++ labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminSideMenuProducer.java
Tue Feb 24 16:08:03 2009
@@ -1,7 +1,9 @@
 package org.apache.magma.website.admin;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.util.List;
 
 import org.apache.magma.basics.LocalizableString;
@@ -31,15 +33,13 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
-		OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
+	public void produce(Writer osw) throws IOException {
 		osw.write("<h1>");
 		osw.write(new LocalizableString(beanClass.getSimpleName()).toString());
 		osw.write("</h1>");
 		osw.write("<div id=\"MagmaAdminSideMenu\"><ul>");
 		super.renderActions(actions, bean, osw);
 		osw.write("</ul></div>");
-		osw.flush();
 	}
 
 }

Modified: labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminTopMenuProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminTopMenuProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminTopMenuProducer.java
(original)
+++ labs/magma/trunk/website-administration/src/main/java/org/apache/magma/website/admin/AdminTopMenuProducer.java
Tue Feb 24 16:08:03 2009
@@ -1,8 +1,10 @@
 package org.apache.magma.website.admin;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
+import java.io.Writer;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -31,8 +33,7 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
-		OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
+	public void produce(Writer osw) throws IOException {
 		osw.write("<div id=\"MagmaAdminMenu\">");
 		osw.write("<ul id=\"MagmaAdminMenuMains\" class=\"MagmaAdminMenuRow\">");
 		renderActions(main, null, osw);
@@ -46,7 +47,6 @@
 		}
 		osw.write("</ul>");
 		osw.write("</div>");
-		osw.flush();
 	}
 
 }

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
Tue Feb 24 16:08:03 2009
@@ -65,13 +65,12 @@
 	}
 	
 	@Override
-	public void produce(OutputStream stream) {
-		OutputStreamWriter out = new OutputStreamWriter(stream, "UTF-8");
+	public void produce(Writer out) throws IOException {
 		try {
 			out.write("<form action=\"filled\" method=\"POST\" accept-charset=\"utf-8\"><div>");
 			out.write("<input type=\"submit\" class=\"DefaultHiddenSubmit\" value=\"-\"/>");
 			out.flush();
-			super.produce(stream);
+			super.produce(out);
 			if (actions != null) {
 				int i = 0;
 				for (FormAction action : this.actions) {
@@ -82,7 +81,6 @@
 				}
 			}
 			out.write("</div></form>");
-			out.flush();
 		} catch (IOException e) {
 			throw new MagmaException(e, "Error writing to output");
 		}

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
Tue Feb 24 16:08:03 2009
@@ -59,7 +59,7 @@
 	}
 	
 	@Override
-	public void produce(OutputStream stream) {
+	public void produce(Writer writer) throws IOException {
 		Node root = bean.beanData().getViewTree(this.filter);
 		if (root.getAllNodes().size() == 1) throw new MagmaException("Cannot display {0}, seems
like no @View elements are present or they are not correctly connected to each other correctly
using @Order, @Zone etc..", bean.getClass());
 		StringWriter tables = new StringWriter();
@@ -76,9 +76,7 @@
 		fullform = fullform.replaceFirst("<table", "<table id=\"" + bean.getClass().getSimpleName()
+ "-table\"");
 		fullform = fullform.replaceAll(">\\|MAGMA-([^\\|]*)\\|"," $1>");
 		fullform = fullform.replaceAll("<td([^>]*)></td>", "<td$1>&nbsp;</td>");
-		OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
-		osw.write(fullform);
-		osw.flush();
+		writer.write(fullform);
 	}
 
 	protected void createTable(Node node, Writer out) throws IOException {

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
Tue Feb 24 16:08:03 2009
@@ -80,7 +80,7 @@
 	}
 	
 	@Override
-	public void produce(OutputStream stream) {
+	public void produce(Writer tables) throws IOException {
 		if (this.link != null) {
 			GenericClass gc = GenericClass.forClass(getCreatingHandler().getClass());
 			List<MethodDef> methods = gc.findMethods(this.link, new Class<?>[] { this.myclass
});
@@ -108,14 +108,12 @@
 				
 		Node root = BeanData.getFor(myclass).getViewListTree(this.filter);
 		if (root.getAllNodes().size() == 1) throw new MagmaException("Cannot create list for {0},
seems like no @Listed elements are present or they are not correctly connected to each other
to form a proper list", myclass);
-		OutputStreamWriter tables = new OutputStreamWriter(stream, "UTF-8");
 		try {
 			openOuterTable(root, tables);
 			createHeader(root, tables);
 			createBody(root, tables);
 			createFooter(root, tables);
 			closeOuterTable(root, tables);
-			tables.flush();
 		} catch (UnsupportedEncodingException e) {
 			// Should never happen
 			throw new MagmaException(e, "Something is extremely wrong if we cannot find UTF-8");

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
Tue Feb 24 16:08:03 2009
@@ -29,9 +29,9 @@
 import org.apache.magma.view.tree.Node;
 import org.apache.magma.view.tree.ViewCustomizer;
 import org.apache.magma.view.tree.ViewUtils;
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.WebHandler;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 import org.apache.magma.website.producers.ParametrizableProducer;
 
 import java.lang.reflect.Method;
@@ -108,7 +108,9 @@
 		BeanFormProducer producer = new BeanFormProducer(this.bean, errors, this.filter, getMyCode());
 		producer.setActions(this.actions);
 		producer.setLists(this.lists);
-		return new CompoundHtmlProducer(header, producer, footer);
+		producer.compoundWith(header, CompoundType.BEFORE);
+		producer.compoundWith(footer, CompoundType.AFTER);
+		return producer;
 	}
 	
 	public HtmlProducer doWorking() {

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
Tue Feb 24 16:08:03 2009
@@ -19,9 +19,9 @@
 import org.apache.magma.view.tree.Node;
 import org.apache.magma.view.tree.PropertyNode;
 import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.website.CompoundType;
 import org.apache.magma.website.HtmlProducer;
 import org.apache.magma.website.WebHandler;
-import org.apache.magma.website.producers.CompoundHtmlProducer;
 import org.apache.magma.website.producers.ParametrizableProducer;
 
 public class SmartList extends WebHandler {
@@ -141,7 +141,9 @@
 		producer.setLink("../" + this.linkUrl);
 		producer.setFilter(filter);
 		producer.setCaption(caption).setSummary(summary);
-		return new CompoundHtmlProducer(header, producer, footer);
+		producer.compoundWith(header, CompoundType.BEFORE);
+		producer.compoundWith(footer, CompoundType.AFTER);
+		return producer;
 	}
 	
 	protected void checkSortables() {

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
Tue Feb 24 16:08:03 2009
@@ -95,15 +95,15 @@
 	}
 
 	@Override
-	public void produce(OutputStream stream) {
+	public void produce(Writer tables) throws IOException {
 		String pagination = createPagination();
-		stream.write("<div class=\"MagmaPagination BeforeList\">".getBytes("UTF-8"));
-		stream.write(pagination.getBytes("UTF-8"));
-		stream.write("</div>".getBytes("UTF-8"));		
-		super.produce(stream);
-		stream.write("<div class=\"MagmaPagination AfterList\">".getBytes("UTF-8"));
-		stream.write(pagination.getBytes("UTF-8"));
-		stream.write("</div>".getBytes("UTF-8"));		
+		tables.append("<div class=\"MagmaPagination BeforeList\">");
+		tables.append(pagination);
+		tables.append("</div>");		
+		super.produce(tables);
+		tables.append("<div class=\"MagmaPagination AfterList\">");
+		tables.append(pagination);
+		tables.append("</div>");		
 	}
 	
 	

Modified: labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/VelocityHtmlProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/VelocityHtmlProducer.java?rev=747409&r1=747408&r2=747409&view=diff
==============================================================================
--- labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/VelocityHtmlProducer.java
(original)
+++ labs/magma/trunk/website-velocity/src/main/java/org/apache/magma/website/velocity/VelocityHtmlProducer.java
Tue Feb 24 16:08:03 2009
@@ -22,10 +22,13 @@
 import org.apache.magma.website.producers.ParametrizableHtmlProducerBase;
 
 import java.beans.Introspector;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
 import java.net.URL;
 import java.nio.charset.Charset;
 import java.util.HashMap;
@@ -59,7 +62,8 @@
 	
 	private String template;
 
-	public void produce(OutputStream stream) {
+	@Override
+	public void produce(Writer writer) throws IOException {
 		String tplname = this.template;
 		if (tplname == null && this.parameters != null) {
 			tplname = parameters.getTemplateName();
@@ -69,9 +73,9 @@
 		if (!tplname.endsWith(".vm")) tplname += ".vm";
 		
 		
-		sendTemplate(stream, tplname, null);
+		sendTemplate(writer, tplname, null);
 	}
-
+	
 	private boolean sendTemplateIfExisting(OutputStream stream, String tplname, Map<String,
Object> additional) {
 		if (parameters != null && getCreatingHandler() != null) {
 			URL resource = getCreatingHandler().getClass().getResource(tplname);
@@ -86,8 +90,24 @@
 		}
 		return false;
 	}
-	
+
 	private void sendTemplate(OutputStream stream, String tplname, Map<String, Object>
additional) {
+		OutputStreamWriter ow;
+		try {
+			ow = new OutputStreamWriter(stream, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			throw new MagmaException(e, "Something is very wrong if we cannot find UTF-8");
+		}
+		try {
+			sendTemplate(ow, tplname, additional);
+			ow.flush();
+		} catch (IOException e) {
+			throw new MagmaException(e, "Error sending velocity template");
+		}
+	}
+	
+	
+	private void sendTemplate(Writer writer, String tplname, Map<String, Object> additional)
{
 		VelocityContext ctx = new VelocityContext();
 		if (parameters != null) {
 			Map<String, Object> map = parameters.getParameters();
@@ -101,15 +121,12 @@
 			}
 		}
 		
-		OutputStreamWriter writer = new OutputStreamWriter(stream, Charset.forName("UTF-8"));
-		
 		if (parameters != null && getCreatingHandler() != null) {
 			InputStream inputStream = getCreatingHandler().getClass().getResourceAsStream(tplname);
 			if (inputStream != null) {
 				InputStreamReader inreader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
 				try {
 					Velocity.evaluate(ctx, writer, tplname, inreader);
-					writer.flush();
 					return;
 				} catch (Throwable e) {
 					throw new MagmaException(e, "Error executing template {0} loaded from resource {1}",
tplname, getCreatingHandler().getClass().getResource(tplname));
@@ -119,7 +136,6 @@
 		
 		try {
 			Velocity.mergeTemplate(tplname, "UTF-8", ctx, writer);
-			writer.flush();
 		} catch (Exception e) {
 			throw new MagmaException(e, "Error executing velocity template {0} loaded by default velocity
loader", tplname);
 		}



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


Mime
View raw message