Move HibernateStatitics page into the core library
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/991afc83 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/991afc83 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/991afc83 Branch: refs/heads/master Commit: 991afc836263227e5291bb268b91c84994bbe9cf Parents: 3fe2242 Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Apr 22 17:00:48 2013 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Apr 22 17:00:48 2013 -0700 ---------------------------------------------------------------------- .../corelib/pages/HibernateStatistics.java | 87 ++++++++++++++ .../tapestry5/hibernate/HibernateModule.java | 15 +-- .../t5internal/pages/HibernateStatistics.java | 91 --------------- .../hibernate/t5internal/pages/package-info.java | 19 --- .../corelib/pages/HibernateStatistics.properties | 15 +++ .../corelib/pages/HibernateStatistics.tml | 69 +++++++++++ .../pages/HibernateStatistics.properties | 15 --- .../t5internal/pages/HibernateStatistics.tml | 69 ----------- 8 files changed, 174 insertions(+), 206 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/java/org/apache/tapestry5/corelib/pages/HibernateStatistics.java ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/corelib/pages/HibernateStatistics.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/corelib/pages/HibernateStatistics.java new file mode 100644 index 0000000..fb2cfcb --- /dev/null +++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/corelib/pages/HibernateStatistics.java @@ -0,0 +1,87 @@ +// Copyright 2009, 2011, 2013 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.corelib.pages; + +import org.apache.tapestry5.SymbolConstants; +import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.annotations.WhitelistAccessOnly; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.ioc.annotations.Symbol; +import org.hibernate.Session; +import org.hibernate.metadata.ClassMetadata; +import org.hibernate.stat.*; + +import java.util.Collection; + +/** + * Page used to see the Hibernate statistics. + * + * @since 5.1.0.2 + */ +@WhitelistAccessOnly +public class HibernateStatistics +{ + @Inject + private Session session; + + @Property + @Inject + @Symbol(SymbolConstants.PRODUCTION_MODE) + private boolean productionMode; + + @Property + private String currentEntityName; + + @Property + private String currentCollectionRoleName; + + @Property + private String currentQuery; + + @Property + private String currentSecondLevelCacheRegionName; + + public Statistics getStatistics() + { + return session.getSessionFactory().getStatistics(); + } + + + @SuppressWarnings("unchecked") + public Collection<ClassMetadata> getAllClassMetadata() + { + return session.getSessionFactory().getAllClassMetadata().values(); + } + + public EntityStatistics getEntityStatistics() + { + return getStatistics().getEntityStatistics(currentEntityName); + } + + public CollectionStatistics getCollectionStatistics() + { + return getStatistics().getCollectionStatistics(currentCollectionRoleName); + } + + public QueryStatistics getQueryStatistics() + { + return getStatistics().getQueryStatistics(currentQuery); + } + + public SecondLevelCacheStatistics getSecondLevelCacheStatistics() + { + return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java index bb7c705..27c3652 100644 --- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java +++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java @@ -14,8 +14,6 @@ package org.apache.tapestry5.hibernate; -import java.util.Iterator; - import org.apache.tapestry5.ValueEncoder; import org.apache.tapestry5.internal.InternalConstants; import org.apache.tapestry5.internal.hibernate.CommitAfterWorker; @@ -34,7 +32,6 @@ import org.apache.tapestry5.ioc.services.ServiceOverride; import org.apache.tapestry5.ioc.services.TypeCoercer; import org.apache.tapestry5.services.ApplicationStateContribution; import org.apache.tapestry5.services.ApplicationStatePersistenceStrategy; -import org.apache.tapestry5.services.LibraryMapping; import org.apache.tapestry5.services.PersistentFieldStrategy; import org.apache.tapestry5.services.ValueEncoderFactory; import org.apache.tapestry5.services.dashboard.DashboardManager; @@ -43,6 +40,8 @@ import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2; import org.hibernate.Session; import org.hibernate.mapping.PersistentClass; +import java.util.Iterator; + /** * Supplements the services defined by {@link org.apache.tapestry5.hibernate.HibernateCoreModule} with additional * services and configuration specific to Tapestry web application. @@ -184,17 +183,9 @@ public class HibernateModule configuration.addInstance("CommitAfter", CommitAfterWorker.class, "after:Log"); } - /** - * Contribution to the {@link org.apache.tapestry5.services.ComponentClassResolver} service configuration. - */ - public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration) - { - configuration.add(new LibraryMapping("t5internal", "org.apache.tapestry5.hibernate.t5internal")); - } - @Contribute(DashboardManager.class) public static void provideHibernateDashboardTab(OrderedConfiguration<DashboardTab> configuration) { - configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "t5internal/HibernateStatistics")); + configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "core/HibernateStatistics")); } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.java ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.java deleted file mode 100644 index 0b67517..0000000 --- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.java +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2009, 2011, 2013 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.hibernate.t5internal.pages; - -import org.apache.tapestry5.SymbolConstants; -import org.apache.tapestry5.annotations.Property; -import org.apache.tapestry5.annotations.WhitelistAccessOnly; -import org.apache.tapestry5.ioc.annotations.Inject; -import org.apache.tapestry5.ioc.annotations.Symbol; -import org.hibernate.Session; -import org.hibernate.metadata.ClassMetadata; -import org.hibernate.stat.CollectionStatistics; -import org.hibernate.stat.EntityStatistics; -import org.hibernate.stat.QueryStatistics; -import org.hibernate.stat.SecondLevelCacheStatistics; -import org.hibernate.stat.Statistics; - -import java.util.Collection; - -/** - * Page used to see the Hibernate statistics. - * - * @since 5.1.0.2 - */ -@WhitelistAccessOnly -public class HibernateStatistics -{ - @Inject - private Session session; - - @Property - @Inject - @Symbol(SymbolConstants.PRODUCTION_MODE) - private boolean productionMode; - - @Property - private String currentEntityName; - - @Property - private String currentCollectionRoleName; - - @Property - private String currentQuery; - - @Property - private String currentSecondLevelCacheRegionName; - - public Statistics getStatistics() - { - return session.getSessionFactory().getStatistics(); - } - - - @SuppressWarnings("unchecked") - public Collection<ClassMetadata> getAllClassMetadata() - { - return session.getSessionFactory().getAllClassMetadata().values(); - } - - public EntityStatistics getEntityStatistics() - { - return getStatistics().getEntityStatistics(currentEntityName); - } - - public CollectionStatistics getCollectionStatistics() - { - return getStatistics().getCollectionStatistics(currentCollectionRoleName); - } - - public QueryStatistics getQueryStatistics() - { - return getStatistics().getQueryStatistics(currentQuery); - } - - public SecondLevelCacheStatistics getSecondLevelCacheStatistics() - { - return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/package-info.java ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/package-info.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/package-info.java deleted file mode 100644 index b18dd60..0000000 --- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/t5internal/pages/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012, 2013 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. - -/** - * Pages included with the Tapestry-hibernate module; this is used to plug in an additonal "Hibernate" - * page into {@link org.apache.tapestry5.corelib.pages.T5Dashboard}. - */ -package org.apache.tapestry5.hibernate.t5internal.pages; http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.properties ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.properties b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.properties new file mode 100644 index 0000000..98cfb66 --- /dev/null +++ b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.properties @@ -0,0 +1,15 @@ +# Copyright 2009, 2013 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. + +hibernate-statistics-hidden=Hibernate statistics are only available in development mode. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.tml ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.tml b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.tml new file mode 100644 index 0000000..4cd9886 --- /dev/null +++ b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/corelib/pages/HibernateStatistics.tml @@ -0,0 +1,69 @@ +<t:block id="content" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> + + <!-- TODO: Convert to a Bootstrap tab set --> + + <t:unless test="productionMode"> + <ul> + <li> + <a href="#EntitiesStatistics"> + Entities Statistics + </a> + </li> + <li> + <a href="#CollectionStatistics"> + Collection Statistics + </a> + </li> + <li> + <a href="#QueriesStatistics">Queries Statistics</a> + </li> + <li> + <a href="#SecondLevelCacheStatistics"> + Second Level Cache Statistics + </a> + </li> + </ul> + + <h1>Session Factory Statistics</h1> + <t:beandisplay object="statistics"/> + + <a name="EntitiesStatistics"/> + + <h1>Entities Statistics</h1> + <t:loop source="statistics.entityNames" + value="currentEntityName"> + <h2>${currentEntityName}</h2> + <t:beandisplay object="entityStatistics"/> + </t:loop> + + <a name="CollectionStatistics"/> + + <h1>Collection Statistics</h1> + <t:loop source="statistics.collectionRoleNames" + value="currentCollectionRoleName"> + <h2>${currentCollectionRoleName}</h2> + <t:beandisplay object="collectionStatistics"/> + </t:loop> + + <a name="QueriesStatistics"/> + + <h1>Queries Statistics</h1> + <t:loop source="statistics.queries" value="currentQuery"> + <t:beandisplay object="queryStatistics"/> + </t:loop> + + <a name="SecondLevelCacheStatistics"/> + + <h1>Second Level Cache Statistics</h1> + <t:loop source="statistics.secondLevelCacheRegionNames" + value="currentSecondLevelCacheRegionName"> + <t:beandisplay object="secondLevelCacheStatistics"/> + </t:loop> + + <p:else> + <p> + <em>${message:hibernate-statistics-hidden}</em> + </p> + </p:else> + </t:unless> +</t:block> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.properties ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.properties b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.properties deleted file mode 100644 index 98cfb66..0000000 --- a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2009, 2013 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. - -hibernate-statistics-hidden=Hibernate statistics are only available in development mode. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/991afc83/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.tml ---------------------------------------------------------------------- diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.tml b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.tml deleted file mode 100644 index 4cd9886..0000000 --- a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/hibernate/t5internal/pages/HibernateStatistics.tml +++ /dev/null @@ -1,69 +0,0 @@ -<t:block id="content" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter"> - - <!-- TODO: Convert to a Bootstrap tab set --> - - <t:unless test="productionMode"> - <ul> - <li> - <a href="#EntitiesStatistics"> - Entities Statistics - </a> - </li> - <li> - <a href="#CollectionStatistics"> - Collection Statistics - </a> - </li> - <li> - <a href="#QueriesStatistics">Queries Statistics</a> - </li> - <li> - <a href="#SecondLevelCacheStatistics"> - Second Level Cache Statistics - </a> - </li> - </ul> - - <h1>Session Factory Statistics</h1> - <t:beandisplay object="statistics"/> - - <a name="EntitiesStatistics"/> - - <h1>Entities Statistics</h1> - <t:loop source="statistics.entityNames" - value="currentEntityName"> - <h2>${currentEntityName}</h2> - <t:beandisplay object="entityStatistics"/> - </t:loop> - - <a name="CollectionStatistics"/> - - <h1>Collection Statistics</h1> - <t:loop source="statistics.collectionRoleNames" - value="currentCollectionRoleName"> - <h2>${currentCollectionRoleName}</h2> - <t:beandisplay object="collectionStatistics"/> - </t:loop> - - <a name="QueriesStatistics"/> - - <h1>Queries Statistics</h1> - <t:loop source="statistics.queries" value="currentQuery"> - <t:beandisplay object="queryStatistics"/> - </t:loop> - - <a name="SecondLevelCacheStatistics"/> - - <h1>Second Level Cache Statistics</h1> - <t:loop source="statistics.secondLevelCacheRegionNames" - value="currentSecondLevelCacheRegionName"> - <t:beandisplay object="secondLevelCacheStatistics"/> - </t:loop> - - <p:else> - <p> - <em>${message:hibernate-statistics-hidden}</em> - </p> - </p:else> - </t:unless> -</t:block> \ No newline at end of file
