jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1484698 - in /jackrabbit/branches/2.6: ./ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/
Date Tue, 21 May 2013 08:40:11 GMT
Author: jukka
Date: Tue May 21 08:40:11 2013
New Revision: 1484698

URL: http://svn.apache.org/r1484698
Log:
2.6: Merged revision 1453907 (JCR-3531)

Modified:
    jackrabbit/branches/2.6/   (props changed)
    jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPool.java
    jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPoolImpl.java

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1453907

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=1484698&r1=1484697&r2=1484698&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
Tue May 21 08:40:11 2013
@@ -51,7 +51,7 @@ public abstract class AbstractJCRTest ex
     /**
      * Pool of helper objects to access repository transparently
      */
-    private static final RepositoryHelperPool HELPER_POOL = new RepositoryHelperPoolImpl();
+    private static final RepositoryHelperPool HELPER_POOL = RepositoryHelperPoolImpl.getInstance();
 
     /**
      * Namespace URI for jcr prefix.

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPool.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPool.java?rev=1484698&r1=1484697&r2=1484698&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPool.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPool.java
Tue May 21 08:40:11 2013
@@ -31,6 +31,16 @@ public interface RepositoryHelperPool {
     public RepositoryHelper borrowHelper() throws InterruptedException;
 
     /**
+     * Borrows all available repository helper instances. Waits until one
+     * becomes available.
+     *
+     * @return a repository helper.
+     * @throws InterruptedException if this thread is interrupted while waiting
+     *                              for a repository helper.
+     */
+    public RepositoryHelper[] borrowHelpers() throws InterruptedException;
+
+    /**
      * Returns the given repository helper to the pool.
      *
      * @param helper the repository helper to return.

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPoolImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPoolImpl.java?rev=1484698&r1=1484697&r2=1484698&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPoolImpl.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelperPoolImpl.java
Tue May 21 08:40:11 2013
@@ -21,7 +21,6 @@ import java.util.LinkedList;
 import java.util.Properties;
 import java.util.Map;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.io.InputStream;
 import java.io.IOException;
 
@@ -33,9 +32,18 @@ public class RepositoryHelperPoolImpl im
 
     private static final String PROP_FILE = "repositoryHelperPool.properties";
 
-    private List helpers = new LinkedList();
+    private List<RepositoryHelper> helpers = new LinkedList<RepositoryHelper>();
 
-    public RepositoryHelperPoolImpl() {
+    private static RepositoryHelperPool POOL = null;
+
+    public synchronized static RepositoryHelperPool getInstance() {
+        if (POOL == null) {
+            POOL = new RepositoryHelperPoolImpl();
+        }
+        return POOL;
+    }
+
+    private RepositoryHelperPoolImpl() {
         InputStream in = RepositoryHelperPoolImpl.class.getClassLoader().getResourceAsStream(PROP_FILE);
         if (in != null) {
             try {
@@ -43,9 +51,8 @@ public class RepositoryHelperPoolImpl im
                 props.load(in);
                 for (int i = 0;; i++) {
                     String prefix = "helper." + i + ".";
-                    Map helperProp = new HashMap();
-                    for (Iterator it = props.entrySet().iterator(); it.hasNext(); ) {
-                        Map.Entry entry = (Map.Entry) it.next();
+                    Map<String, Object> helperProp = new HashMap<String, Object>();
+                    for (Map.Entry<Object, Object> entry : props.entrySet()) {
                         String key = (String) entry.getKey();
                         if (key.startsWith(prefix)) {
                             helperProp.put(key.substring(prefix.length()), entry.getValue());
@@ -81,7 +88,18 @@ public class RepositoryHelperPoolImpl im
         while (helpers.isEmpty()) {
             wait();
         }
-        return (RepositoryHelper) helpers.remove(0);
+        return helpers.remove(0);
+    }
+
+    public synchronized RepositoryHelper[] borrowHelpers() throws InterruptedException {
+        while (helpers.isEmpty()) {
+            wait();
+        }
+        try {
+            return helpers.toArray(new RepositoryHelper[helpers.size()]);
+        } finally {
+            helpers.clear();
+        }
     }
 
     public synchronized void returnHelper(RepositoryHelper helper) {



Mime
View raw message