You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/05/17 00:00:07 UTC

[1/5] git commit: Add cross-reference from @EagerLoad to ServiceBindingOptions.eagerLoad()

Updated Branches:
  refs/heads/master 9e8cc984e -> 2015f1ece


Add cross-reference from @EagerLoad to ServiceBindingOptions.eagerLoad()


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/53443f26
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/53443f26
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/53443f26

Branch: refs/heads/master
Commit: 53443f2645ef6b824e014609d69dc25596a26fb2
Parents: 9e8cc98
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Apr 29 09:02:20 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:11:24 2013 -0700

----------------------------------------------------------------------
 .../tapestry5/ioc/annotations/EagerLoad.java       |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/53443f26/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/EagerLoad.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/EagerLoad.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/EagerLoad.java
index c97142b..f67c67d 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/EagerLoad.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/EagerLoad.java
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
@@ -15,11 +15,12 @@
 package org.apache.tapestry5.ioc.annotations;
 
 import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.TYPE;
-import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
 
 /**
  * Marker annotation placed on a service builder method to indicate that the service should be eagerly loaded: realized
@@ -28,9 +29,11 @@ import java.lang.annotation.Target;
  * <p/>
  * This annotation may also be placed directly on a service implementation class, when using autobuilding via the {@link
  * org.apache.tapestry5.ioc.ServiceBinder}.
+ *
+ * @see org.apache.tapestry5.ioc.ServiceBindingOptions#eagerLoad()
  */
 @Target(
-        { TYPE, METHOD })
+        {TYPE, METHOD})
 @Retention(RUNTIME)
 @Documented
 @UseWith(AnnotationUseContext.SERVICE)


[3/5] git commit: Move the HibernateModule to a modules package

Posted by hl...@apache.org.
Move the HibernateModule to a modules package


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/43598e0a
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/43598e0a
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/43598e0a

Branch: refs/heads/master
Commit: 43598e0af84439e67ef2a8abb53e4a9176bd3277
Parents: 4fda4c8
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:35:33 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:35:33 2013 -0700

----------------------------------------------------------------------
 tapestry-hibernate/build.gradle                    |    2 +-
 .../tapestry5/hibernate/HibernateModule.java       |  191 --------------
 .../hibernate/modules/HibernateModule.java         |  195 +++++++++++++++
 .../java/org/example/app0/services/AppModule.java  |    2 +-
 4 files changed, 197 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/build.gradle b/tapestry-hibernate/build.gradle
