tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [4/5] git commit: Inline the generation of message strings
Date Thu, 16 May 2013 22:00:10 GMT
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 <hlship@apache.org>
Authored: Thu May 16 14:53:58 2013 -0700
Committer: Howard M. Lewis Ship <hlship@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)>


Mime
View raw message