Author: hlship Date: Wed Oct 26 22:10:50 2011 New Revision: 1189502 URL: http://svn.apache.org/viewvc?rev=1189502&view=rev Log: TAP5-1727: PageCatalog page can fail with an odd ClassCastException
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/PageCatalogTotals.java Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/PageCatalog.java tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PageCatalog.tml 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=1189502&r1=1189501&r2=1189502&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 Wed Oct 26 22:10:50 2011 @@ -18,10 +18,10 @@ import org.apache.tapestry5.SymbolConsta import org.apache.tapestry5.alerts.AlertManager; import org.apache.tapestry5.annotations.*; import org.apache.tapestry5.beaneditor.BeanModel; -import org.apache.tapestry5.beaneditor.ReorderProperties; import org.apache.tapestry5.beaneditor.Validate; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.func.*; +import org.apache.tapestry5.internal.PageCatalogTotals; import org.apache.tapestry5.internal.services.ComponentInstantiatorSource; import org.apache.tapestry5.internal.services.PageSource; import org.apache.tapestry5.internal.structure.Page; @@ -47,32 +47,9 @@ import java.util.Set; @WhitelistAccessOnly public class PageCatalog { - @ReorderProperties("definedPages,loadedPages,uniquePageNames,selectors,components") - public class Totals - { - /** - * Total number of pages loaded. - */ - public int loadedPages; - - /** - * Number of total page names. - */ - public int definedPages; - /** - * Number of unique page names (remember, same page may appear for multiple selectors). - */ - public int uniquePageNames; - /** - * Total number of components. - */ - public int components; - - /** - * All selectors represented in the pool, often just 'en'. - */ - public String selectors; - } + + @Property + private PageCatalogTotals totals; @Property @Inject @@ -133,17 +110,15 @@ public class PageCatalog model.reorder("name", "selector", "assemblyTime", "componentCount", "weight"); } - @Cached - public Totals getTotals() + public void onRecomputeTotals() { - - Totals result = new Totals(); + totals = new PageCatalogTotals(); Flow<Page> pages = F.flow(getPages()); - result.loadedPages = pages.count(); - result.definedPages = getPageNames().size(); - result.uniquePageNames = pages.map(new Mapper<Page, String>() + totals.loadedPages = pages.count(); + totals.definedPages = getPageNames().size(); + totals.uniquePageNames = pages.map(new Mapper<Page, String>() { public String map(Page element) { @@ -151,7 +126,7 @@ public class PageCatalog } }).toSet().size(); - result.components = pages.reduce(new Reducer<Integer, Page>() + totals.components = pages.reduce(new Reducer<Integer, Page>() { public Integer reduce(Integer accumulator, Page element) { @@ -167,10 +142,7 @@ public class PageCatalog } }).toSet(); - result.selectors = InternalUtils.joinSorted(selectorIds); - - return result; - + totals.selectors = InternalUtils.joinSorted(selectorIds); } public List<String> getPageNames() Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/PageCatalogTotals.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/PageCatalogTotals.java?rev=1189502&view=auto ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/PageCatalogTotals.java (added) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/PageCatalogTotals.java Wed Oct 26 22:10:50 2011 @@ -0,0 +1,47 @@ +// Copyright 2011 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.internal; + +import org.apache.tapestry5.beaneditor.ReorderProperties; + +/** + * @see org.apache.tapestry5.corelib.pages.PageCatalog + */ +@ReorderProperties("definedPages,loadedPages,uniquePageNames,selectors,components") +public class PageCatalogTotals +{ + /** + * Total number of pages loaded. + */ + public int loadedPages; + + /** + * Number of total page names. + */ + public int definedPages; + /** + * Number of unique page names (remember, same page may appear for multiple selectors). + */ + public int uniquePageNames; + /** + * Total number of components. + */ + public int components; + + /** + * All selectors represented in the pool, often just 'en'. + */ + public String selectors; +} Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PageCatalog.tml URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PageCatalog.tml?rev=1189502&r1=1189501&r2=1189502&view=diff ============================================================================== --- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PageCatalog.tml (original) +++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/PageCatalog.tml Wed Oct 26 22:10:50 2011 @@ -33,7 +33,9 @@ This page provides a list of pages currently loaded in the application. </p> - <t:beandisplay object="totals"/> + <t:trigger event="recomputeTotals"/> + + <t:beandisplay t:id="totals"/> <t:grid source="pages" row="page" model="model"> <p:assemblyTimeCell>