jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r395305 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
Date Wed, 19 Apr 2006 16:33:01 GMT
Author: jukka
Date: Wed Apr 19 09:32:55 2006
New Revision: 395305

URL: http://svn.apache.org/viewcvs?rev=395305&view=rev
Log:
JCR-403: Added a shutdown() method to TransientRepository.

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java?rev=395305&r1=395304&r2=395305&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/TransientRepository.java
Wed Apr 19 09:32:55 2006
@@ -22,6 +22,7 @@
 import java.io.OutputStream;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
@@ -31,6 +32,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.core.config.ConfigurationException;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.slf4j.Logger;
@@ -43,7 +45,8 @@
  * when no longer used, this class can be used to avoid having to explicitly
  * shut down the repository.
  */
-public class TransientRepository implements Repository, SessionListener {
+public class TransientRepository
+        implements JackrabbitRepository, SessionListener {
 
     /**
      * The logger instance used to log the repository and session lifecycles.
@@ -382,6 +385,22 @@
      */
     public Session login() throws RepositoryException {
         return login(null, null);
+    }
+
+    //--------------------------------------------------<JackrabbitRepository>
+
+    /**
+     * Forces all active sessions to logout. Once the last session has logged
+     * out, the underlying repository instance will automatically be shut down.
+     *
+     * @see Session#logout()
+     */
+    public synchronized void shutdown() {
+        Iterator iterator = new HashSet(sessions).iterator();
+        while (iterator.hasNext()) {
+            Session session = (Session) iterator.next();
+            session.logout();
+        }
     }
 
     //-------------------------------------------------------<SessionListener>



Mime
View raw message