Author: jkuhnert
Date: Mon May 14 07:09:01 2007
New Revision: 537849

URL: http://svn.apache.org/viewvc?view=rev&rev=537849
Log:
-) Shell component was needlessly buffering / delaying writing of important 
content like stylesheets / js inclusions / etc when there is no need to for the 
Relation / Style components.  Refactored to write this important content as 
early as possible as it does have a huge performance impact on the client 
side.. Even with a partial stream of output coming in to render a page most 
browsers will agressively download all js / style includes they see as soon as 
they see them. 

-) The renderTime being captured by Shell was wrong. ..It was only measuring 
how long it took to render its own content instead of the entire response. 
Fixed that so people have realisitic numbers to look at.

Modified:
    
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Relation.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.java

Modified: 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application?view=diff&rev=537849&r1=537848&r2=537849
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application
 Mon May 14 07:09:01 2007
@@ -27,8 +27,4 @@
 
     <library id="contrib" 
specification-path="classpath:/org/apache/tapestry/contrib/Contrib.library"/>
 
-    <!--
-    <component-type type="Locale" 
specification-path="classpath:/org/apache/tapestry/timetracker/component/Locale.jwc"
 />
-    -->
-
 </application>

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Relation.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Relation.java?view=diff&rev=537849&r1=537848&r2=537849
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Relation.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Relation.java
 Mon May 14 07:09:01 2007
@@ -13,9 +13,6 @@
 // limitations under the License.
 package org.apache.tapestry.html;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.tapestry.AbstractComponent;
 import org.apache.tapestry.IAsset;
@@ -24,6 +21,9 @@
 import org.apache.tapestry.markup.MarkupWriterSource;
 import org.apache.tapestry.util.ContentType;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
 /**
  * Works with the [EMAIL PROTECTED] Shell} component to define and append a 
  * relationship between documents (typically a stylesheet) to 
@@ -64,8 +64,7 @@
         Object href = getHref();
         boolean ok = (href instanceof String) || (href instanceof IAsset);     
       
         if (!ok)
-            throw new ApplicationRuntimeException(
-                HTMLMessages.stringOrIAssetExpected(),
+            throw new 
ApplicationRuntimeException(HTMLMessages.stringOrIAssetExpected(),
                 this.getLocation(), null); 
                 
         String url;
@@ -77,15 +76,15 @@
         {
             url = ((IAsset)href).buildURL();
         }
-                
-        RelationBean bean = new RelationBean();           
+        
+        RelationBean bean = new RelationBean();
         bean.setHref(url);
         bean.setMedia(getMedia());
         bean.setRel(getRel());
         bean.setRev(getRev());
         bean.setTitle(getTitle());
         bean.setType(getType());
-        shell.addRelation(bean);        
+        shell.addRelation(bean); 
     }   
     
     protected void renderStyleTag(Shell shell, IMarkupWriter writer, 
IRequestCycle cycle)
@@ -94,11 +93,14 @@
         {
             return;
         }
+        
         StringWriter sWriter = new StringWriter();
         IMarkupWriter nested = getMarkupWriterSource().newMarkupWriter(new 
PrintWriter(sWriter),
                 new ContentType(writer.getContentType()));
+        
         nested.begin("style");
         nested.attribute("type", "text/css");
+        
         if (getMedia()!=null)
             nested.attribute("media", getMedia());
         if (getTitle()!=null)

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.java?view=diff&rev=537849&r1=537848&r2=537849
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/html/Shell.java
 Mon May 14 07:09:01 2007
@@ -14,26 +14,19 @@
 
 package org.apache.tapestry.html;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.hivemind.HiveMind;
-import org.apache.tapestry.AbstractComponent;
-import org.apache.tapestry.IAsset;
-import org.apache.tapestry.IMarkupWriter;
-import org.apache.tapestry.IPage;
-import org.apache.tapestry.IRender;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.Tapestry;
-import org.apache.tapestry.TapestryUtils;
+import org.apache.tapestry.*;
 import org.apache.tapestry.coerce.ValueConverter;
 import org.apache.tapestry.engine.IEngineService;
 import org.apache.tapestry.engine.ILink;
 import org.apache.tapestry.spec.IApplicationSpecification;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * Component for creating a standard 'shell' for a page, which comprises the 
&lt;html&gt; and
  * &lt;head&gt; portions of the page. [ <a
@@ -55,30 +48,23 @@
     {
         TapestryUtils.storeUniqueAttribute(cycle, SHELL_ATTRIBUTE, this);
         
-        long startTime = 0;
-
+        long startTime = System.currentTimeMillis();
         boolean rewinding = cycle.isRewinding();
-        
-        IMarkupWriter nested = writer.getNestedWriter();
-        // Render the body, the actual page content        
-        renderBody(nested, cycle);
 
         if (!rewinding)
         {
-            startTime = System.currentTimeMillis();
-
             writeDocType(writer, cycle);
 
             IPage page = getPage();
-            
+
             if (!isDisableTapestryMeta()) {
-                
+
                 writer.comment("Application: " + 
getApplicationSpecification().getName());
 
                 writer.comment("Page: " + page.getPageName());
                 writer.comment("Generated: " + new Date());
             }
-            
+
             writer.begin("html");
             writer.println();
             writer.begin("head");
@@ -86,57 +72,66 @@
 
             if (!isDisableTapestryMeta())
                 writeMetaTag(writer, "name", "generator", GENERATOR_CONTENT);
-            
+
             if (isDisableCaching())
                 writeMetaTag(writer, "http-equiv", "content", "no-cache");
-            
+
             if (getRenderContentType())
                 writeMetaTag(writer, "http-equiv", "Content-Type", 
writer.getContentType());
-            
+
+            writeRefresh(writer, cycle);
+
             if (getRenderBaseTag())
                 getBaseTagWriter().render(writer, cycle);
-            
+
             writer.begin("title");
-            
-            writer.print(getTitle(), getRaw());               
+
+            writer.print(getTitle(), getRaw());
             writer.end(); // title
             writer.println();
-            
+
             IRender delegate = getDelegate();
-            
+
             if (delegate != null)
                 delegate.render(writer, cycle);
-            
+
             IRender ajaxDelegate = getAjaxDelegate();
-            
+
             if (ajaxDelegate != null)
                 ajaxDelegate.render(writer, cycle);
             
-            List relations = getRelations();
-            if (relations != null)
-                writeRelations(writer, relations); 
-            
-            StringBuffer additionalContent = getContentBuffer();
-            if (additionalContent != null)
-                writer.printRaw(additionalContent.toString());
-            
             IAsset stylesheet = getStylesheet();
-            
+
             if (stylesheet != null)
                 writeStylesheetLink(writer, cycle, stylesheet);
-            
+
             Iterator i = (Iterator) getValueConverter().coerceValue(
                     getStylesheets(),
                     Iterator.class);
-            
+
             while (i.hasNext())
             {
                 stylesheet = (IAsset) i.next();
 
                 writeStylesheetLink(writer, cycle, stylesheet);
             }
+        }
+
+        // Render the body, the actual page content
+
+        IMarkupWriter nested = writer.getNestedWriter();
+
+        renderBody(nested, cycle);
+
+        if (!rewinding)
+        {
+            List relations = getRelations();
+            if (relations != null)
+                writeRelations(writer, relations); 
             
-            writeRefresh(writer, cycle);
+            StringBuffer additionalContent = getContentBuffer();
+            if (additionalContent != null)
+                writer.printRaw(additionalContent.toString());
             
             writer.end(); // head
         }


Reply via email to