Move the HibernateCoreModule into 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/2de3d0f7
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/2de3d0f7
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/2de3d0f7

Branch: refs/heads/master
Commit: 2de3d0f77e15f8b6f05c3231665709db0887d757
Parents: 991afc8
Author: Howard M. Lewis Ship <[email protected]>
Authored: Mon Apr 22 17:02:36 2013 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Mon Apr 22 17:02:36 2013 -0700

----------------------------------------------------------------------
 tapestry-hibernate-core/build.gradle               |    2 +-
 .../apache/tapestry5/hibernate/HibernateCore.java  |    2 +-
 .../tapestry5/hibernate/HibernateCoreModule.java   |  133 ---------------
 .../hibernate/modules/HibernateCoreModule.java     |  131 ++++++++++++++
 .../tapestry5/hibernate/HibernateModule.java       |    2 +-
 .../java/org/example/app0/services/AppModule.java  |    2 +-
 6 files changed, 135 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/tapestry-hibernate-core/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-hibernate-core/build.gradle 
b/tapestry-hibernate-core/build.gradle
index 7c24a8e..3a5aec0 100644
--- a/tapestry-hibernate-core/build.gradle
+++ b/tapestry-hibernate-core/build.gradle
@@ -26,6 +26,6 @@ dependencies {
 
 jar {
     manifest {
-        attributes 'Tapestry-Module-Classes': 
'org.apache.tapestry5.hibernate.HibernateCoreModule'
+        attributes 'Tapestry-Module-Classes': 
'org.apache.tapestry5.hibernate.modules.HibernateCoreModule'
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCore.java
----------------------------------------------------------------------
diff --git 
a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCore.java
 
b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCore.java
index 776c29e..56a83c9 100644
--- 
a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCore.java
+++ 
b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCore.java
@@ -18,7 +18,7 @@ import java.lang.annotation.*;
 
 
 /**
- * Marker annotation used to identify services defined in the {@link 
org.apache.tapestry5.hibernate.HibernateCoreModule}.
+ * Marker annotation used to identify services defined in the {@link 
org.apache.tapestry5.hibernate.modules.HibernateCoreModule}.
  */
 @Target({ElementType.PARAMETER, ElementType.FIELD})
 @Retention(RetentionPolicy.RUNTIME)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
 
b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
deleted file mode 100644
index 1d0bf31..0000000
--- 
a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/HibernateCoreModule.java
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 2008, 2009, 2011 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.hibernate;
-
-import org.apache.tapestry5.internal.hibernate.*;
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.ScopeConstants;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Local;
-import org.apache.tapestry5.ioc.annotations.Marker;
-import org.apache.tapestry5.ioc.annotations.Scope;
-import org.apache.tapestry5.ioc.annotations.Symbol;
-import org.apache.tapestry5.ioc.services.PerthreadManager;
-import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
-import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
-import org.hibernate.Session;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Defines core services that support initialization of Hibernate and access 
to the Hibernate {@link
- * org.hibernate.Session}.
- */
-@SuppressWarnings({"JavaDoc"})
-@Marker(HibernateCore.class)
-public class HibernateCoreModule
-{
-    public static void bind(ServiceBinder binder)
-    {
-        binder.bind(HibernateTransactionDecorator.class, 
HibernateTransactionDecoratorImpl.class);
-        binder.bind(HibernateTransactionAdvisor.class, 
HibernateTransactionAdvisorImpl.class);
-        binder.bind(HibernateConfigurer.class, 
DefaultHibernateConfigurer.class).withSimpleId();
-        binder.bind(HibernateSessionSource.class, 
HibernateSessionSourceImpl.class);
-    }
-
-
-    public static void contributeFactoryDefaults(MappedConfiguration<String, 
String> configuration)
-    {
-        configuration.add(HibernateSymbols.DEFAULT_CONFIGURATION, "true");
-        configuration.add(HibernateSymbols.EARLY_START_UP, "false");
-    }
-
-    public static void 
contributeRegistryStartup(OrderedConfiguration<Runnable> configuration,
-
-                                                 
@Symbol(HibernateSymbols.EARLY_START_UP)
-                                                 final boolean earlyStartup,
-
-                                                 final HibernateSessionSource 
sessionSource)
-    {
-        configuration.add("HibernateStartup", new Runnable()
-        {
-            public void run()
-            {
-                if (earlyStartup)
-                    sessionSource.getConfiguration();
-            }
-        });
-    }
-
-    public static HibernateEntityPackageManager 
buildHibernateEntityPackageManager(
-            final Collection<String> packageNames)
-    {
-        return new HibernateEntityPackageManager()
-        {
-            public Collection<String> getPackageNames()
-            {
-                return packageNames;
-            }
-        };
-    }
-
-    /**
-     * The session manager manages sessions on a per-thread/per-request basis. 
Any active transaction will be rolled
-     * back at {@linkplain org.apache.tapestry5.ioc.Registry#cleanupThread() 
thread cleanup time}.  The thread is
-     * cleaned up automatically in a Tapestry web application.
-     */
-    @Scope(ScopeConstants.PERTHREAD)
-    public static HibernateSessionManager 
buildHibernateSessionManager(HibernateSessionSource sessionSource,
-                                                                       
PerthreadManager perthreadManager)
-    {
-        HibernateSessionManagerImpl service = new 
HibernateSessionManagerImpl(sessionSource);
-
-        perthreadManager.addThreadCleanupListener(service);
-
-        return service;
-    }
-
-    public static Session buildSession(HibernateSessionManager sessionManager,
-                                       PropertyShadowBuilder 
propertyShadowBuilder)
-    {
-        // Here's the thing: the tapestry.hibernate.Session class doesn't have 
to be per-thread,
-        // since
-        // it will invoke getSession() on the HibernateSessionManager service 
(which is per-thread).
-        // On
-        // first invocation per request,
-        // this forces the HSM into existence (which creates the session and 
begins the
-        // transaction).
-        // Thus we don't actually create
-        // a session until we first try to access it, then the session 
continues to exist for the
-        // rest
-        // of the request.
-
-        return propertyShadowBuilder.build(sessionManager, "session", 
Session.class);
-    }
-
-    /**
-     * Adds the following configurers: <dl> <dt>Default <dd> performs default 
hibernate configuration <dt>PackageName
-     * <dd> loads entities by package name</dl>
-     */
-    public static void 
contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> 
config,
-
-                                                        @Local
-                                                        HibernateConfigurer 
defaultHibernateConfigurer)
-    {
-        config.add("Default", defaultHibernateConfigurer);
-        config.addInstance("PackageName", 
PackageNameHibernateConfigurer.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateCoreModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateCoreModule.java
 
b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateCoreModule.java
new file mode 100644
index 0000000..e759a33
--- /dev/null
+++ 
b/tapestry-hibernate-core/src/main/java/org/apache/tapestry5/hibernate/modules/HibernateCoreModule.java
@@ -0,0 +1,131 @@
+// Copyright 2008, 2009, 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.hibernate.modules;
+
+import org.apache.tapestry5.hibernate.*;
+import org.apache.tapestry5.internal.hibernate.*;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.OrderedConfiguration;
+import org.apache.tapestry5.ioc.ScopeConstants;
+import org.apache.tapestry5.ioc.ServiceBinder;
+import org.apache.tapestry5.ioc.annotations.Local;
+import org.apache.tapestry5.ioc.annotations.Marker;
+import org.apache.tapestry5.ioc.annotations.Scope;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+import org.apache.tapestry5.ioc.services.PerthreadManager;
+import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
+import org.hibernate.Session;
+
+import java.util.Collection;
+
+/**
+ * Defines core services that support initialization of Hibernate and access 
to the Hibernate {@link
+ * org.hibernate.Session}.
+ */
+@SuppressWarnings({"JavaDoc"})
+@Marker(HibernateCore.class)
+public class HibernateCoreModule
+{
+    public static void bind(ServiceBinder binder)
+    {
+        binder.bind(HibernateTransactionDecorator.class, 
HibernateTransactionDecoratorImpl.class);
+        binder.bind(HibernateTransactionAdvisor.class, 
HibernateTransactionAdvisorImpl.class);
+        binder.bind(HibernateConfigurer.class, 
DefaultHibernateConfigurer.class).withSimpleId();
+        binder.bind(HibernateSessionSource.class, 
HibernateSessionSourceImpl.class);
+    }
+
+
+    public static void contributeFactoryDefaults(MappedConfiguration<String, 
String> configuration)
+    {
+        configuration.add(HibernateSymbols.DEFAULT_CONFIGURATION, "true");
+        configuration.add(HibernateSymbols.EARLY_START_UP, "false");
+    }
+
+    public static void 
contributeRegistryStartup(OrderedConfiguration<Runnable> configuration,
+
+                                                 
@Symbol(HibernateSymbols.EARLY_START_UP)
+                                                 final boolean earlyStartup,
+
+                                                 final HibernateSessionSource 
sessionSource)
+    {
+        configuration.add("HibernateStartup", new Runnable()
+        {
+            public void run()
+            {
+                if (earlyStartup)
+                    sessionSource.getConfiguration();
+            }
+        });
+    }
+
+    public static HibernateEntityPackageManager 
buildHibernateEntityPackageManager(
+            final Collection<String> packageNames)
+    {
+        return new HibernateEntityPackageManager()
+        {
+            public Collection<String> getPackageNames()
+            {
+                return packageNames;
+            }
+        };
+    }
+
+    /**
+     * The session manager manages sessions on a per-thread/per-request basis. 
Any active transaction will be rolled
+     * back at {@linkplain org.apache.tapestry5.ioc.Registry#cleanupThread() 
thread cleanup time}.  The thread is
+     * cleaned up automatically in a Tapestry web application.
+     */
+    @Scope(ScopeConstants.PERTHREAD)
+    public static HibernateSessionManager 
buildHibernateSessionManager(HibernateSessionSource sessionSource,
+                                                                       
PerthreadManager perthreadManager)
+    {
+        HibernateSessionManagerImpl service = new 
HibernateSessionManagerImpl(sessionSource);
+
+        perthreadManager.addThreadCleanupListener(service);
+
+        return service;
+    }
+
+    public static Session buildSession(HibernateSessionManager sessionManager,
+                                       PropertyShadowBuilder 
propertyShadowBuilder)
+    {
+        // Here's the thing: the tapestry.hibernate.Session class doesn't have 
to be per-thread,
+        // since
+        // it will invoke getSession() on the HibernateSessionManager service 
(which is per-thread).
+        // On
+        // first invocation per request,
+        // this forces the HSM into existence (which creates the session and 
begins the
+        // transaction).
+        // Thus we don't actually create
+        // a session until we first try to access it, then the session 
continues to exist for the
+        // rest
+        // of the request.
+
+        return propertyShadowBuilder.build(sessionManager, "session", 
Session.class);
+    }
+
+    /**
+     * Adds the following configurers: <dl> <dt>Default <dd> performs default 
hibernate configuration <dt>PackageName
+     * <dd> loads entities by package name</dl>
+     */
+    public static void 
contributeHibernateSessionSource(OrderedConfiguration<HibernateConfigurer> 
config,
+
+                                                        @Local
+                                                        HibernateConfigurer 
defaultHibernateConfigurer)
+    {
+        config.add("Default", defaultHibernateConfigurer);
+        config.addInstance("PackageName", 
PackageNameHibernateConfigurer.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
 
b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
index 27c3652..5d73516 100644
--- 
a/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
+++ 
b/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
@@ -43,7 +43,7 @@ import org.hibernate.mapping.PersistentClass;
 import java.util.Iterator;
 
 /**
- * Supplements the services defined by {@link 
org.apache.tapestry5.hibernate.HibernateCoreModule} with additional
+ * 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

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2de3d0f7/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 291e241..a2b24a6 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.HibernateCoreModule;
 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.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.ServiceBinder;

Reply via email to