jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1399316 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/ oak-core/sr...
Date Wed, 17 Oct 2012 15:57:31 GMT
Author: mduerig
Date: Wed Oct 17 15:57:30 2012
New Revision: 1399316

URL: http://svn.apache.org/viewvc?rev=1399316&view=rev
Log:
OAK-363: Make conflict handler configurable through Oak builder

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/RepositoryCallback.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/RootTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/TreeTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java Wed Oct
17 15:57:30 2012
@@ -29,6 +29,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
@@ -62,6 +63,8 @@ public class Oak {
 
     private SecurityProvider securityProvider;
 
+    private ConflictHandler conflictHandler;
+
     public Oak(MicroKernel kernel) {
         this.kernel = kernel;
     }
@@ -156,11 +159,24 @@ public class Oak {
         return this;
     }
 
+    /**
+     * Associates the given conflict handler with the repository to be created.
+     *
+     * @param conflictHandler conflict handler
+     * @return this builder
+     */
+    @Nonnull
+    public Oak with(@Nonnull ConflictHandler conflictHandler) {
+        this.conflictHandler = conflictHandler;
+        return this;
+    }
+
     public ContentRepository createContentRepository() {
         return new ContentRepositoryImpl(
                 kernel,
                 CompositeQueryIndexProvider.compose(queryIndexProviders),
                 createCommitHook(),
+                conflictHandler,
                 securityProvider);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Wed Oct 17 15:57:30 2012
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
-import org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
@@ -51,11 +50,10 @@ public class ContentRepositoryImpl imple
     // TODO: retrieve default wsp-name from configuration
     private static final String DEFAULT_WORKSPACE_NAME = "default";
 
-    private static final ConflictHandler DEFAULT_CONFLICT = new AnnotatingConflictHandler();
-
     private final SecurityProvider securityProvider;
     private final QueryIndexProvider indexProvider;
     private final NodeStore nodeStore;
+    private final ConflictHandler conflictHandler;
 
     /**
      * Creates an content repository instance based on the given, already
@@ -70,8 +68,9 @@ public class ContentRepositoryImpl imple
     public ContentRepositoryImpl(MicroKernel microKernel,
                                  QueryIndexProvider indexProvider,
                                  CommitHook commitHook,
+                                 ConflictHandler conflictHandler,
                                  SecurityProvider securityProvider) {
-        this(createNodeStore(microKernel, commitHook), indexProvider, securityProvider);
+        this(createNodeStore(microKernel, commitHook), conflictHandler, indexProvider, securityProvider);
     }
 
     /**
@@ -84,9 +83,11 @@ public class ContentRepositoryImpl imple
      * default implementations should be used.
      */
     public ContentRepositoryImpl(NodeStore nodeStore,
+                                 ConflictHandler conflictHandler,
                                  QueryIndexProvider indexProvider,
                                  SecurityProvider securityProvider) {
         this.nodeStore = nodeStore;
+        this.conflictHandler = conflictHandler;
         this.indexProvider = indexProvider != null ? indexProvider : new CompositeQueryIndexProvider();
         this.securityProvider = securityProvider;
     }
@@ -110,7 +111,7 @@ public class ContentRepositoryImpl imple
 
         AccessControlProvider acProvider = securityProvider.getAccessControlProvider();
         return new ContentSessionImpl(loginContext, acProvider, workspaceName,
-                nodeStore, DEFAULT_CONFLICT, indexProvider);
+                nodeStore, conflictHandler, indexProvider);
     }
 
     //--------------------------------------------------------------------------

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/RepositoryCallback.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/RepositoryCallback.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/RepositoryCallback.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/callback/RepositoryCallback.java
Wed Oct 17 15:57:30 2012
@@ -57,7 +57,7 @@ public class RepositoryCallback implemen
             try {
                 // FIXME: need a direct and fast way to create Root from the node store without
having to call login
                 SecurityProvider sp = new OpenSecurityProvider();
-                return new ContentRepositoryImpl(nodeStore, null, sp).login(null, workspaceName).getLatestRoot();
+                return new ContentRepositoryImpl(nodeStore, null, null, sp).login(null, workspaceName).getLatestRoot();
             } catch (LoginException e) {
                 log.warn("Internal error ", e.getMessage());
             } catch (NoSuchWorkspaceException e) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/RootTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/RootTest.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/RootTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/RootTest.java Wed
Oct 17 15:57:30 2012
@@ -22,6 +22,7 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler;
 import org.apache.jackrabbit.oak.plugins.commit.ConflictValidator;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.junit.Ignore;
@@ -34,8 +35,11 @@ public class RootTest extends AbstractOa
 
     @Override
     protected ContentRepository createRepository() {
-        return new Oak().with(new OpenSecurityProvider()).with(
-                new ConflictValidator()).createContentRepository();
+        return new Oak()
+                .with(new OpenSecurityProvider())
+                .with(new ConflictValidator())
+                .with(new AnnotatingConflictHandler())
+                .createContentRepository();
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/TreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/TreeTest.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/TreeTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/TreeTest.java Wed
Oct 17 15:57:30 2012
@@ -20,17 +20,17 @@ package org.apache.jackrabbit.oak;
 
 import java.util.Set;
 
+import com.google.common.collect.Sets;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler;
 import org.apache.jackrabbit.oak.plugins.commit.ConflictValidator;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
 import org.junit.Test;
 
-import com.google.common.collect.Sets;
-
 import static org.junit.Assert.assertEquals;
 
 /**
@@ -40,8 +40,11 @@ public class TreeTest extends AbstractOa
 
     @Override
     protected ContentRepository createRepository() {
-        return new Oak().with(new OpenSecurityProvider()).with(
-                new ConflictValidator()).createContentRepository();
+        return new Oak()
+                .with(new OpenSecurityProvider())
+                .with(new ConflictValidator())
+                .with(new AnnotatingConflictHandler())
+                .createContentRepository();
     }
     @Test
     public void orderBefore() throws Exception {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1399316&r1=1399315&r2=1399316&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Wed Oct 17 15:57:30 2012
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.jcr;
 
 import java.util.concurrent.ScheduledExecutorService;
+
 import javax.jcr.Credentials;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
@@ -29,6 +30,7 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.plugins.commit.AnnotatingConflictHandler;
 import org.apache.jackrabbit.oak.plugins.commit.ConflictValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHook;
 import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
@@ -37,6 +39,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.nodetype.TypeValidatorProvider;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
@@ -65,6 +68,8 @@ public class RepositoryImpl implements R
                     new ValidatingHook(DEFAULT_VALIDATOR),
                     new PropertyIndexHook());
 
+    private static final ConflictHandler DEFAULT_CONFLICT_HANDLER = new AnnotatingConflictHandler();
+
     private final Descriptors descriptors = new Descriptors(new SimpleValueFactory());
     private final ContentRepository contentRepository;
 
@@ -75,7 +80,9 @@ public class RepositoryImpl implements R
     public RepositoryImpl(MicroKernel kernel, ScheduledExecutorService executor,
                           SecurityProvider securityProvider) {
         this(new Oak(setupInitialContent(kernel))
-                .with(DEFAULT_COMMIT_HOOK).with(securityProvider)
+                .with(DEFAULT_COMMIT_HOOK)
+                .with(DEFAULT_CONFLICT_HANDLER)
+                .with(securityProvider)
                 .createContentRepository(),
                 executor, securityProvider);
     }



Mime
View raw message