jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r307128 - in /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: RepositoryImpl.java jndi/BindableRepository.java
Date Fri, 07 Oct 2005 14:03:14 GMT
Author: jukka
Date: Fri Oct  7 07:03:09 2005
New Revision: 307128

URL: http://svn.apache.org/viewcvs?rev=307128&view=rev
Log:
JCR-120: Moved the shutdown hook from RepositoryImpl to BindableRepository.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/BindableRepository.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=307128&r1=307127&r2=307128&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java Fri
Oct  7 07:03:09 2005
@@ -221,13 +221,6 @@
         // after the workspaces are initialized, we setup a system session for
         // the virtual nodetype manager
         virtNTMgr.setSession(getSystemSession(repConfig.getDefaultWorkspaceName()));
-
-        // finally register shutdown hook
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            public void run() {
-                shutdown();
-            }
-        });
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=307128&r1=307127&r2=307128&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
Fri Oct  7 07:03:09 2005
@@ -52,6 +52,12 @@
  * The uninitialized state is only used briefly during the static
  * {@link #create(String, String) create} method and during
  * serialization and JNDI "referenciation".
+ * <p>
+ * A JVM shutdown hook is used to make sure that the initialized
+ * repository is properly closed when the JVM shuts down. The
+ * {@link RegistryHelper#unregisterRepository(Context, String)}
+ * method should be used to explicitly close the repository if
+ * needed. 
  */
 class BindableRepository implements Repository, Referenceable, Serializable {
 
@@ -106,7 +112,9 @@
     }
 
     /**
-     * Creates the underlying repository instance.
+     * Creates the underlying repository instance. A shutdown hook is
+     * registered to make sure that the initialized repository gets closed
+     * when the JVM shuts down. 
      *
      * @throws RepositoryException if the repository cannot be created
      */
@@ -114,6 +122,11 @@
         RepositoryConfig config =
             RepositoryConfig.create(configFilePath, repHomeDir);
         delegatee = RepositoryImpl.create(config);
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                shutdown();
+            }
+        });
     }
 
     //-----------------------------------------------------------< Repository >



Mime
View raw message