index 26bbae7..73a6658 100644
--- a/tapestry-hibernate/build.gradle
+++ b/tapestry-hibernate/build.gradle
@@ -12,6 +12,6 @@ dependencies {
 
 jar {
     manifest {
-        attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.HibernateModule'
+        attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.modules.HibernateModule'
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/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
deleted file mode 100644
index 5d73516..0000000
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright 2007-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;
-
-import org.apache.tapestry5.ValueEncoder;
-import org.apache.tapestry5.internal.InternalConstants;
-import org.apache.tapestry5.internal.hibernate.CommitAfterWorker;
-import org.apache.tapestry5.internal.hibernate.EntityApplicationStatePersistenceStrategy;
-import org.apache.tapestry5.internal.hibernate.EntityPersistentFieldStrategy;
-import org.apache.tapestry5.internal.hibernate.HibernateEntityValueEncoder;
-import org.apache.tapestry5.ioc.Configuration;
-import org.apache.tapestry5.ioc.LoggerSource;
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.ioc.annotations.Primary;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-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.PersistentFieldStrategy;
-import org.apache.tapestry5.services.ValueEncoderFactory;
-import org.apache.tapestry5.services.dashboard.DashboardManager;
-import org.apache.tapestry5.services.dashboard.DashboardTab;
-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.modules.HibernateCoreModule} with additional
- * services and configuration specific to Tapestry web application.
- */
-public class HibernateModule
-{
-    public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
-    {
-        configuration.add(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, "true");
-        configuration.add(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED, "false");
-    }
-
-    /**
-     * Contributes the package "&lt;root&gt;.entities" to the configuration, so that it will be scanned for annotated
-     * entity classes.
-     */
-    public static void contributeHibernateEntityPackageManager(Configuration<String> configuration,
-
-    @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
-    String appRootPackage)
-    {
-        configuration.add(appRootPackage + ".entities");
-    }
-
-    @Contribute(ServiceOverride.class)
-    public static void provideInjectableSessionObject(MappedConfiguration<Class, Object> configuration, @HibernateCore
-    Session session)
-    {
-        configuration.add(Session.class, session);
-    }
-
-    /**
-     * Contributes {@link ValueEncoderFactory}s for all registered Hibernate entity classes. Encoding and decoding are
-     * based on the id property value of the entity using type coercion. Hence, if the id can be coerced to a String and
-     * back then the entity can be coerced.
-     */
-    @SuppressWarnings("unchecked")
-    public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration,
-            @Symbol(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS)
-            boolean provideEncoders, final HibernateSessionSource sessionSource, final Session session,
-            final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource)
-    {
-        if (!provideEncoders)
-            return;
-
-        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
-        Iterator<PersistentClass> mappings = config.getClassMappings();
-        while (mappings.hasNext())
-        {
-            final PersistentClass persistentClass = mappings.next();
-            final Class entityClass = persistentClass.getMappedClass();
-
-            if (entityClass != null)
-            {
-                ValueEncoderFactory factory = new ValueEncoderFactory()
-                {
-                    public ValueEncoder create(Class type)
-                    {
-                        return new HibernateEntityValueEncoder(entityClass, persistentClass, session, propertyAccess,
-                                typeCoercer, loggerSource.getLogger(entityClass));
-                    }
-                };
-
-                configuration.add(entityClass, factory);
-
-            }
-        }
-    }
-
-    /**
-     * Contributes the following:
-     * <dl>
-     * <dt>entity</dt>
-     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
-     * </dl>
-     */
-    public static void contributePersistentFieldManager(
-            MappedConfiguration<String, PersistentFieldStrategy> configuration)
-    {
-        configuration.addInstance(HibernatePersistenceConstants.ENTITY, EntityPersistentFieldStrategy.class);
-    }
-
-    /**
-     * Contributes the following strategy:
-     * <dl>
-     * <dt>entity</dt>
-     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
-     * </dl>
-     */
-    public void contributeApplicationStatePersistenceStrategySource(
-            MappedConfiguration<String, ApplicationStatePersistenceStrategy> configuration)
-    {
-        configuration
-                .addInstance(HibernatePersistenceConstants.ENTITY, EntityApplicationStatePersistenceStrategy.class);
-    }
-
-    /**
-     * Contributes {@link ApplicationStateContribution}s for all registered Hibernate entity classes.
-     * 
-     * @param configuration
-     *            Configuration to contribute
-     * @param entitySessionStatePersistenceStrategyEnabled
-     *            indicates if contribution should take place
-     * @param sessionSource
-     *            creates Hibernate session
-     */
-    public static void contributeApplicationStateManager(
-            MappedConfiguration<Class, ApplicationStateContribution> configuration,
-            @Symbol(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED)
-            boolean entitySessionStatePersistenceStrategyEnabled, HibernateSessionSource sessionSource)
-    {
-
-        if (!entitySessionStatePersistenceStrategyEnabled)
-            return;
-
-        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
-        Iterator<PersistentClass> mappings = config.getClassMappings();
-        while (mappings.hasNext())
-        {
-
-            final PersistentClass persistentClass = mappings.next();
-            final Class entityClass = persistentClass.getMappedClass();
-
-            configuration.add(entityClass, new ApplicationStateContribution(HibernatePersistenceConstants.ENTITY));
-        }
-    }
-
-    /**
-     * Adds the CommitAfter annotation work, to process the
-     * {@link org.apache.tapestry5.hibernate.annotations.CommitAfter} annotation.
-     */
-    @Contribute(ComponentClassTransformWorker2.class)
-    @Primary
-    public static void provideCommitAfterAnnotationSupport(
-            OrderedConfiguration<ComponentClassTransformWorker2> configuration)
-    {
-        // If logging is enabled, we want logging to be the first advice, wrapping around the commit advice.
-
-        configuration.addInstance("CommitAfter", CommitAfterWorker.class, "after:Log");
-    }
-
-    @Contribute(DashboardManager.class)
-    public static void provideHibernateDashboardTab(OrderedConfiguration<DashboardTab> configuration)
-    {
-        configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "core/HibernateStatistics"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
new file mode 100644
index 0000000..a9fb486
--- /dev/null
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
@@ -0,0 +1,195 @@
+// Copyright 2007-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.modules;
+
+import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.hibernate.HibernateCore;
+import org.apache.tapestry5.hibernate.HibernatePersistenceConstants;
+import org.apache.tapestry5.hibernate.HibernateSessionSource;
+import org.apache.tapestry5.hibernate.HibernateSymbols;
+import org.apache.tapestry5.internal.InternalConstants;
+import org.apache.tapestry5.internal.hibernate.CommitAfterWorker;
+import org.apache.tapestry5.internal.hibernate.EntityApplicationStatePersistenceStrategy;
+import org.apache.tapestry5.internal.hibernate.EntityPersistentFieldStrategy;
+import org.apache.tapestry5.internal.hibernate.HibernateEntityValueEncoder;
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.LoggerSource;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.annotations.Primary;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+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.PersistentFieldStrategy;
+import org.apache.tapestry5.services.ValueEncoderFactory;
+import org.apache.tapestry5.services.dashboard.DashboardManager;
+import org.apache.tapestry5.services.dashboard.DashboardTab;
+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.modules.HibernateCoreModule} with additional
+ * services and configuration specific to Tapestry web application.
+ */
+public class HibernateModule
+{
+    public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
+    {
+        configuration.add(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, "true");
+        configuration.add(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED, "false");
+    }
+
+    /**
+     * Contributes the package "&lt;root&gt;.entities" to the configuration, so that it will be scanned for annotated
+     * entity classes.
+     */
+    public static void contributeHibernateEntityPackageManager(Configuration<String> configuration,
+
+                                                               @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
+                                                               String appRootPackage)
+    {
+        configuration.add(appRootPackage + ".entities");
+    }
+
+    @Contribute(ServiceOverride.class)
+    public static void provideInjectableSessionObject(MappedConfiguration<Class, Object> configuration, @HibernateCore
+    Session session)
+    {
+        configuration.add(Session.class, session);
+    }
+
+    /**
+     * Contributes {@link ValueEncoderFactory}s for all registered Hibernate entity classes. Encoding and decoding are
+     * based on the id property value of the entity using type coercion. Hence, if the id can be coerced to a String and
+     * back then the entity can be coerced.
+     */
+    @SuppressWarnings("unchecked")
+    public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration,
+                                                    @Symbol(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS)
+                                                    boolean provideEncoders, final HibernateSessionSource sessionSource, final Session session,
+                                                    final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource)
+    {
+        if (!provideEncoders)
+            return;
+
+        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
+        Iterator<PersistentClass> mappings = config.getClassMappings();
+        while (mappings.hasNext())
+        {
+            final PersistentClass persistentClass = mappings.next();
+            final Class entityClass = persistentClass.getMappedClass();
+
+            if (entityClass != null)
+            {
+                ValueEncoderFactory factory = new ValueEncoderFactory()
+                {
+                    public ValueEncoder create(Class type)
+                    {
+                        return new HibernateEntityValueEncoder(entityClass, persistentClass, session, propertyAccess,
+                                typeCoercer, loggerSource.getLogger(entityClass));
+                    }
+                };
+
+                configuration.add(entityClass, factory);
+
+            }
+        }
+    }
+
+    /**
+     * Contributes the following:
+     * <dl>
+     * <dt>entity</dt>
+     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
+     * </dl>
+     */
+    public static void contributePersistentFieldManager(
+            MappedConfiguration<String, PersistentFieldStrategy> configuration)
+    {
+        configuration.addInstance(HibernatePersistenceConstants.ENTITY, EntityPersistentFieldStrategy.class);
+    }
+
+    /**
+     * Contributes the following strategy:
+     * <dl>
+     * <dt>entity</dt>
+     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
+     * </dl>
+     */
+    public void contributeApplicationStatePersistenceStrategySource(
+            MappedConfiguration<String, ApplicationStatePersistenceStrategy> configuration)
+    {
+        configuration
+                .addInstance(HibernatePersistenceConstants.ENTITY, EntityApplicationStatePersistenceStrategy.class);
+    }
+
+    /**
+     * Contributes {@link ApplicationStateContribution}s for all registered Hibernate entity classes.
+     *
+     * @param configuration
+     *         Configuration to contribute
+     * @param entitySessionStatePersistenceStrategyEnabled
+     *         indicates if contribution should take place
+     * @param sessionSource
+     *         creates Hibernate session
+     */
+    public static void contributeApplicationStateManager(
+            MappedConfiguration<Class, ApplicationStateContribution> configuration,
+            @Symbol(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED)
+            boolean entitySessionStatePersistenceStrategyEnabled, HibernateSessionSource sessionSource)
+    {
+
+        if (!entitySessionStatePersistenceStrategyEnabled)
+            return;
+
+        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
+        Iterator<PersistentClass> mappings = config.getClassMappings();
+        while (mappings.hasNext())
+        {
+
+            final PersistentClass persistentClass = mappings.next();
+            final Class entityClass = persistentClass.getMappedClass();
+
+            configuration.add(entityClass, new ApplicationStateContribution(HibernatePersistenceConstants.ENTITY));
+        }
+    }
+
+    /**
+     * Adds the CommitAfter annotation work, to process the
+     * {@link org.apache.tapestry5.hibernate.annotations.CommitAfter} annotation.
+     */
+    @Contribute(ComponentClassTransformWorker2.class)
+    @Primary
+    public static void provideCommitAfterAnnotationSupport(
+            OrderedConfiguration<ComponentClassTransformWorker2> configuration)
+    {
+        // If logging is enabled, we want logging to be the first advice, wrapping around the commit advice.
+
+        configuration.addInstance("CommitAfter", CommitAfterWorker.class, "after:Log");
+    }
+
+    @Contribute(DashboardManager.class)
+    public static void provideHibernateDashboardTab(OrderedConfiguration<DashboardTab> configuration)
+    {
+        configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "core/HibernateStatistics"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java b/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
index a2b24a6..0d8d994 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
@@ -15,10 +15,10 @@
 package org.example.app0.services;
 
 import org.apache.tapestry5.SymbolConstants;
-import org.apache.tapestry5.hibernate.HibernateModule;
 import org.apache.tapestry5.hibernate.HibernateSymbols;
 import org.apache.tapestry5.hibernate.HibernateTransactionDecorator;
 import org.apache.tapestry5.hibernate.modules.HibernateCoreModule;
+import org.apache.tapestry5.hibernate.modules.HibernateModule;
 import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.ServiceBinder;


[4/5] git commit: Inline the generation of message strings

Posted by hl...@apache.org.
Inline the generation of message strings


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/378986b1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/378986b1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/378986b1

Branch: refs/heads/master
Commit: 378986b178a3889f74707602db3862ac7e55d769
Parents: 43598e0
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:53:58 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:53:58 2013 -0700

----------------------------------------------------------------------
 .../internal/hibernate/HibernateCoreMessages.java  |   36 --------------
 .../hibernate/HibernateSessionSourceImpl.java      |    8 ++--
 .../hibernate/HibernateCoreStrings.properties      |   16 ------
 .../hibernate/EntityPersistentFieldStrategy.java   |    4 +-
 .../internal/hibernate/HibernateMessages.java      |   38 ---------------
 .../internal/hibernate/PersistedEntity.java        |    4 +-
 .../internal/hibernate/HibernateStrings.properties |   17 -------
 7 files changed, 8 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
deleted file mode 100644
index 0edf93c..0000000
--- a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2008, 2010 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.hibernate;
-
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
-
-import java.util.Collection;
-
-public class HibernateCoreMessages
-{
-    private static final Messages MESSAGES = MessagesImpl.forClass(HibernateCoreMessages.class);
-
-    public static String startupTiming(long toConfigure, long overall)
-    {
-        return MESSAGES.format("startup-timing", toConfigure, overall);
-    }
-
-    public static String entityCatalog(Collection entityNames)
-    {
-        return MESSAGES.format("entity-catalog", InternalUtils.joinSorted(entityNames));
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
index eaece53..615016e 100644
--- a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
+++ b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2011 The Apache Software Foundation
+// Copyright 2007-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.
@@ -17,10 +17,10 @@ package org.apache.tapestry5.internal.hibernate;
 import org.apache.tapestry5.hibernate.HibernateConfigurer;
 import org.apache.tapestry5.hibernate.HibernateSessionSource;
 import org.apache.tapestry5.ioc.annotations.PostInjection;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.cfg.Configuration;
 import org.slf4j.Logger;
 
@@ -47,9 +47,9 @@ public class HibernateSessionSourceImpl implements HibernateSessionSource
 
         long factoryCreated = System.currentTimeMillis();
 
-        logger.info(HibernateCoreMessages.startupTiming(configurationComplete - startTime, factoryCreated - startTime));
+        logger.info(String.format("Hibernate startup: %,d ms to configure, %,d ms overall.", configurationComplete - startTime, factoryCreated - startTime));
 
-        logger.info(HibernateCoreMessages.entityCatalog(sessionFactory.getAllClassMetadata().keySet()));
+        logger.info(String.format("Configured Hibernate entities: %s", InternalUtils.joinSorted(sessionFactory.getAllClassMetadata().keySet())));
     }
 
     @PostInjection

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties b/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
deleted file mode 100644
index f90ff8d..0000000
--- a/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2008, 2010 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.
-
-startup-timing=Hibernate startup: %,d ms to configure, %,d ms overall.
-entity-catalog=Configured Hibernate entities: %s

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
index f5e6f2f..d651352 100644
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008m 2913 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.
@@ -49,7 +49,7 @@ public class EntityPersistentFieldStrategy extends AbstractSessionPersistentFiel
         }
         catch (HibernateException ex)
         {
-            throw new IllegalArgumentException(HibernateMessages.entityNotAttached(newValue), ex);
+            throw new IllegalArgumentException(String.format("Failed persisting an entity in the session. Only entities attached to a Hibernate Session can be persisted. entity: %s", newValue), ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
deleted file mode 100644
index a498c5b..0000000
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2007, 2008, 2010 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.hibernate;
-
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
-
-public class HibernateMessages
-{
-    private static final Messages MESSAGES = MessagesImpl.forClass(HibernateMessages.class);
-
-    public static String sessionPersistedEntityLoadFailure(String entityName, Object id, Throwable cause)
-    {
-        return MESSAGES.format("session-persisted-entity-load-failure", entityName, id, cause);
-    }
-
-    public static String entityNotAttached(Object entity)
-    {
-        return MESSAGES.format("entity-not-attached", entity);
-    }
-
-    public static String commitTransactionInterceptor(String serviceId, Class serviceInterface)
-    {
-        return MESSAGES.format("commit-transaction-interceptor", serviceId, serviceInterface.getName());
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
index 18fe5fd..51d3088 100644
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
@@ -1,4 +1,4 @@
-// Copyright 2008, 2010 The Apache Software Foundation
+// Copyright 2008, 2010, 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.
@@ -45,7 +45,7 @@ public class PersistedEntity implements Serializable
         }
         catch (Exception ex)
         {
-            throw new RuntimeException(HibernateMessages.sessionPersistedEntityLoadFailure(entityName, id, ex));
+            throw new RuntimeException(String.format("Failed to load session-persisted entity %s(%s): %s", entityName, id, ex));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
deleted file mode 100644
index 7eda452..0000000
--- a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2007, 2008 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.
-
-session-persisted-entity-load-failure=Failed to load session-persisted entity %s(%s): %s
-entity-not-attached=Failed persisting an entity in the session. Only entities attached to a Hibernate Session can be persisted. entity: %s
-commit-transaction-interceptor=<Hibernate Transaction interceptor for %s(%s)>


Re: [2/5] git commit: Strip out the metrics support

Posted by Howard Lewis Ship <hl...@gmail.com>.
It became obvious that I didn't have a real plan, or the time, to get this
into 5.4.  I can't even communicate a design ... too busy with other stuff.

I'm trying to lock down 5.4 pretty soon; my last two major items are
- wro4j support (CoffeeScript, Less, CSS and JS minimization)
- websocket/server-push/comet.d -- something to fascilitate easy server push






On Fri, May 17, 2013 at 2:51 AM, Massimo Lusetti <ml...@gmail.com> wrote:

> On Fri, May 17, 2013 at 9:36 AM, Ulrich Stärk <ul...@spielviel.de> wrote:
>
> Why?
> >
> >
> Don't know if it's related but the last version of rrd4j requires java6 ...
> BTW the deps was on 2.1.x which still run on java5
>
> --
> Massimo Lusetti
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Re: [2/5] git commit: Strip out the metrics support

Posted by Massimo Lusetti <ml...@gmail.com>.
On Fri, May 17, 2013 at 9:36 AM, Ulrich Stärk <ul...@spielviel.de> wrote:

Why?
>
>
Don't know if it's related but the last version of rrd4j requires java6 ...
BTW the deps was on 2.1.x which still run on java5

-- 
Massimo Lusetti

Re: [2/5] git commit: Strip out the metrics support

Posted by Ulrich Stärk <ul...@spielviel.de>.
Why?

On 17.05.2013 00:00, hlship@apache.org wrote:
> Strip out the metrics support
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
> Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/4fda4c80
> Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/4fda4c80
> Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/4fda4c80
> 
> Branch: refs/heads/master
> Commit: 4fda4c803dc40bb164dff4203d8358c0e3996c85
> Parents: 53443f2
> Author: Howard M. Lewis Ship <hl...@apache.org>
> Authored: Thu May 16 14:34:07 2013 -0700
> Committer: Howard M. Lewis Ship <hl...@apache.org>
> Committed: Thu May 16 14:34:07 2013 -0700
> 
> ----------------------------------------------------------------------
>  .../apache/tapestry5/corelib/pages/AppMetrics.java |   48 --
>  .../tapestry5/modules/RootMetricsFilter.java       |   52 ---
>  .../apache/tapestry5/modules/TapestryModule.java   |    2 +-
>  .../apache/tapestry5/modules/WebMetricsModule.java |   34 --
>  .../apache/tapestry5/corelib/pages/AppMetrics.tml  |    6 -
>  tapestry-ioc/build.gradle                          |    2 -
>  .../services/metrics/MetricCollectorImpl.java      |  358 ---------------
>  .../tapestry5/ioc/modules/MetricsModule.java       |   29 --
>  .../tapestry5/ioc/modules/TapestryIOCModule.java   |    3 +-
>  .../tapestry5/ioc/services/metrics/Metric.java     |  106 -----
>  .../ioc/services/metrics/MetricCollector.java      |   32 --
>  .../ioc/services/metrics/MetricsSymbols.java       |   10 -
>  12 files changed, 2 insertions(+), 680 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
> deleted file mode 100644
> index d57b75c..0000000
> --- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
> +++ /dev/null
> @@ -1,48 +0,0 @@
> -// Copyright 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.annotations.WhitelistAccessOnly;
> -import org.apache.tapestry5.beaneditor.BeanModel;
> -import org.apache.tapestry5.ioc.Messages;
> -import org.apache.tapestry5.ioc.annotations.Inject;
> -import org.apache.tapestry5.ioc.services.metrics.Metric;
> -import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
> -import org.apache.tapestry5.services.BeanModelSource;
> -
> -import java.util.List;
> -
> -@WhitelistAccessOnly
> -/**
> - * Contributes to the {@link T5Dashboard} page, providing application metrics from the {@link org.apache.tapestry5.ioc.services.metrics.MetricCollector}.
> - */
> -public class AppMetrics
> -{
> -    @Inject
> -    MetricCollector collector;
> -
> -    @Inject
> -    BeanModelSource beanModelSource;
> -
> -    @Inject
> -    private Messages messages;
> -
> -    public final BeanModel<Metric> metricModel = beanModelSource.createDisplayModel(Metric.class, messages);
> -
> -    public List<Metric> getRootMetrics()
> -    {
> -        return collector.getRootMetrics();
> -    }
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
> deleted file mode 100644
> index 3d08f30..0000000
> --- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
> +++ /dev/null
> @@ -1,52 +0,0 @@
> -// Copyright 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.modules;
> -
> -import org.apache.tapestry5.ioc.services.metrics.Metric;
> -import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
> -import org.apache.tapestry5.services.HttpServletRequestFilter;
> -import org.apache.tapestry5.services.HttpServletRequestHandler;
> -
> -import javax.servlet.http.HttpServletRequest;
> -import javax.servlet.http.HttpServletResponse;
> -import java.io.IOException;
> -
> -public class RootMetricsFilter implements HttpServletRequestFilter
> -{
> -
> -    private final Metric count, requestTime;
> -
> -    public RootMetricsFilter(MetricCollector collector)
> -    {
> -        count = collector.createRootMetric("request-count", Metric.Type.TOTAL, Metric.Units.COUNTER);
> -        requestTime = collector.createRootMetric("request-time", Metric.Type.RATE, Metric.Units.MILLISECONDS);
> -    }
> -
> -    public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler) throws IOException
> -    {
> -        long start = System.currentTimeMillis();
> -
> -        boolean handled = handler.service(request, response);
> -
> -        // We don't count the unhandled requests
> -
> -        if (handled) {
> -            count.increment();
> -            requestTime.accumulate(System.currentTimeMillis() - start);
> -        }
> -
> -        return handled;
> -    }
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
> index 4f567b9..0dbe078 100644
> --- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
> +++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
> @@ -108,7 +108,7 @@ import java.util.regex.Pattern;
>   */
>  @Marker(Core.class)
>  @SubModule(
> -        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class, WebMetricsModule.class})
> +        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class})
>  public final class TapestryModule
>  {
>      private final PipelineBuilder pipelineBuilder;
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
> deleted file mode 100644
> index 7778e94..0000000
> --- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -// Copyright 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.modules;
> -
> -import org.apache.tapestry5.ioc.OrderedConfiguration;
> -import org.apache.tapestry5.ioc.annotations.Contribute;
> -import org.apache.tapestry5.services.HttpServletRequestFilter;
> -import org.apache.tapestry5.services.HttpServletRequestHandler;
> -
> -/**
> - * Responsible for contributing filters in various places, to handle metrics collection.
> - *
> - * @since 5.4
> - */
> -public class WebMetricsModule
> -{
> -    @Contribute(HttpServletRequestHandler.class)
> -    public static void addRootFilter(OrderedConfiguration<HttpServletRequestFilter> configuration)
> -    {
> -        configuration.addInstance("RootMetrics", RootMetricsFilter.class, "before:GZip");
> -    }
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
> ----------------------------------------------------------------------
> diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
> deleted file mode 100644
> index 736698a..0000000
> --- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -<t:block id="content" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
> -        >
> -
> -    <t:grid source="rootMetrics" model="metricModel"/>"
> -
> -</t:block>
> \ No newline at end of file
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/build.gradle
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
> index b08f585..e890f7e 100644
> --- a/tapestry-ioc/build.gradle
> +++ b/tapestry-ioc/build.gradle
> @@ -17,8 +17,6 @@ dependencies {
>      testCompile "org.spockframework:spock-core:${versions.spock}"
>      testCompile "commons-lang:commons-lang:2.6"
>  
> -    compile "org.rrd4j:rrd4j:2.1.1"
> -
>      provided "org.testng:testng:${versions.testng}", { transitive = false }
>  }
>  
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
> deleted file mode 100644
> index 51cf1c9..0000000
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
> +++ /dev/null
> @@ -1,358 +0,0 @@
> -// Copyright 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.ioc.internal.services.metrics;
> -
> -import org.apache.tapestry5.func.F;
> -import org.apache.tapestry5.ioc.annotations.PostInjection;
> -import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
> -import org.apache.tapestry5.ioc.annotations.Symbol;
> -import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
> -import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> -import org.apache.tapestry5.ioc.internal.util.LockSupport;
> -import org.apache.tapestry5.ioc.services.cron.IntervalSchedule;
> -import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor;
> -import org.apache.tapestry5.ioc.services.metrics.Metric;
> -import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
> -import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
> -import org.apache.tapestry5.ioc.util.ExceptionUtils;
> -import org.rrd4j.ConsolFun;
> -import org.rrd4j.DsType;
> -import org.rrd4j.core.*;
> -import org.slf4j.Logger;
> -
> -import java.io.File;
> -import java.io.IOException;
> -import java.util.Date;
> -import java.util.HashMap;
> -import java.util.List;
> -import java.util.Map;
> -import java.util.concurrent.atomic.AtomicReference;
> -
> -@PreventServiceDecoration
> -public class MetricCollectorImpl extends LockSupport implements MetricCollector, Runnable
> -{
> -    private final boolean inMemory;
> -
> -    private final RrdBackendFactory factory;
> -
> -    private final Logger logger;
> -
> -    private final String dbDir;
> -
> -    private final List<Runnable> updates = CollectionFactory.newThreadSafeList();
> -
> -    public static final int HEARTBEAT = 10; // seconds
> -
> -    public static final String DS_NAME = "data";
> -
> -    public class MetricImpl extends LockSupport implements Metric, Comparable<MetricImpl>, Runnable
> -    {
> -        private final MetricImpl parent;
> -
> -        private final Map<String, Metric> children = new HashMap<String, Metric>();
> -
> -        private final String name;
> -
> -        private final String path;
> -
> -        private final Type type;
> -
> -        private final Units units;
> -
> -        private final RrdDb db;
> -
> -        // TODO: May want to initialize this from stored data for Type.TOTAL
> -
> -        private final AtomicReference<Double> accumulator = new AtomicReference<Double>(0d);
> -
> -        MetricImpl(MetricImpl parent, String name, Type type, Units units)
> -        {
> -            this.name = name;
> -            assert InternalUtils.isNonBlank(name);
> -            assert type != null;
> -            assert units != null;
> -
> -            this.parent = parent;
> -
> -            // Parent may be null for a root Metric
> -            this.path = parent == null ? name : parent.getPath() + "/" + name;
> -
> -            this.type = type;
> -            this.units = units;
> -
> -            try
> -            {
> -                this.db = createDb();
> -            } catch (IOException ex)
> -            {
> -                throw new RuntimeException(String.format("Unable to create RrdDb for '%s': %s",
> -                        path,
> -                        ExceptionUtils.toMessage(ex)), ex);
> -            }
> -
> -            updates.add(this);
> -        }
> -
> -        private RrdDb createDb() throws IOException
> -        {
> -
> -            if (inMemory)
> -            {
> -                return new RrdDb(createDef(path), factory);
> -            }
> -
> -            // TODO: If we want to support other options, such as Mongo or Berkley, we'll need
> -            // to abstract the RRDb factory a bit further!
> -
> -            String filePath = dbDir + "/" + path + ".rrdb";
> -
> -            File dbFile = new File(filePath);
> -            dbFile.getParentFile().mkdirs();
> -
> -            if (dbFile.exists())
> -            {
> -                return new RrdDb(filePath, factory);
> -            }
> -
> -            return new RrdDb(createDef(filePath), factory);
> -        }
> -
> -        private RrdDef createDef(String filePath)
> -        {
> -            RrdDef result = new RrdDef(filePath, HEARTBEAT);
> -
> -            result.addDatasource(DS_NAME, DsType.COUNTER, HEARTBEAT, 0, Double.NaN);
> -            // One archive: average for each new data point, 10 minutes worth.
> -            result.addArchive(new ArcDef(ConsolFun.AVERAGE, .5, 1, 60));
> -
> -            return result;
> -        }
> -
> -        public int compareTo(MetricImpl o)
> -        {
> -            return this.name.compareTo(o.name);
> -        }
> -
> -        public Metric createChild(String name)
> -        {
> -            assert InternalUtils.isNonBlank(name);
> -
> -            try
> -            {
> -                acquireReadLock();
> -
> -                Metric child = children.get(name);
> -
> -                if (child == null)
> -                {
> -                    try
> -                    {
> -                        upgradeReadLockToWriteLock();
> -
> -                        // Could be a race ...
> -
> -                        child = children.get(name);
> -
> -                        if (child == null)
> -                        {
> -                            child = new MetricImpl(this, name, type, units);
> -
> -                            children.put(name, child);
> -                        }
> -                    } finally
> -                    {
> -                        downgradeWriteLockToReadLock();
> -                    }
> -                }
> -
> -                return child;
> -
> -            } finally
> -            {
> -                releaseReadLock();
> -            }
> -        }
> -
> -        public String getPath()
> -        {
> -            return path;
> -        }
> -
> -        public Type getType()
> -        {
> -            return type;
> -        }
> -
> -        public Units getUnits()
> -        {
> -            return units;
> -        }
> -
> -        public void increment()
> -        {
> -            accumulate(1);
> -        }
> -
> -        public void accumulate(double value)
> -        {
> -            while (true)
> -            {
> -                Double current = accumulator.get();
> -                Double updated = current + value;
> -
> -                // This is where an Atomic is better than a simple volatile, we can detect
> -                // when a race condition would have caused the loss of data by overlapping
> -                // read-and-increment operations. Still miss Clojure's approach, of course.
> -
> -                if (accumulator.compareAndSet(current, updated))
> -                {
> -                    break;
> -                }
> -            }
> -
> -            if (parent != null)
> -            {
> -                parent.accumulate(value);
> -            }
> -        }
> -
> -        public List<Metric> getChildren()
> -        {
> -            try
> -            {
> -                acquireReadLock();
> -
> -                return F.flow(children.values()).sort().toList();
> -            } finally
> -            {
> -                releaseReadLock();
> -            }
> -        }
> -
> -        public Date getLastUpdateTime()
> -        {
> -            try
> -            {
> -                return new Date(db.getLastUpdateTime());
> -            } catch (IOException ex)
> -            {
> -                return null;
> -            }
> -        }
> -
> -        public void run()
> -        {
> -            try
> -            {
> -                db.createSample().setValue(DS_NAME, accumulator.getAndSet(0d)).update();
> -            } catch (IOException ex)
> -            {
> -                logger.error(String.format("Unable to update database for metric '%s': %s",
> -                        path,
> -                        ExceptionUtils.toMessage(ex)), ex);
> -            }
> -        }
> -    }
> -
> -    private final Map<String, Metric> rootMetrics = new HashMap<String, Metric>();
> -
> -    public MetricCollectorImpl(Logger logger, @Symbol(MetricsSymbols.RRD_DB_DIR) String dbDir)
> -    {
> -        this.logger = logger;
> -        this.dbDir = dbDir;
> -
> -        inMemory = dbDir.equals("");
> -
> -        factory = inMemory ? new RrdMemoryBackendFactory() : new RrdNioBackendFactory();
> -
> -        logger.info(String.format("Collecting metrics %s.",
> -                inMemory ? "in memory" : (" to" + dbDir)));
> -    }
> -
> -
> -    public Metric createRootMetric(String name, Metric.Type type, Metric.Units units)
> -    {
> -
> -        try
> -        {
> -            acquireReadLock();
> -
> -            Metric result = rootMetrics.get(name);
> -
> -            if (result == null)
> -            {
> -                try
> -                {
> -                    upgradeReadLockToWriteLock();
> -
> -                    // There's a window where another thread may create the metric instead.
> -
> -                    result = rootMetrics.get(name);
> -
> -                    // But in the normal case, that won't happen and this thread has the exclusive
> -                    // write lock to create and cache the new metric.
> -                    if (result == null)
> -                    {
> -
> -                        result = new MetricImpl(null, name, type, units);
> -
> -                        rootMetrics.put(name, result);
> -                    }
> -                } finally
> -                {
> -                    downgradeWriteLockToReadLock();
> -                }
> -            }
> -
> -            if (result.getType() != type || result.getUnits() != units)
> -            {
> -                throw new IllegalArgumentException(String.format("Metric %s already exists and is type %s, units %s.",
> -                        result.getPath(),
> -                        result.getType().name(),
> -                        result.getUnits().name()));
> -            }
> -
> -            return result;
> -
> -        } finally
> -        {
> -            releaseReadLock();
> -        }
> -
> -    }
> -
> -    /**
> -     * Invoked every few seconds to make all the active metrics update their dbs.
> -     */
> -    public void run()
> -    {
> -        for (Runnable r : updates)
> -        {
> -            r.run();
> -        }
> -    }
> -
> -    @PostInjection
> -    public void activatePeriodicUpdates(PeriodicExecutor executor)
> -    {
> -        executor.addJob(new IntervalSchedule(HEARTBEAT * 1000),
> -                "UpdateMetrics", this);
> -    }
> -
> -    public List<Metric> getRootMetrics()
> -    {
> -        return F.flow(rootMetrics.values()).sort().toList();
> -    }
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
> deleted file mode 100644
> index 38b2732..0000000
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -package org.apache.tapestry5.ioc.modules;
> -
> -import org.apache.tapestry5.ioc.MappedConfiguration;
> -import org.apache.tapestry5.ioc.ServiceBinder;
> -import org.apache.tapestry5.ioc.annotations.Contribute;
> -import org.apache.tapestry5.ioc.annotations.Marker;
> -import org.apache.tapestry5.ioc.internal.services.metrics.MetricCollectorImpl;
> -import org.apache.tapestry5.ioc.services.Builtin;
> -import org.apache.tapestry5.ioc.services.FactoryDefaults;
> -import org.apache.tapestry5.ioc.services.SymbolProvider;
> -import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
> -import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
> -
> -@Marker(Builtin.class)
> -public class MetricsModule
> -{
> -
> -    public static void bind(ServiceBinder binder)
> -    {
> -        binder.bind(MetricCollector.class, MetricCollectorImpl.class);
> -    }
> -
> -    @Contribute(SymbolProvider.class)
> -    @FactoryDefaults
> -    public static void provideDefaults(MappedConfiguration<String, Object> configuration)
> -    {
> -        configuration.add(MetricsSymbols.RRD_DB_DIR, "");
> -    }
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
> index 178edf2..7f95181 100644
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
> +++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
> @@ -1,4 +1,4 @@
> -// Copyright 2006-2012 The Apache Software Foundation
> +// Copyright 2006-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.
> @@ -43,7 +43,6 @@ import static org.apache.tapestry5.ioc.OrderConstraintBuilder.before;
>   */
>  @SuppressWarnings("all")
>  @Marker(Builtin.class)
> -@SubModule(MetricsModule.class)
>  public final class TapestryIOCModule
>  {
>      public static void bind(ServiceBinder binder)
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
> deleted file mode 100644
> index 71cda59..0000000
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
> +++ /dev/null
> @@ -1,106 +0,0 @@
> -// Copyright 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.ioc.services.metrics;
> -
> -import java.util.Date;
> -import java.util.List;
> -
> -/**
> - * @since 5.4
> - */
> -public interface Metric
> -{
> -    enum Type
> -    {
> -        /**
> -         * Storing a value accumulates into an ever increasing total. Example:
> -         * number of burgers served.
> -         */
> -        TOTAL,
> -
> -        /**
> -         * Storing a value accumulates just for the current time interval.  Example:
> -         * burgers served per second.
> -         */
> -        RATE
> -    }
> -
> -
> -    /**
> -     * Primarily used when reporting to indicate the types of values.
> -     */
> -    enum Units
> -    {
> -        /**
> -         * Appropriate when measuring bytes transferred, etc.
> -         */
> -        BYTES,
> -        /**
> -         * Useful when measuring the time to produce a result, such as processing some kind of request.
> -         */
> -        MILLISECONDS,
> -        /**
> -         * Placeholder for all other kinds of units, such as "pages viewed" or "messages processed".
> -         */
> -        COUNTER
> -    }
> -
> -    /**
> -     * Creates a child metric with the same type and units.
> -     * Values posted to the child are also posted to the container (this
> -     * bubbling up can occur across several levels).
> -     *
> -     * @param name
> -     *         child's extension to this Metric's name
> -     * @return the child with the given name (creating it if necessary).
> -     */
> -    Metric createChild(String name);
> -
> -    /**
> -     * Returns the path to this metric: the metric's name appended (after a slash) to the parent
> -     * metric's path.
> -     */
> -    String getPath();
> -
> -    Type getType();
> -
> -    Units getUnits();
> -
> -    /**
> -     * Accumulates a value of 1; useful  when the metric's type is {@link Units#COUNTER}.
> -     */
> -    void increment();
> -
> -    /**
> -     * Adds the provided value to the current time interval's value. This may be called multiple times during
> -     * a time interval, and the values will accumulate. In addition, {@link #accumulate(double)}
> -     * propagates the value up to the parent metrics, if any, all the way up to the root metric.
> -     *
> -     * @param value
> -     */
> -    void accumulate(double value);
> -
> -    /**
> -     * Returns the children of this metric, sorted by name.
> -     */
> -    List<Metric> getChildren();
> -
> -    /**
> -     * Returns the last time the archive was updated (this happens a regular intervals called heartbeats).
> -     *
> -     * @return archive update time, or null if there is an exception accessing the time
> -     */
> -    Date getLastUpdateTime();
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
> deleted file mode 100644
> index e5c168f..0000000
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -package org.apache.tapestry5.ioc.services.metrics;
> -
> -import java.util.List;
> -
> -/**
> - * Central hub for creating or obtaining {@link Metric}s.
> - *
> - * @since 5.4
> - */
> -public interface MetricCollector
> -{
> -    /**
> -     * Creates a root metric, or returns an existing one.
> -     *
> -     * @param name
> -     *         name of the metric to create
> -     * @param type
> -     *         used when creating the metric
> -     * @param units
> -     *         used when creating the metric
> -     * @return the metric
> -     * @throws IllegalMonitorStateException
> -     *         if an existing root metric with that name is present, but does
> -     *         not have the matching type and units.
> -     */
> -    Metric createRootMetric(String name, Metric.Type type, Metric.Units units);
> -
> -    /**
> -     * Returns root metrics, sorted by name.
> -     */
> -    List<Metric> getRootMetrics();
> -}
> 
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
> ----------------------------------------------------------------------
> diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
> deleted file mode 100644
> index 39c9bb1..0000000
> --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
> +++ /dev/null
> @@ -1,10 +0,0 @@
> -package org.apache.tapestry5.ioc.services.metrics;
> -
> -public class MetricsSymbols
> -{
> -    /**
> -     * The directory in which RRDb database files are stored. If blank (the default),
> -     * then RRD is set up for in-memory databases only (re-created on each launch of the application).
> -     */
> -    public static final String RRD_DB_DIR = "tapestry.rrd-dir";
> -}
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


[2/5] git commit: Strip out the metrics support

Posted by hl...@apache.org.
Strip out the metrics support


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/4fda4c80
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/4fda4c80
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/4fda4c80

Branch: refs/heads/master
Commit: 4fda4c803dc40bb164dff4203d8358c0e3996c85
Parents: 53443f2
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:34:07 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:34:07 2013 -0700

----------------------------------------------------------------------
 .../apache/tapestry5/corelib/pages/AppMetrics.java |   48 --
 .../tapestry5/modules/RootMetricsFilter.java       |   52 ---
 .../apache/tapestry5/modules/TapestryModule.java   |    2 +-
 .../apache/tapestry5/modules/WebMetricsModule.java |   34 --
 .../apache/tapestry5/corelib/pages/AppMetrics.tml  |    6 -
 tapestry-ioc/build.gradle                          |    2 -
 .../services/metrics/MetricCollectorImpl.java      |  358 ---------------
 .../tapestry5/ioc/modules/MetricsModule.java       |   29 --
 .../tapestry5/ioc/modules/TapestryIOCModule.java   |    3 +-
 .../tapestry5/ioc/services/metrics/Metric.java     |  106 -----
 .../ioc/services/metrics/MetricCollector.java      |   32 --
 .../ioc/services/metrics/MetricsSymbols.java       |   10 -
 12 files changed, 2 insertions(+), 680 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
deleted file mode 100644
index d57b75c..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 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.annotations.WhitelistAccessOnly;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.services.BeanModelSource;
-
-import java.util.List;
-
-@WhitelistAccessOnly
-/**
- * Contributes to the {@link T5Dashboard} page, providing application metrics from the {@link org.apache.tapestry5.ioc.services.metrics.MetricCollector}.
- */
-public class AppMetrics
-{
-    @Inject
-    MetricCollector collector;
-
-    @Inject
-    BeanModelSource beanModelSource;
-
-    @Inject
-    private Messages messages;
-
-    public final BeanModel<Metric> metricModel = beanModelSource.createDisplayModel(Metric.class, messages);
-
-    public List<Metric> getRootMetrics()
-    {
-        return collector.getRootMetrics();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
deleted file mode 100644
index 3d08f30..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 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.modules;
-
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.services.HttpServletRequestFilter;
-import org.apache.tapestry5.services.HttpServletRequestHandler;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public class RootMetricsFilter implements HttpServletRequestFilter
-{
-
-    private final Metric count, requestTime;
-
-    public RootMetricsFilter(MetricCollector collector)
-    {
-        count = collector.createRootMetric("request-count", Metric.Type.TOTAL, Metric.Units.COUNTER);
-        requestTime = collector.createRootMetric("request-time", Metric.Type.RATE, Metric.Units.MILLISECONDS);
-    }
-
-    public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler) throws IOException
-    {
-        long start = System.currentTimeMillis();
-
-        boolean handled = handler.service(request, response);
-
-        // We don't count the unhandled requests
-
-        if (handled) {
-            count.increment();
-            requestTime.accumulate(System.currentTimeMillis() - start);
-        }
-
-        return handled;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index 4f567b9..0dbe078 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -108,7 +108,7 @@ import java.util.regex.Pattern;
  */
 @Marker(Core.class)
 @SubModule(
-        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class, WebMetricsModule.class})
+        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class})
 public final class TapestryModule
 {
     private final PipelineBuilder pipelineBuilder;

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
deleted file mode 100644
index 7778e94..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 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.modules;
-
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.services.HttpServletRequestFilter;
-import org.apache.tapestry5.services.HttpServletRequestHandler;
-
-/**
- * Responsible for contributing filters in various places, to handle metrics collection.
- *
- * @since 5.4
- */
-public class WebMetricsModule
-{
-    @Contribute(HttpServletRequestHandler.class)
-    public static void addRootFilter(OrderedConfiguration<HttpServletRequestFilter> configuration)
-    {
-        configuration.addInstance("RootMetrics", RootMetricsFilter.class, "before:GZip");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
deleted file mode 100644
index 736698a..0000000
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
+++ /dev/null
@@ -1,6 +0,0 @@
-<t:block id="content" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
-        >
-
-    <t:grid source="rootMetrics" model="metricModel"/>"
-
-</t:block>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
index b08f585..e890f7e 100644
--- a/tapestry-ioc/build.gradle
+++ b/tapestry-ioc/build.gradle
@@ -17,8 +17,6 @@ dependencies {
     testCompile "org.spockframework:spock-core:${versions.spock}"
     testCompile "commons-lang:commons-lang:2.6"
 
-    compile "org.rrd4j:rrd4j:2.1.1"
-
     provided "org.testng:testng:${versions.testng}", { transitive = false }
 }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
deleted file mode 100644
index 51cf1c9..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 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.ioc.internal.services.metrics;
-
-import org.apache.tapestry5.func.F;
-import org.apache.tapestry5.ioc.annotations.PostInjection;
-import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.internal.util.LockSupport;
-import org.apache.tapestry5.ioc.services.cron.IntervalSchedule;
-import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor;
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
-import org.apache.tapestry5.ioc.util.ExceptionUtils;
-import org.rrd4j.ConsolFun;
-import org.rrd4j.DsType;
-import org.rrd4j.core.*;
-import org.slf4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-
-@PreventServiceDecoration
-public class MetricCollectorImpl extends LockSupport implements MetricCollector, Runnable
-{
-    private final boolean inMemory;
-
-    private final RrdBackendFactory factory;
-
-    private final Logger logger;
-
-    private final String dbDir;
-
-    private final List<Runnable> updates = CollectionFactory.newThreadSafeList();
-
-    public static final int HEARTBEAT = 10; // seconds
-
-    public static final String DS_NAME = "data";
-
-    public class MetricImpl extends LockSupport implements Metric, Comparable<MetricImpl>, Runnable
-    {
-        private final MetricImpl parent;
-
-        private final Map<String, Metric> children = new HashMap<String, Metric>();
-
-        private final String name;
-
-        private final String path;
-
-        private final Type type;
-
-        private final Units units;
-
-        private final RrdDb db;
-
-        // TODO: May want to initialize this from stored data for Type.TOTAL
-
-        private final AtomicReference<Double> accumulator = new AtomicReference<Double>(0d);
-
-        MetricImpl(MetricImpl parent, String name, Type type, Units units)
-        {
-            this.name = name;
-            assert InternalUtils.isNonBlank(name);
-            assert type != null;
-            assert units != null;
-
-            this.parent = parent;
-
-            // Parent may be null for a root Metric
-            this.path = parent == null ? name : parent.getPath() + "/" + name;
-
-            this.type = type;
-            this.units = units;
-
-            try
-            {
-                this.db = createDb();
-            } catch (IOException ex)
-            {
-                throw new RuntimeException(String.format("Unable to create RrdDb for '%s': %s",
-                        path,
-                        ExceptionUtils.toMessage(ex)), ex);
-            }
-
-            updates.add(this);
-        }
-
-        private RrdDb createDb() throws IOException
-        {
-
-            if (inMemory)
-            {
-                return new RrdDb(createDef(path), factory);
-            }
-
-            // TODO: If we want to support other options, such as Mongo or Berkley, we'll need
-            // to abstract the RRDb factory a bit further!
-
-            String filePath = dbDir + "/" + path + ".rrdb";
-
-            File dbFile = new File(filePath);
-            dbFile.getParentFile().mkdirs();
-
-            if (dbFile.exists())
-            {
-                return new RrdDb(filePath, factory);
-            }
-
-            return new RrdDb(createDef(filePath), factory);
-        }
-
-        private RrdDef createDef(String filePath)
-        {
-            RrdDef result = new RrdDef(filePath, HEARTBEAT);
-
-            result.addDatasource(DS_NAME, DsType.COUNTER, HEARTBEAT, 0, Double.NaN);
-            // One archive: average for each new data point, 10 minutes worth.
-            result.addArchive(new ArcDef(ConsolFun.AVERAGE, .5, 1, 60));
-
-            return result;
-        }
-
-        public int compareTo(MetricImpl o)
-        {
-            return this.name.compareTo(o.name);
-        }
-
-        public Metric createChild(String name)
-        {
-            assert InternalUtils.isNonBlank(name);
-
-            try
-            {
-                acquireReadLock();
-
-                Metric child = children.get(name);
-
-                if (child == null)
-                {
-                    try
-                    {
-                        upgradeReadLockToWriteLock();
-
-                        // Could be a race ...
-
-                        child = children.get(name);
-
-                        if (child == null)
-                        {
-                            child = new MetricImpl(this, name, type, units);
-
-                            children.put(name, child);
-                        }
-                    } finally
-                    {
-                        downgradeWriteLockToReadLock();
-                    }
-                }
-
-                return child;
-
-            } finally
-            {
-                releaseReadLock();
-            }
-        }
-
-        public String getPath()
-        {
-            return path;
-        }
-
-        public Type getType()
-        {
-            return type;
-        }
-
-        public Units getUnits()
-        {
-            return units;
-        }
-
-        public void increment()
-        {
-            accumulate(1);
-        }
-
-        public void accumulate(double value)
-        {
-            while (true)
-            {
-                Double current = accumulator.get();
-                Double updated = current + value;
-
-                // This is where an Atomic is better than a simple volatile, we can detect
-                // when a race condition would have caused the loss of data by overlapping
-                // read-and-increment operations. Still miss Clojure's approach, of course.
-
-                if (accumulator.compareAndSet(current, updated))
-                {
-                    break;
-                }
-            }
-
-            if (parent != null)
-            {
-                parent.accumulate(value);
-            }
-        }
-
-        public List<Metric> getChildren()
-        {
-            try
-            {
-                acquireReadLock();
-
-                return F.flow(children.values()).sort().toList();
-            } finally
-            {
-                releaseReadLock();
-            }
-        }
-
-        public Date getLastUpdateTime()
-        {
-            try
-            {
-                return new Date(db.getLastUpdateTime());
-            } catch (IOException ex)
-            {
-                return null;
-            }
-        }
-
-        public void run()
-        {
-            try
-            {
-                db.createSample().setValue(DS_NAME, accumulator.getAndSet(0d)).update();
-            } catch (IOException ex)
-            {
-                logger.error(String.format("Unable to update database for metric '%s': %s",
-                        path,
-                        ExceptionUtils.toMessage(ex)), ex);
-            }
-        }
-    }
-
-    private final Map<String, Metric> rootMetrics = new HashMap<String, Metric>();
-
-    public MetricCollectorImpl(Logger logger, @Symbol(MetricsSymbols.RRD_DB_DIR) String dbDir)
-    {
-        this.logger = logger;
-        this.dbDir = dbDir;
-
-        inMemory = dbDir.equals("");
-
-        factory = inMemory ? new RrdMemoryBackendFactory() : new RrdNioBackendFactory();
-
-        logger.info(String.format("Collecting metrics %s.",
-                inMemory ? "in memory" : (" to" + dbDir)));
-    }
-
-
-    public Metric createRootMetric(String name, Metric.Type type, Metric.Units units)
-    {
-
-        try
-        {
-            acquireReadLock();
-
-            Metric result = rootMetrics.get(name);
-
-            if (result == null)
-            {
-                try
-                {
-                    upgradeReadLockToWriteLock();
-
-                    // There's a window where another thread may create the metric instead.
-
-                    result = rootMetrics.get(name);
-
-                    // But in the normal case, that won't happen and this thread has the exclusive
-                    // write lock to create and cache the new metric.
-                    if (result == null)
-                    {
-
-                        result = new MetricImpl(null, name, type, units);
-
-                        rootMetrics.put(name, result);
-                    }
-                } finally
-                {
-                    downgradeWriteLockToReadLock();
-                }
-            }
-
-            if (result.getType() != type || result.getUnits() != units)
-            {
-                throw new IllegalArgumentException(String.format("Metric %s already exists and is type %s, units %s.",
-                        result.getPath(),
-                        result.getType().name(),
-                        result.getUnits().name()));
-            }
-
-            return result;
-
-        } finally
-        {
-            releaseReadLock();
-        }
-
-    }
-
-    /**
-     * Invoked every few seconds to make all the active metrics update their dbs.
-     */
-    public void run()
-    {
-        for (Runnable r : updates)
-        {
-            r.run();
-        }
-    }
-
-    @PostInjection
-    public void activatePeriodicUpdates(PeriodicExecutor executor)
-    {
-        executor.addJob(new IntervalSchedule(HEARTBEAT * 1000),
-                "UpdateMetrics", this);
-    }
-
-    public List<Metric> getRootMetrics()
-    {
-        return F.flow(rootMetrics.values()).sort().toList();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
deleted file mode 100644
index 38b2732..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.tapestry5.ioc.modules;
-
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.ioc.annotations.Marker;
-import org.apache.tapestry5.ioc.internal.services.metrics.MetricCollectorImpl;
-import org.apache.tapestry5.ioc.services.Builtin;
-import org.apache.tapestry5.ioc.services.FactoryDefaults;
-import org.apache.tapestry5.ioc.services.SymbolProvider;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
-
-@Marker(Builtin.class)
-public class MetricsModule
-{
-
-    public static void bind(ServiceBinder binder)
-    {
-        binder.bind(MetricCollector.class, MetricCollectorImpl.class);
-    }
-
-    @Contribute(SymbolProvider.class)
-    @FactoryDefaults
-    public static void provideDefaults(MappedConfiguration<String, Object> configuration)
-    {
-        configuration.add(MetricsSymbols.RRD_DB_DIR, "");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
index 178edf2..7f95181 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
@@ -1,4 +1,4 @@
-// Copyright 2006-2012 The Apache Software Foundation
+// Copyright 2006-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.
@@ -43,7 +43,6 @@ import static org.apache.tapestry5.ioc.OrderConstraintBuilder.before;
  */
 @SuppressWarnings("all")
 @Marker(Builtin.class)
-@SubModule(MetricsModule.class)
 public final class TapestryIOCModule
 {
     public static void bind(ServiceBinder binder)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
deleted file mode 100644
index 71cda59..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 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.ioc.services.metrics;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @since 5.4
- */
-public interface Metric
-{
-    enum Type
-    {
-        /**
-         * Storing a value accumulates into an ever increasing total. Example:
-         * number of burgers served.
-         */
-        TOTAL,
-
-        /**
-         * Storing a value accumulates just for the current time interval.  Example:
-         * burgers served per second.
-         */
-        RATE
-    }
-
-
-    /**
-     * Primarily used when reporting to indicate the types of values.
-     */
-    enum Units
-    {
-        /**
-         * Appropriate when measuring bytes transferred, etc.
-         */
-        BYTES,
-        /**
-         * Useful when measuring the time to produce a result, such as processing some kind of request.
-         */
-        MILLISECONDS,
-        /**
-         * Placeholder for all other kinds of units, such as "pages viewed" or "messages processed".
-         */
-        COUNTER
-    }
-
-    /**
-     * Creates a child metric with the same type and units.
-     * Values posted to the child are also posted to the container (this
-     * bubbling up can occur across several levels).
-     *
-     * @param name
-     *         child's extension to this Metric's name
-     * @return the child with the given name (creating it if necessary).
-     */
-    Metric createChild(String name);
-
-    /**
-     * Returns the path to this metric: the metric's name appended (after a slash) to the parent
-     * metric's path.
-     */
-    String getPath();
-
-    Type getType();
-
-    Units getUnits();
-
-    /**
-     * Accumulates a value of 1; useful  when the metric's type is {@link Units#COUNTER}.
-     */
-    void increment();
-
-    /**
-     * Adds the provided value to the current time interval's value. This may be called multiple times during
-     * a time interval, and the values will accumulate. In addition, {@link #accumulate(double)}
-     * propagates the value up to the parent metrics, if any, all the way up to the root metric.
-     *
-     * @param value
-     */
-    void accumulate(double value);
-
-    /**
-     * Returns the children of this metric, sorted by name.
-     */
-    List<Metric> getChildren();
-
-    /**
-     * Returns the last time the archive was updated (this happens a regular intervals called heartbeats).
-     *
-     * @return archive update time, or null if there is an exception accessing the time
-     */
-    Date getLastUpdateTime();
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
deleted file mode 100644
index e5c168f..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.tapestry5.ioc.services.metrics;
-
-import java.util.List;
-
-/**
- * Central hub for creating or obtaining {@link Metric}s.
- *
- * @since 5.4
- */
-public interface MetricCollector
-{
-    /**
-     * Creates a root metric, or returns an existing one.
-     *
-     * @param name
-     *         name of the metric to create
-     * @param type
-     *         used when creating the metric
-     * @param units
-     *         used when creating the metric
-     * @return the metric
-     * @throws IllegalMonitorStateException
-     *         if an existing root metric with that name is present, but does
-     *         not have the matching type and units.
-     */
-    Metric createRootMetric(String name, Metric.Type type, Metric.Units units);
-
-    /**
-     * Returns root metrics, sorted by name.
-     */
-    List<Metric> getRootMetrics();
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
deleted file mode 100644
index 39c9bb1..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.tapestry5.ioc.services.metrics;
-
-public class MetricsSymbols
-{
-    /**
-     * The directory in which RRDb database files are stored. If blank (the default),
-     * then RRD is set up for in-memory databases only (re-created on each launch of the application).
-     */
-    public static final String RRD_DB_DIR = "tapestry.rrd-dir";
-}


[5/5] git commit: Add fix for slow page load

Posted by hl...@apache.org.
Add fix for slow page load


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/2015f1ec
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2015f1ec
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2015f1ec

Branch: refs/heads/master
Commit: 2015f1ece5723d327190b8cdd2e006db678ab4e2
Parents: 378986b
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:59:50 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:59:50 2013 -0700

----------------------------------------------------------------------
 .../itest/YUICompressorIntegrationTests.groovy     |   19 +++++++++-----
 1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2015f1ec/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy b/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
index 5c091a0..76757f8 100644
--- a/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
+++ b/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
@@ -1,4 +1,4 @@
-// Copyright 2011, 2012 The Apache Software Foundation
+// Copyright 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.
@@ -15,12 +15,12 @@
 package org.apache.tapestry5.yuicompressor.itest
 
 import org.apache.tapestry5.test.SeleniumTestCase
-import org.apache.tapestry5.test.TapestryTestConfiguration;
-import org.testng.annotations.Test;
+import org.apache.tapestry5.test.TapestryTestConfiguration
+import org.testng.annotations.Test
 
 @TapestryTestConfiguration(webAppFolder = "src/test/webapp")
-class YUICompressorIntegrationTests extends SeleniumTestCase
-{
+class YUICompressorIntegrationTests extends SeleniumTestCase {
+
     def AVAILABLE_OPTIONS = "css=.t-palette-available select";
 
     def SELECT_BUTTON = "css=.t-palette [data-action=select]";
@@ -30,6 +30,11 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         openBaseURL()
 
+        // Added this sleep in 5.4; necessary since JS is compressed
+        // during initial page render, not on subsequent request to
+        // load the JS.
+        sleep 500
+
         waitForPageInitialized()
 
         addSelection AVAILABLE_OPTIONS, "label=Clojure"
@@ -37,7 +42,7 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         addSelection AVAILABLE_OPTIONS, "label=Java"
         click SELECT_BUTTON
-        
+
         clickAndWait SUBMIT
 
         waitForPageInitialized()
@@ -53,4 +58,4 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         assertTitle "Tapestry 5: Bad JavaScript Demo"
     }
-}
+}
\ No newline at end of file


[2/5] git commit: Strip out the metrics support

Posted by hl...@apache.org.
Strip out the metrics support


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/4fda4c80
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/4fda4c80
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/4fda4c80

Branch: refs/heads/master
Commit: 4fda4c803dc40bb164dff4203d8358c0e3996c85
Parents: 53443f2
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:34:07 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:34:07 2013 -0700

----------------------------------------------------------------------
 .../apache/tapestry5/corelib/pages/AppMetrics.java |   48 --
 .../tapestry5/modules/RootMetricsFilter.java       |   52 ---
 .../apache/tapestry5/modules/TapestryModule.java   |    2 +-
 .../apache/tapestry5/modules/WebMetricsModule.java |   34 --
 .../apache/tapestry5/corelib/pages/AppMetrics.tml  |    6 -
 tapestry-ioc/build.gradle                          |    2 -
 .../services/metrics/MetricCollectorImpl.java      |  358 ---------------
 .../tapestry5/ioc/modules/MetricsModule.java       |   29 --
 .../tapestry5/ioc/modules/TapestryIOCModule.java   |    3 +-
 .../tapestry5/ioc/services/metrics/Metric.java     |  106 -----
 .../ioc/services/metrics/MetricCollector.java      |   32 --
 .../ioc/services/metrics/MetricsSymbols.java       |   10 -
 12 files changed, 2 insertions(+), 680 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
deleted file mode 100644
index d57b75c..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/AppMetrics.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 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.annotations.WhitelistAccessOnly;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.services.BeanModelSource;
-
-import java.util.List;
-
-@WhitelistAccessOnly
-/**
- * Contributes to the {@link T5Dashboard} page, providing application metrics from the {@link org.apache.tapestry5.ioc.services.metrics.MetricCollector}.
- */
-public class AppMetrics
-{
-    @Inject
-    MetricCollector collector;
-
-    @Inject
-    BeanModelSource beanModelSource;
-
-    @Inject
-    private Messages messages;
-
-    public final BeanModel<Metric> metricModel = beanModelSource.createDisplayModel(Metric.class, messages);
-
-    public List<Metric> getRootMetrics()
-    {
-        return collector.getRootMetrics();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
deleted file mode 100644
index 3d08f30..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/RootMetricsFilter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 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.modules;
-
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.services.HttpServletRequestFilter;
-import org.apache.tapestry5.services.HttpServletRequestHandler;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public class RootMetricsFilter implements HttpServletRequestFilter
-{
-
-    private final Metric count, requestTime;
-
-    public RootMetricsFilter(MetricCollector collector)
-    {
-        count = collector.createRootMetric("request-count", Metric.Type.TOTAL, Metric.Units.COUNTER);
-        requestTime = collector.createRootMetric("request-time", Metric.Type.RATE, Metric.Units.MILLISECONDS);
-    }
-
-    public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler) throws IOException
-    {
-        long start = System.currentTimeMillis();
-
-        boolean handled = handler.service(request, response);
-
-        // We don't count the unhandled requests
-
-        if (handled) {
-            count.increment();
-            requestTime.accumulate(System.currentTimeMillis() - start);
-        }
-
-        return handled;
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
index 4f567b9..0dbe078 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/modules/TapestryModule.java
@@ -108,7 +108,7 @@ import java.util.regex.Pattern;
  */
 @Marker(Core.class)
 @SubModule(
-        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class, WebMetricsModule.class})
+        {InternalModule.class, AssetsModule.class, PageLoadModule.class, JavaScriptModule.class, CompatibilityModule.class, DashboardModule.class})
 public final class TapestryModule
 {
     private final PipelineBuilder pipelineBuilder;

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
deleted file mode 100644
index 7778e94..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/modules/WebMetricsModule.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 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.modules;
-
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.services.HttpServletRequestFilter;
-import org.apache.tapestry5.services.HttpServletRequestHandler;
-
-/**
- * Responsible for contributing filters in various places, to handle metrics collection.
- *
- * @since 5.4
- */
-public class WebMetricsModule
-{
-    @Contribute(HttpServletRequestHandler.class)
-    public static void addRootFilter(OrderedConfiguration<HttpServletRequestFilter> configuration)
-    {
-        configuration.addInstance("RootMetrics", RootMetricsFilter.class, "before:GZip");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml b/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
deleted file mode 100644
index 736698a..0000000
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/pages/AppMetrics.tml
+++ /dev/null
@@ -1,6 +0,0 @@
-<t:block id="content" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
-        >
-
-    <t:grid source="rootMetrics" model="metricModel"/>"
-
-</t:block>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
index b08f585..e890f7e 100644
--- a/tapestry-ioc/build.gradle
+++ b/tapestry-ioc/build.gradle
@@ -17,8 +17,6 @@ dependencies {
     testCompile "org.spockframework:spock-core:${versions.spock}"
     testCompile "commons-lang:commons-lang:2.6"
 
-    compile "org.rrd4j:rrd4j:2.1.1"
-
     provided "org.testng:testng:${versions.testng}", { transitive = false }
 }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
deleted file mode 100644
index 51cf1c9..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 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.ioc.internal.services.metrics;
-
-import org.apache.tapestry5.func.F;
-import org.apache.tapestry5.ioc.annotations.PostInjection;
-import org.apache.tapestry5.ioc.annotations.PreventServiceDecoration;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.internal.util.LockSupport;
-import org.apache.tapestry5.ioc.services.cron.IntervalSchedule;
-import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor;
-import org.apache.tapestry5.ioc.services.metrics.Metric;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
-import org.apache.tapestry5.ioc.util.ExceptionUtils;
-import org.rrd4j.ConsolFun;
-import org.rrd4j.DsType;
-import org.rrd4j.core.*;
-import org.slf4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-
-@PreventServiceDecoration
-public class MetricCollectorImpl extends LockSupport implements MetricCollector, Runnable
-{
-    private final boolean inMemory;
-
-    private final RrdBackendFactory factory;
-
-    private final Logger logger;
-
-    private final String dbDir;
-
-    private final List<Runnable> updates = CollectionFactory.newThreadSafeList();
-
-    public static final int HEARTBEAT = 10; // seconds
-
-    public static final String DS_NAME = "data";
-
-    public class MetricImpl extends LockSupport implements Metric, Comparable<MetricImpl>, Runnable
-    {
-        private final MetricImpl parent;
-
-        private final Map<String, Metric> children = new HashMap<String, Metric>();
-
-        private final String name;
-
-        private final String path;
-
-        private final Type type;
-
-        private final Units units;
-
-        private final RrdDb db;
-
-        // TODO: May want to initialize this from stored data for Type.TOTAL
-
-        private final AtomicReference<Double> accumulator = new AtomicReference<Double>(0d);
-
-        MetricImpl(MetricImpl parent, String name, Type type, Units units)
-        {
-            this.name = name;
-            assert InternalUtils.isNonBlank(name);
-            assert type != null;
-            assert units != null;
-
-            this.parent = parent;
-
-            // Parent may be null for a root Metric
-            this.path = parent == null ? name : parent.getPath() + "/" + name;
-
-            this.type = type;
-            this.units = units;
-
-            try
-            {
-                this.db = createDb();
-            } catch (IOException ex)
-            {
-                throw new RuntimeException(String.format("Unable to create RrdDb for '%s': %s",
-                        path,
-                        ExceptionUtils.toMessage(ex)), ex);
-            }
-
-            updates.add(this);
-        }
-
-        private RrdDb createDb() throws IOException
-        {
-
-            if (inMemory)
-            {
-                return new RrdDb(createDef(path), factory);
-            }
-
-            // TODO: If we want to support other options, such as Mongo or Berkley, we'll need
-            // to abstract the RRDb factory a bit further!
-
-            String filePath = dbDir + "/" + path + ".rrdb";
-
-            File dbFile = new File(filePath);
-            dbFile.getParentFile().mkdirs();
-
-            if (dbFile.exists())
-            {
-                return new RrdDb(filePath, factory);
-            }
-
-            return new RrdDb(createDef(filePath), factory);
-        }
-
-        private RrdDef createDef(String filePath)
-        {
-            RrdDef result = new RrdDef(filePath, HEARTBEAT);
-
-            result.addDatasource(DS_NAME, DsType.COUNTER, HEARTBEAT, 0, Double.NaN);
-            // One archive: average for each new data point, 10 minutes worth.
-            result.addArchive(new ArcDef(ConsolFun.AVERAGE, .5, 1, 60));
-
-            return result;
-        }
-
-        public int compareTo(MetricImpl o)
-        {
-            return this.name.compareTo(o.name);
-        }
-
-        public Metric createChild(String name)
-        {
-            assert InternalUtils.isNonBlank(name);
-
-            try
-            {
-                acquireReadLock();
-
-                Metric child = children.get(name);
-
-                if (child == null)
-                {
-                    try
-                    {
-                        upgradeReadLockToWriteLock();
-
-                        // Could be a race ...
-
-                        child = children.get(name);
-
-                        if (child == null)
-                        {
-                            child = new MetricImpl(this, name, type, units);
-
-                            children.put(name, child);
-                        }
-                    } finally
-                    {
-                        downgradeWriteLockToReadLock();
-                    }
-                }
-
-                return child;
-
-            } finally
-            {
-                releaseReadLock();
-            }
-        }
-
-        public String getPath()
-        {
-            return path;
-        }
-
-        public Type getType()
-        {
-            return type;
-        }
-
-        public Units getUnits()
-        {
-            return units;
-        }
-
-        public void increment()
-        {
-            accumulate(1);
-        }
-
-        public void accumulate(double value)
-        {
-            while (true)
-            {
-                Double current = accumulator.get();
-                Double updated = current + value;
-
-                // This is where an Atomic is better than a simple volatile, we can detect
-                // when a race condition would have caused the loss of data by overlapping
-                // read-and-increment operations. Still miss Clojure's approach, of course.
-
-                if (accumulator.compareAndSet(current, updated))
-                {
-                    break;
-                }
-            }
-
-            if (parent != null)
-            {
-                parent.accumulate(value);
-            }
-        }
-
-        public List<Metric> getChildren()
-        {
-            try
-            {
-                acquireReadLock();
-
-                return F.flow(children.values()).sort().toList();
-            } finally
-            {
-                releaseReadLock();
-            }
-        }
-
-        public Date getLastUpdateTime()
-        {
-            try
-            {
-                return new Date(db.getLastUpdateTime());
-            } catch (IOException ex)
-            {
-                return null;
-            }
-        }
-
-        public void run()
-        {
-            try
-            {
-                db.createSample().setValue(DS_NAME, accumulator.getAndSet(0d)).update();
-            } catch (IOException ex)
-            {
-                logger.error(String.format("Unable to update database for metric '%s': %s",
-                        path,
-                        ExceptionUtils.toMessage(ex)), ex);
-            }
-        }
-    }
-
-    private final Map<String, Metric> rootMetrics = new HashMap<String, Metric>();
-
-    public MetricCollectorImpl(Logger logger, @Symbol(MetricsSymbols.RRD_DB_DIR) String dbDir)
-    {
-        this.logger = logger;
-        this.dbDir = dbDir;
-
-        inMemory = dbDir.equals("");
-
-        factory = inMemory ? new RrdMemoryBackendFactory() : new RrdNioBackendFactory();
-
-        logger.info(String.format("Collecting metrics %s.",
-                inMemory ? "in memory" : (" to" + dbDir)));
-    }
-
-
-    public Metric createRootMetric(String name, Metric.Type type, Metric.Units units)
-    {
-
-        try
-        {
-            acquireReadLock();
-
-            Metric result = rootMetrics.get(name);
-
-            if (result == null)
-            {
-                try
-                {
-                    upgradeReadLockToWriteLock();
-
-                    // There's a window where another thread may create the metric instead.
-
-                    result = rootMetrics.get(name);
-
-                    // But in the normal case, that won't happen and this thread has the exclusive
-                    // write lock to create and cache the new metric.
-                    if (result == null)
-                    {
-
-                        result = new MetricImpl(null, name, type, units);
-
-                        rootMetrics.put(name, result);
-                    }
-                } finally
-                {
-                    downgradeWriteLockToReadLock();
-                }
-            }
-
-            if (result.getType() != type || result.getUnits() != units)
-            {
-                throw new IllegalArgumentException(String.format("Metric %s already exists and is type %s, units %s.",
-                        result.getPath(),
-                        result.getType().name(),
-                        result.getUnits().name()));
-            }
-
-            return result;
-
-        } finally
-        {
-            releaseReadLock();
-        }
-
-    }
-
-    /**
-     * Invoked every few seconds to make all the active metrics update their dbs.
-     */
-    public void run()
-    {
-        for (Runnable r : updates)
-        {
-            r.run();
-        }
-    }
-
-    @PostInjection
-    public void activatePeriodicUpdates(PeriodicExecutor executor)
-    {
-        executor.addJob(new IntervalSchedule(HEARTBEAT * 1000),
-                "UpdateMetrics", this);
-    }
-
-    public List<Metric> getRootMetrics()
-    {
-        return F.flow(rootMetrics.values()).sort().toList();
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
deleted file mode 100644
index 38b2732..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.tapestry5.ioc.modules;
-
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.ioc.annotations.Marker;
-import org.apache.tapestry5.ioc.internal.services.metrics.MetricCollectorImpl;
-import org.apache.tapestry5.ioc.services.Builtin;
-import org.apache.tapestry5.ioc.services.FactoryDefaults;
-import org.apache.tapestry5.ioc.services.SymbolProvider;
-import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
-import org.apache.tapestry5.ioc.services.metrics.MetricsSymbols;
-
-@Marker(Builtin.class)
-public class MetricsModule
-{
-
-    public static void bind(ServiceBinder binder)
-    {
-        binder.bind(MetricCollector.class, MetricCollectorImpl.class);
-    }
-
-    @Contribute(SymbolProvider.class)
-    @FactoryDefaults
-    public static void provideDefaults(MappedConfiguration<String, Object> configuration)
-    {
-        configuration.add(MetricsSymbols.RRD_DB_DIR, "");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
index 178edf2..7f95181 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/TapestryIOCModule.java
@@ -1,4 +1,4 @@
-// Copyright 2006-2012 The Apache Software Foundation
+// Copyright 2006-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.
@@ -43,7 +43,6 @@ import static org.apache.tapestry5.ioc.OrderConstraintBuilder.before;
  */
 @SuppressWarnings("all")
 @Marker(Builtin.class)
-@SubModule(MetricsModule.class)
 public final class TapestryIOCModule
 {
     public static void bind(ServiceBinder binder)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
deleted file mode 100644
index 71cda59..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 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.ioc.services.metrics;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @since 5.4
- */
-public interface Metric
-{
-    enum Type
-    {
-        /**
-         * Storing a value accumulates into an ever increasing total. Example:
-         * number of burgers served.
-         */
-        TOTAL,
-
-        /**
-         * Storing a value accumulates just for the current time interval.  Example:
-         * burgers served per second.
-         */
-        RATE
-    }
-
-
-    /**
-     * Primarily used when reporting to indicate the types of values.
-     */
-    enum Units
-    {
-        /**
-         * Appropriate when measuring bytes transferred, etc.
-         */
-        BYTES,
-        /**
-         * Useful when measuring the time to produce a result, such as processing some kind of request.
-         */
-        MILLISECONDS,
-        /**
-         * Placeholder for all other kinds of units, such as "pages viewed" or "messages processed".
-         */
-        COUNTER
-    }
-
-    /**
-     * Creates a child metric with the same type and units.
-     * Values posted to the child are also posted to the container (this
-     * bubbling up can occur across several levels).
-     *
-     * @param name
-     *         child's extension to this Metric's name
-     * @return the child with the given name (creating it if necessary).
-     */
-    Metric createChild(String name);
-
-    /**
-     * Returns the path to this metric: the metric's name appended (after a slash) to the parent
-     * metric's path.
-     */
-    String getPath();
-
-    Type getType();
-
-    Units getUnits();
-
-    /**
-     * Accumulates a value of 1; useful  when the metric's type is {@link Units#COUNTER}.
-     */
-    void increment();
-
-    /**
-     * Adds the provided value to the current time interval's value. This may be called multiple times during
-     * a time interval, and the values will accumulate. In addition, {@link #accumulate(double)}
-     * propagates the value up to the parent metrics, if any, all the way up to the root metric.
-     *
-     * @param value
-     */
-    void accumulate(double value);
-
-    /**
-     * Returns the children of this metric, sorted by name.
-     */
-    List<Metric> getChildren();
-
-    /**
-     * Returns the last time the archive was updated (this happens a regular intervals called heartbeats).
-     *
-     * @return archive update time, or null if there is an exception accessing the time
-     */
-    Date getLastUpdateTime();
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
deleted file mode 100644
index e5c168f..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.tapestry5.ioc.services.metrics;
-
-import java.util.List;
-
-/**
- * Central hub for creating or obtaining {@link Metric}s.
- *
- * @since 5.4
- */
-public interface MetricCollector
-{
-    /**
-     * Creates a root metric, or returns an existing one.
-     *
-     * @param name
-     *         name of the metric to create
-     * @param type
-     *         used when creating the metric
-     * @param units
-     *         used when creating the metric
-     * @return the metric
-     * @throws IllegalMonitorStateException
-     *         if an existing root metric with that name is present, but does
-     *         not have the matching type and units.
-     */
-    Metric createRootMetric(String name, Metric.Type type, Metric.Units units);
-
-    /**
-     * Returns root metrics, sorted by name.
-     */
-    List<Metric> getRootMetrics();
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/4fda4c80/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
deleted file mode 100644
index 39c9bb1..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricsSymbols.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.tapestry5.ioc.services.metrics;
-
-public class MetricsSymbols
-{
-    /**
-     * The directory in which RRDb database files are stored. If blank (the default),
-     * then RRD is set up for in-memory databases only (re-created on each launch of the application).
-     */
-    public static final String RRD_DB_DIR = "tapestry.rrd-dir";
-}


[4/5] git commit: Inline the generation of message strings

Posted by hl...@apache.org.
Inline the generation of message strings


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/378986b1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/378986b1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/378986b1

Branch: refs/heads/master
Commit: 378986b178a3889f74707602db3862ac7e55d769
Parents: 43598e0
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:53:58 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:53:58 2013 -0700

----------------------------------------------------------------------
 .../internal/hibernate/HibernateCoreMessages.java  |   36 --------------
 .../hibernate/HibernateSessionSourceImpl.java      |    8 ++--
 .../hibernate/HibernateCoreStrings.properties      |   16 ------
 .../hibernate/EntityPersistentFieldStrategy.java   |    4 +-
 .../internal/hibernate/HibernateMessages.java      |   38 ---------------
 .../internal/hibernate/PersistedEntity.java        |    4 +-
 .../internal/hibernate/HibernateStrings.properties |   17 -------
 7 files changed, 8 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
deleted file mode 100644
index 0edf93c..0000000
--- a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateCoreMessages.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2008, 2010 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.hibernate;
-
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
-
-import java.util.Collection;
-
-public class HibernateCoreMessages
-{
-    private static final Messages MESSAGES = MessagesImpl.forClass(HibernateCoreMessages.class);
-
-    public static String startupTiming(long toConfigure, long overall)
-    {
-        return MESSAGES.format("startup-timing", toConfigure, overall);
-    }
-
-    public static String entityCatalog(Collection entityNames)
-    {
-        return MESSAGES.format("entity-catalog", InternalUtils.joinSorted(entityNames));
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
index eaece53..615016e 100644
--- a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
+++ b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateSessionSourceImpl.java
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2011 The Apache Software Foundation
+// Copyright 2007-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.
@@ -17,10 +17,10 @@ package org.apache.tapestry5.internal.hibernate;
 import org.apache.tapestry5.hibernate.HibernateConfigurer;
 import org.apache.tapestry5.hibernate.HibernateSessionSource;
 import org.apache.tapestry5.ioc.annotations.PostInjection;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.cfg.Configuration;
 import org.slf4j.Logger;
 
@@ -47,9 +47,9 @@ public class HibernateSessionSourceImpl implements HibernateSessionSource
 
         long factoryCreated = System.currentTimeMillis();
 
-        logger.info(HibernateCoreMessages.startupTiming(configurationComplete - startTime, factoryCreated - startTime));
+        logger.info(String.format("Hibernate startup: %,d ms to configure, %,d ms overall.", configurationComplete - startTime, factoryCreated - startTime));
 
-        logger.info(HibernateCoreMessages.entityCatalog(sessionFactory.getAllClassMetadata().keySet()));
+        logger.info(String.format("Configured Hibernate entities: %s", InternalUtils.joinSorted(sessionFactory.getAllClassMetadata().keySet())));
     }
 
     @PostInjection

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties b/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
deleted file mode 100644
index f90ff8d..0000000
--- a/tapestry-hibernate-core/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateCoreStrings.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2008, 2010 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.
-
-startup-timing=Hibernate startup: %,d ms to configure, %,d ms overall.
-entity-catalog=Configured Hibernate entities: %s

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
index f5e6f2f..d651352 100644
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/EntityPersistentFieldStrategy.java
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008m 2913 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.
@@ -49,7 +49,7 @@ public class EntityPersistentFieldStrategy extends AbstractSessionPersistentFiel
         }
         catch (HibernateException ex)
         {
-            throw new IllegalArgumentException(HibernateMessages.entityNotAttached(newValue), ex);
+            throw new IllegalArgumentException(String.format("Failed persisting an entity in the session. Only entities attached to a Hibernate Session can be persisted. entity: %s", newValue), ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
deleted file mode 100644
index a498c5b..0000000
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/HibernateMessages.java
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2007, 2008, 2010 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.hibernate;
-
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
-
-public class HibernateMessages
-{
-    private static final Messages MESSAGES = MessagesImpl.forClass(HibernateMessages.class);
-
-    public static String sessionPersistedEntityLoadFailure(String entityName, Object id, Throwable cause)
-    {
-        return MESSAGES.format("session-persisted-entity-load-failure", entityName, id, cause);
-    }
-
-    public static String entityNotAttached(Object entity)
-    {
-        return MESSAGES.format("entity-not-attached", entity);
-    }
-
-    public static String commitTransactionInterceptor(String serviceId, Class serviceInterface)
-    {
-        return MESSAGES.format("commit-transaction-interceptor", serviceId, serviceInterface.getName());
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
index 18fe5fd..51d3088 100644
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/PersistedEntity.java
@@ -1,4 +1,4 @@
-// Copyright 2008, 2010 The Apache Software Foundation
+// Copyright 2008, 2010, 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.
@@ -45,7 +45,7 @@ public class PersistedEntity implements Serializable
         }
         catch (Exception ex)
         {
-            throw new RuntimeException(HibernateMessages.sessionPersistedEntityLoadFailure(entityName, id, ex));
+            throw new RuntimeException(String.format("Failed to load session-persisted entity %s(%s): %s", entityName, id, ex));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/378986b1/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties b/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
deleted file mode 100644
index 7eda452..0000000
--- a/tapestry-hibernate/src/main/resources/org/apache/tapestry5/internal/hibernate/HibernateStrings.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2007, 2008 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.
-
-session-persisted-entity-load-failure=Failed to load session-persisted entity %s(%s): %s
-entity-not-attached=Failed persisting an entity in the session. Only entities attached to a Hibernate Session can be persisted. entity: %s
-commit-transaction-interceptor=<Hibernate Transaction interceptor for %s(%s)>


[5/5] git commit: Add fix for slow page load

Posted by hl...@apache.org.
Add fix for slow page load


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/2015f1ec
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2015f1ec
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2015f1ec

Branch: refs/heads/master
Commit: 2015f1ece5723d327190b8cdd2e006db678ab4e2
Parents: 378986b
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:59:50 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:59:50 2013 -0700

----------------------------------------------------------------------
 .../itest/YUICompressorIntegrationTests.groovy     |   19 +++++++++-----
 1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2015f1ec/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
----------------------------------------------------------------------
diff --git a/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy b/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
index 5c091a0..76757f8 100644
--- a/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
+++ b/tapestry-yuicompressor/src/test/groovy/org/apache/tapestry5/yuicompressor/itest/YUICompressorIntegrationTests.groovy
@@ -1,4 +1,4 @@
-// Copyright 2011, 2012 The Apache Software Foundation
+// Copyright 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.
@@ -15,12 +15,12 @@
 package org.apache.tapestry5.yuicompressor.itest
 
 import org.apache.tapestry5.test.SeleniumTestCase
-import org.apache.tapestry5.test.TapestryTestConfiguration;
-import org.testng.annotations.Test;
+import org.apache.tapestry5.test.TapestryTestConfiguration
+import org.testng.annotations.Test
 
 @TapestryTestConfiguration(webAppFolder = "src/test/webapp")
-class YUICompressorIntegrationTests extends SeleniumTestCase
-{
+class YUICompressorIntegrationTests extends SeleniumTestCase {
+
     def AVAILABLE_OPTIONS = "css=.t-palette-available select";
 
     def SELECT_BUTTON = "css=.t-palette [data-action=select]";
@@ -30,6 +30,11 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         openBaseURL()
 
+        // Added this sleep in 5.4; necessary since JS is compressed
+        // during initial page render, not on subsequent request to
+        // load the JS.
+        sleep 500
+
         waitForPageInitialized()
 
         addSelection AVAILABLE_OPTIONS, "label=Clojure"
@@ -37,7 +42,7 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         addSelection AVAILABLE_OPTIONS, "label=Java"
         click SELECT_BUTTON
-        
+
         clickAndWait SUBMIT
 
         waitForPageInitialized()
@@ -53,4 +58,4 @@ class YUICompressorIntegrationTests extends SeleniumTestCase
 
         assertTitle "Tapestry 5: Bad JavaScript Demo"
     }
-}
+}
\ No newline at end of file


[3/5] git commit: Move the HibernateModule to a modules package

Posted by hl...@apache.org.
Move the HibernateModule to a modules package


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/43598e0a
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/43598e0a
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/43598e0a

Branch: refs/heads/master
Commit: 43598e0af84439e67ef2a8abb53e4a9176bd3277
Parents: 4fda4c8
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 14:35:33 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 14:35:33 2013 -0700

----------------------------------------------------------------------
 tapestry-hibernate/build.gradle                    |    2 +-
 .../tapestry5/hibernate/HibernateModule.java       |  191 --------------
 .../hibernate/modules/HibernateModule.java         |  195 +++++++++++++++
 .../java/org/example/app0/services/AppModule.java  |    2 +-
 4 files changed, 197 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/build.gradle b/tapestry-hibernate/build.gradle
index 26bbae7..73a6658 100644
--- a/tapestry-hibernate/build.gradle
+++ b/tapestry-hibernate/build.gradle
@@ -12,6 +12,6 @@ dependencies {
 
 jar {
     manifest {
-        attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.HibernateModule'
+        attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.hibernate.modules.HibernateModule'
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/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
deleted file mode 100644
index 5d73516..0000000
--- a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright 2007-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;
-
-import org.apache.tapestry5.ValueEncoder;
-import org.apache.tapestry5.internal.InternalConstants;
-import org.apache.tapestry5.internal.hibernate.CommitAfterWorker;
-import org.apache.tapestry5.internal.hibernate.EntityApplicationStatePersistenceStrategy;
-import org.apache.tapestry5.internal.hibernate.EntityPersistentFieldStrategy;
-import org.apache.tapestry5.internal.hibernate.HibernateEntityValueEncoder;
-import org.apache.tapestry5.ioc.Configuration;
-import org.apache.tapestry5.ioc.LoggerSource;
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.annotations.Contribute;
-import org.apache.tapestry5.ioc.annotations.Primary;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-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.PersistentFieldStrategy;
-import org.apache.tapestry5.services.ValueEncoderFactory;
-import org.apache.tapestry5.services.dashboard.DashboardManager;
-import org.apache.tapestry5.services.dashboard.DashboardTab;
-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.modules.HibernateCoreModule} with additional
- * services and configuration specific to Tapestry web application.
- */
-public class HibernateModule
-{
-    public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
-    {
-        configuration.add(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, "true");
-        configuration.add(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED, "false");
-    }
-
-    /**
-     * Contributes the package "&lt;root&gt;.entities" to the configuration, so that it will be scanned for annotated
-     * entity classes.
-     */
-    public static void contributeHibernateEntityPackageManager(Configuration<String> configuration,
-
-    @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
-    String appRootPackage)
-    {
-        configuration.add(appRootPackage + ".entities");
-    }
-
-    @Contribute(ServiceOverride.class)
-    public static void provideInjectableSessionObject(MappedConfiguration<Class, Object> configuration, @HibernateCore
-    Session session)
-    {
-        configuration.add(Session.class, session);
-    }
-
-    /**
-     * Contributes {@link ValueEncoderFactory}s for all registered Hibernate entity classes. Encoding and decoding are
-     * based on the id property value of the entity using type coercion. Hence, if the id can be coerced to a String and
-     * back then the entity can be coerced.
-     */
-    @SuppressWarnings("unchecked")
-    public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration,
-            @Symbol(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS)
-            boolean provideEncoders, final HibernateSessionSource sessionSource, final Session session,
-            final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource)
-    {
-        if (!provideEncoders)
-            return;
-
-        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
-        Iterator<PersistentClass> mappings = config.getClassMappings();
-        while (mappings.hasNext())
-        {
-            final PersistentClass persistentClass = mappings.next();
-            final Class entityClass = persistentClass.getMappedClass();
-
-            if (entityClass != null)
-            {
-                ValueEncoderFactory factory = new ValueEncoderFactory()
-                {
-                    public ValueEncoder create(Class type)
-                    {
-                        return new HibernateEntityValueEncoder(entityClass, persistentClass, session, propertyAccess,
-                                typeCoercer, loggerSource.getLogger(entityClass));
-                    }
-                };
-
-                configuration.add(entityClass, factory);
-
-            }
-        }
-    }
-
-    /**
-     * Contributes the following:
-     * <dl>
-     * <dt>entity</dt>
-     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
-     * </dl>
-     */
-    public static void contributePersistentFieldManager(
-            MappedConfiguration<String, PersistentFieldStrategy> configuration)
-    {
-        configuration.addInstance(HibernatePersistenceConstants.ENTITY, EntityPersistentFieldStrategy.class);
-    }
-
-    /**
-     * Contributes the following strategy:
-     * <dl>
-     * <dt>entity</dt>
-     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
-     * </dl>
-     */
-    public void contributeApplicationStatePersistenceStrategySource(
-            MappedConfiguration<String, ApplicationStatePersistenceStrategy> configuration)
-    {
-        configuration
-                .addInstance(HibernatePersistenceConstants.ENTITY, EntityApplicationStatePersistenceStrategy.class);
-    }
-
-    /**
-     * Contributes {@link ApplicationStateContribution}s for all registered Hibernate entity classes.
-     * 
-     * @param configuration
-     *            Configuration to contribute
-     * @param entitySessionStatePersistenceStrategyEnabled
-     *            indicates if contribution should take place
-     * @param sessionSource
-     *            creates Hibernate session
-     */
-    public static void contributeApplicationStateManager(
-            MappedConfiguration<Class, ApplicationStateContribution> configuration,
-            @Symbol(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED)
-            boolean entitySessionStatePersistenceStrategyEnabled, HibernateSessionSource sessionSource)
-    {
-
-        if (!entitySessionStatePersistenceStrategyEnabled)
-            return;
-
-        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
-        Iterator<PersistentClass> mappings = config.getClassMappings();
-        while (mappings.hasNext())
-        {
-
-            final PersistentClass persistentClass = mappings.next();
-            final Class entityClass = persistentClass.getMappedClass();
-
-            configuration.add(entityClass, new ApplicationStateContribution(HibernatePersistenceConstants.ENTITY));
-        }
-    }
-
-    /**
-     * Adds the CommitAfter annotation work, to process the
-     * {@link org.apache.tapestry5.hibernate.annotations.CommitAfter} annotation.
-     */
-    @Contribute(ComponentClassTransformWorker2.class)
-    @Primary
-    public static void provideCommitAfterAnnotationSupport(
-            OrderedConfiguration<ComponentClassTransformWorker2> configuration)
-    {
-        // If logging is enabled, we want logging to be the first advice, wrapping around the commit advice.
-
-        configuration.addInstance("CommitAfter", CommitAfterWorker.class, "after:Log");
-    }
-
-    @Contribute(DashboardManager.class)
-    public static void provideHibernateDashboardTab(OrderedConfiguration<DashboardTab> configuration)
-    {
-        configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "core/HibernateStatistics"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
new file mode 100644
index 0000000..a9fb486
--- /dev/null
+++ b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateModule.java
@@ -0,0 +1,195 @@
+// Copyright 2007-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.modules;
+
+import org.apache.tapestry5.ValueEncoder;
+import org.apache.tapestry5.hibernate.HibernateCore;
+import org.apache.tapestry5.hibernate.HibernatePersistenceConstants;
+import org.apache.tapestry5.hibernate.HibernateSessionSource;
+import org.apache.tapestry5.hibernate.HibernateSymbols;
+import org.apache.tapestry5.internal.InternalConstants;
+import org.apache.tapestry5.internal.hibernate.CommitAfterWorker;
+import org.apache.tapestry5.internal.hibernate.EntityApplicationStatePersistenceStrategy;
+import org.apache.tapestry5.internal.hibernate.EntityPersistentFieldStrategy;
+import org.apache.tapestry5.internal.hibernate.HibernateEntityValueEncoder;
+import org.apache.tapestry5.ioc.Configuration;
+import org.apache.tapestry5.ioc.LoggerSource;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.annotations.Primary;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+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.PersistentFieldStrategy;
+import org.apache.tapestry5.services.ValueEncoderFactory;
+import org.apache.tapestry5.services.dashboard.DashboardManager;
+import org.apache.tapestry5.services.dashboard.DashboardTab;
+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.modules.HibernateCoreModule} with additional
+ * services and configuration specific to Tapestry web application.
+ */
+public class HibernateModule
+{
+    public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
+    {
+        configuration.add(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, "true");
+        configuration.add(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED, "false");
+    }
+
+    /**
+     * Contributes the package "&lt;root&gt;.entities" to the configuration, so that it will be scanned for annotated
+     * entity classes.
+     */
+    public static void contributeHibernateEntityPackageManager(Configuration<String> configuration,
+
+                                                               @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
+                                                               String appRootPackage)
+    {
+        configuration.add(appRootPackage + ".entities");
+    }
+
+    @Contribute(ServiceOverride.class)
+    public static void provideInjectableSessionObject(MappedConfiguration<Class, Object> configuration, @HibernateCore
+    Session session)
+    {
+        configuration.add(Session.class, session);
+    }
+
+    /**
+     * Contributes {@link ValueEncoderFactory}s for all registered Hibernate entity classes. Encoding and decoding are
+     * based on the id property value of the entity using type coercion. Hence, if the id can be coerced to a String and
+     * back then the entity can be coerced.
+     */
+    @SuppressWarnings("unchecked")
+    public static void contributeValueEncoderSource(MappedConfiguration<Class, ValueEncoderFactory> configuration,
+                                                    @Symbol(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS)
+                                                    boolean provideEncoders, final HibernateSessionSource sessionSource, final Session session,
+                                                    final TypeCoercer typeCoercer, final PropertyAccess propertyAccess, final LoggerSource loggerSource)
+    {
+        if (!provideEncoders)
+            return;
+
+        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
+        Iterator<PersistentClass> mappings = config.getClassMappings();
+        while (mappings.hasNext())
+        {
+            final PersistentClass persistentClass = mappings.next();
+            final Class entityClass = persistentClass.getMappedClass();
+
+            if (entityClass != null)
+            {
+                ValueEncoderFactory factory = new ValueEncoderFactory()
+                {
+                    public ValueEncoder create(Class type)
+                    {
+                        return new HibernateEntityValueEncoder(entityClass, persistentClass, session, propertyAccess,
+                                typeCoercer, loggerSource.getLogger(entityClass));
+                    }
+                };
+
+                configuration.add(entityClass, factory);
+
+            }
+        }
+    }
+
+    /**
+     * Contributes the following:
+     * <dl>
+     * <dt>entity</dt>
+     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
+     * </dl>
+     */
+    public static void contributePersistentFieldManager(
+            MappedConfiguration<String, PersistentFieldStrategy> configuration)
+    {
+        configuration.addInstance(HibernatePersistenceConstants.ENTITY, EntityPersistentFieldStrategy.class);
+    }
+
+    /**
+     * Contributes the following strategy:
+     * <dl>
+     * <dt>entity</dt>
+     * <dd>Stores the id of the entity and reloads from the {@link Session}</dd>
+     * </dl>
+     */
+    public void contributeApplicationStatePersistenceStrategySource(
+            MappedConfiguration<String, ApplicationStatePersistenceStrategy> configuration)
+    {
+        configuration
+                .addInstance(HibernatePersistenceConstants.ENTITY, EntityApplicationStatePersistenceStrategy.class);
+    }
+
+    /**
+     * Contributes {@link ApplicationStateContribution}s for all registered Hibernate entity classes.
+     *
+     * @param configuration
+     *         Configuration to contribute
+     * @param entitySessionStatePersistenceStrategyEnabled
+     *         indicates if contribution should take place
+     * @param sessionSource
+     *         creates Hibernate session
+     */
+    public static void contributeApplicationStateManager(
+            MappedConfiguration<Class, ApplicationStateContribution> configuration,
+            @Symbol(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED)
+            boolean entitySessionStatePersistenceStrategyEnabled, HibernateSessionSource sessionSource)
+    {
+
+        if (!entitySessionStatePersistenceStrategyEnabled)
+            return;
+
+        org.hibernate.cfg.Configuration config = sessionSource.getConfiguration();
+        Iterator<PersistentClass> mappings = config.getClassMappings();
+        while (mappings.hasNext())
+        {
+
+            final PersistentClass persistentClass = mappings.next();
+            final Class entityClass = persistentClass.getMappedClass();
+
+            configuration.add(entityClass, new ApplicationStateContribution(HibernatePersistenceConstants.ENTITY));
+        }
+    }
+
+    /**
+     * Adds the CommitAfter annotation work, to process the
+     * {@link org.apache.tapestry5.hibernate.annotations.CommitAfter} annotation.
+     */
+    @Contribute(ComponentClassTransformWorker2.class)
+    @Primary
+    public static void provideCommitAfterAnnotationSupport(
+            OrderedConfiguration<ComponentClassTransformWorker2> configuration)
+    {
+        // If logging is enabled, we want logging to be the first advice, wrapping around the commit advice.
+
+        configuration.addInstance("CommitAfter", CommitAfterWorker.class, "after:Log");
+    }
+
+    @Contribute(DashboardManager.class)
+    public static void provideHibernateDashboardTab(OrderedConfiguration<DashboardTab> configuration)
+    {
+        configuration.add("HibernateStatistics", new DashboardTab("Hibernate", "core/HibernateStatistics"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/43598e0a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
----------------------------------------------------------------------
diff --git a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java b/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
index a2b24a6..0d8d994 100644
--- a/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
+++ b/tapestry-hibernate/src/test/java/org/example/app0/services/AppModule.java
@@ -15,10 +15,10 @@
 package org.example.app0.services;
 
 import org.apache.tapestry5.SymbolConstants;
-import org.apache.tapestry5.hibernate.HibernateModule;
 import org.apache.tapestry5.hibernate.HibernateSymbols;
 import org.apache.tapestry5.hibernate.HibernateTransactionDecorator;
 import org.apache.tapestry5.hibernate.modules.HibernateCoreModule;
+import org.apache.tapestry5.hibernate.modules.HibernateModule;
 import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.ServiceBinder;