jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r1469700 - /jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
Date Fri, 19 Apr 2013 05:34:50 GMT
Author: ckoell
Date: Fri Apr 19 05:34:50 2013
New Revision: 1469700

URL: http://svn.apache.org/r1469700
Log:
JCR-3570 Make immediately Repository start configureable in JCAManagedConnectionFactory

Modified:
    jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java

Modified: jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?rev=1469700&r1=1469699&r2=1469700&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
Fri Apr 19 05:34:50 2013
@@ -63,6 +63,13 @@ public class JCAManagedConnectionFactory
     private Boolean bindSessionToTransaction = Boolean.TRUE;
 
     /**
+     * Flag indicating whether the Repository should start
+     * immediately or lazy on first access. Per default true so the Repository will
+     * start immediately if this JCAManagedConnectionFactory will be initialized.
+     */
+    private Boolean startRepositoryImmediately = Boolean.TRUE;
+
+    /**
      * Repository.
      */
     private transient Repository repository;
@@ -142,9 +149,9 @@ public class JCAManagedConnectionFactory
      */
     public Object createConnectionFactory(ConnectionManager cm)
             throws ResourceException {
-        // JCR-3491 Start the Repository immediatly in JCA Environment. 
-        // If this Instance is in a Cluster it would not get any changes till someone performs
a first login 
-        createRepository();
+    	if (startRepositoryImmediately) {
+    		createRepository();
+    	}
         JCARepositoryHandle handle = new JCARepositoryHandle(this, cm);
         log("Created repository handle (" + handle + ")");
         return handle;
@@ -221,7 +228,17 @@ public class JCAManagedConnectionFactory
     /**
      * Return the repository, automatically creating it if needed.
      */
-    public Repository getRepository() throws RepositoryException {
+    @SuppressWarnings("deprecation")
+	public Repository getRepository() throws RepositoryException {
+    	if (repository == null) {
+    		synchronized (this) {
+    			try {
+    				createRepository();
+    			} catch (ResourceException e) {
+    				throw (RepositoryException) e.getLinkedException();
+    			}
+			}
+    	}
         return repository;
     }
     
@@ -288,4 +305,12 @@ public class JCAManagedConnectionFactory
         this.bindSessionToTransaction = bindSessionToTransaction;
     }
 
+    public Boolean getStartRepositoryImmediately() {
+        return startRepositoryImmediately;
+    }
+
+    public void setStartRepositoryImmediately(Boolean startRepositoryImmediately) {
+        this.startRepositoryImmediately = startRepositoryImmediately;
+    }
+
 }



Mime
View raw message