tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1181321 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
Date Tue, 11 Oct 2011 00:43:32 GMT
Author: hlship
Date: Tue Oct 11 00:43:31 2011
New Revision: 1181321

URL: http://svn.apache.org/viewvc?rev=1181321&view=rev
Log:
Use the OperationTracker to identify which page is being loaded

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java?rev=1181321&r1=1181320&r2=1181321&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java
Tue Oct 11 00:43:31 2011
@@ -27,6 +27,7 @@ import org.apache.tapestry5.func.Predica
 import org.apache.tapestry5.internal.services.ComponentInstantiatorSource;
 import org.apache.tapestry5.internal.services.PageSource;
 import org.apache.tapestry5.internal.structure.Page;
+import org.apache.tapestry5.ioc.OperationTracker;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
@@ -76,6 +77,9 @@ public class PageCatalog
     private String pageName;
 
     @Inject
+    private OperationTracker operationTracker;
+
+    @Inject
     private ComponentInstantiatorSource componentInstantiatorSource;
 
     public List<String> getPageNames()
@@ -136,6 +140,13 @@ public class PageCatalog
         return pagesZone.getBody();
     }
 
+    private class PageLoadData
+    {
+        int loadedCount;
+        RuntimeException fail;
+        boolean someFail;
+    }
+
     Object onActionFromForceLoad()
     {
         if (failures == null)
@@ -145,57 +156,62 @@ public class PageCatalog
 
         long startTime = System.currentTimeMillis();
 
-        Collection<Page> initialPages = getPages();
-
-        int loadedCount = 0;
-
-        RuntimeException fail = null;
+        final Collection<Page> initialPages = getPages();
 
-        boolean someFail = false;
+        final PageLoadData data = new PageLoadData();
 
-        for (String name : resolver.getPageNames())
+        for (final String name : resolver.getPageNames())
         {
             if (failures.contains(name))
             {
                 alertManager.warn(String.format("Skipping page %s due to prior load failure.",
name));
-                someFail = true;
+                data.someFail = true;
                 continue;
             }
 
-            try
+            operationTracker.run("Loading page " + name, new Runnable()
             {
-                Page newPage = pageSource.getPage(name);
-
-                if (!initialPages.contains(newPage))
-                {
-                    loadedCount++;
-                }
-            } catch (RuntimeException ex)
-            {
-                alertManager.error(String.format("Page %s failed to load.", name));
-                failures.add(name);
-
-                if (fail == null)
+                public void run()
                 {
-                    pageName = name;
-                    fail = ex;
+                    try
+                    {
+                        Page newPage = pageSource.getPage(name);
+
+                        if (!initialPages.contains(newPage))
+                        {
+                            data.loadedCount++;
+                        }
+                    } catch (RuntimeException ex)
+                    {
+                        alertManager.error(String.format("Page %s failed to load.", name));
+                        failures.add(name);
+
+                        if (data.fail == null)
+                        {
+                            pageName = name;
+                            data.fail = ex;
+                        }
+                    }
                 }
+            });
 
+            if (data.fail != null)
+            {
                 break;
             }
         }
 
-        alertManager.info(String.format("Loaded %,d new pages for selector '%s' (in %,d ms).",
loadedCount,
+        alertManager.info(String.format("Loaded %,d new pages for selector '%s' (in %,d ms).",
data.loadedCount,
                 selector.toShortString(), System.currentTimeMillis() - startTime));
 
-        if (someFail)
+        if (data.someFail)
         {
             alertManager.warn("Clear the cache to reset the list of failed pages.");
         }
 
-        if (fail != null)
+        if (data.fail != null)
         {
-            throw fail;
+            throw data.fail;
         }
 
         return pagesZone.getBody();



Mime
View raw message