jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1392821 - in /jackrabbit/oak/trunk: oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/ oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/ja...
Date Tue, 02 Oct 2012 10:08:03 GMT
Author: jukka
Date: Tue Oct  2 10:08:02 2012
New Revision: 1392821

URL: http://svn.apache.org/viewvc?rev=1392821&view=rev
Log:
OAK-352: Oak builder for simplified repository construction

Better documentation of the Oak class.
Prepare for making also the authentication bits configurable.

Modified:
    jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
    jackrabbit/oak/trunk/oak-core/pom.xml
    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/security/authentication/LoginContextProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java

Modified: jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
(original)
+++ jackrabbit/oak/trunk/oak-bench/base/src/main/java/org/apache/jackrabbit/oak/performance/AbstractPerformanceTest.java
Tue Oct  2 10:08:02 2012
@@ -33,6 +33,7 @@ import org.apache.jackrabbit.mk.MicroKer
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.mk.index.IndexWrapper;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
@@ -175,9 +176,8 @@ public abstract class AbstractPerformanc
         // return new RepositoryImpl();
 
         mk = new IndexWrapper(mk);
-        ValidatingHook ve =  new ValidatingHook(
-                CompositeValidatorProvider.compose(Collections.<ValidatorProvider>emptyList()));
-        ContentRepository contentRepository = new ContentRepositoryImpl(mk, null, ve);
+        ContentRepository contentRepository =
+                new Oak(mk).createContentRepository();
         return new RepositoryImpl(contentRepository, null);
 
     }

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Tue Oct  2 10:08:02 2012
@@ -39,6 +39,7 @@
         <configuration>
           <instructions>
             <Export-Package>
+              org.apache.jackrabbit.oak,
               org.apache.jackrabbit.oak.api,
               org.apache.jackrabbit.oak.core,
               org.apache.jackrabbit.oak.util,

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=1392821&r1=1392820&r2=1392821&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 Tue Oct
 2 10:08:02 2012
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.oak.core.Co
 import org.apache.jackrabbit.oak.core.RootImpl;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.security.authentication.LoginContextProviderImpl;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
@@ -53,11 +54,13 @@ public class Oak {
 
     private final MicroKernel kernel;
 
-    private final List<QueryIndexProvider> providers = Lists.newArrayList();
+    private final List<QueryIndexProvider> queryIndexProviders =
+            Lists.newArrayList();
 
-    private final List<CommitHook> hooks = Lists.newArrayList();
+    private final List<CommitHook> commitHooks = Lists.newArrayList();
 
-    private final List<ValidatorProvider> validators = Lists.newArrayList();
+    private final List<ValidatorProvider> validatorProviders =
+            Lists.newArrayList();
 
     public Oak(MicroKernel kernel) {
         this.kernel = kernel;
@@ -76,7 +79,7 @@ public class Oak {
      */
     @Nonnull
     public Oak with(@Nonnull QueryIndexProvider provider) {
-        providers.add(provider);
+        queryIndexProviders.add(provider);
         return this;
     }
 
@@ -89,7 +92,7 @@ public class Oak {
     @Nonnull
     public Oak with(@Nonnull CommitHook hook) {
         withValidatorHook();
-        hooks.add(hook);
+        commitHooks.add(hook);
         return this;
     }
 
@@ -102,10 +105,10 @@ public class Oak {
      * multiple validators iterating over the changes simultaneously.
      */
     private void withValidatorHook() {
-        if (!validators.isEmpty()) {
+        if (!validatorProviders.isEmpty()) {
             with(new ValidatingHook(
-                    CompositeValidatorProvider.compose(validators)));
-            validators.clear();
+                    CompositeValidatorProvider.compose(validatorProviders)));
+            validatorProviders.clear();
         }
     }
 
@@ -118,7 +121,7 @@ public class Oak {
      */
     @Nonnull
     public Oak with(@Nonnull ValidatorProvider provider) {
-        validators.add(provider);
+        validatorProviders.add(provider);
         return this;
     }
 
@@ -142,13 +145,14 @@ public class Oak {
     public ContentRepository createContentRepository() {
         return new ContentRepositoryImpl(
                 kernel,
-                CompositeQueryIndexProvider.compose(providers),
+                new LoginContextProviderImpl(),
+                CompositeQueryIndexProvider.compose(queryIndexProviders),
                 createCommitHook());
     }
 
     private CommitHook createCommitHook() {
         withValidatorHook();
-        return CompositeHook.compose(hooks);
+        return CompositeHook.compose(commitHooks);
     }
 
     /**
@@ -179,4 +183,4 @@ public class Oak {
     public Root createRoot() {
         return new RootImpl(createNodeStore(), null);
     }
-}
+}
\ No newline at end of file

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=1392821&r1=1392820&r2=1392821&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
Tue Oct  2 10:08:02 2012
@@ -71,7 +71,8 @@ public class ContentRepositoryImpl imple
     }
 
     public ContentRepositoryImpl(CommitHook hook) {
-        this(new MicroKernelImpl(), new CompositeQueryIndexProvider(), hook);
+        this(new MicroKernelImpl(), new LoginContextProviderImpl(),
+                new CompositeQueryIndexProvider(), hook);
     }
 
     /**
@@ -87,12 +88,12 @@ public class ContentRepositoryImpl imple
      * @param validatorProvider
      *            the validation provider
      */
-    public ContentRepositoryImpl(MicroKernel microKernel,
-            QueryIndexProvider indexProvider,
+    public ContentRepositoryImpl(
+            MicroKernel microKernel, QueryIndexProvider indexProvider,
             ValidatorProvider validatorProvider) {
-        this(microKernel, indexProvider, new ValidatingHook(
-                validatorProvider != null ? validatorProvider
-                        : DefaultValidatorProvider.INSTANCE));
+        this(microKernel, new LoginContextProviderImpl(), indexProvider,
+                new ValidatingHook(validatorProvider != null
+                    ? validatorProvider : DefaultValidatorProvider.INSTANCE));
     }
 
     public ContentRepositoryImpl(
@@ -105,11 +106,13 @@ public class ContentRepositoryImpl imple
      * initialized components.
      *
      * @param microKernel underlying kernel instance
+     * @param loginContextProvider login context provider
      * @param indexProvider index provider
      * @param commitHook the commit hook
      */
-    public ContentRepositoryImpl(MicroKernel microKernel, QueryIndexProvider indexProvider,
-                                 CommitHook commitHook) {
+    public ContentRepositoryImpl(
+            MicroKernel microKernel, LoginContextProvider loginContextProvider,
+            QueryIndexProvider indexProvider, CommitHook commitHook) {
 
         nodeStore = new KernelNodeStore(microKernel);
         nodeStore.setHook(commitHook);
@@ -118,8 +121,7 @@ public class ContentRepositoryImpl imple
                 : new CompositeQueryIndexProvider();
         queryEngine = new QueryEngineImpl(nodeStore, qip);
 
-        // TODO: use configurable context provider
-        loginContextProvider = new LoginContextProviderImpl(this);
+        this.loginContextProvider = loginContextProvider;
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/LoginContextProviderImpl.java
Tue Oct  2 10:08:02 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.security.authentication;
 
-import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.security.principal.TmpPrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
@@ -42,7 +41,7 @@ public class LoginContextProviderImpl im
     private final Configuration authConfig;
     private final PrincipalProvider principalProvider;
 
-    public LoginContextProviderImpl(ContentRepository repository) {
+    public LoginContextProviderImpl() {
         // TODO: use configurable authentication config and principal provider
         authConfig = new ConfigurationImpl();
         principalProvider = new TmpPrincipalProvider();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
Tue Oct  2 10:08:02 2012
@@ -21,6 +21,7 @@ import java.text.ParseException;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.AbstractOakTest;
+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.api.CoreValueFactory;
@@ -29,7 +30,6 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
@@ -70,7 +70,7 @@ public abstract class AbstractLuceneQuer
                 DEFAULT_INDEX_HOME), new LuceneHook(DEFAULT_INDEX_HOME));
         MicroKernel mk = new MicroKernelImpl();
         createDefaultKernelTracker().available(mk);
-        return new ContentRepositoryImpl(mk, qip, ch);
+        return new Oak(mk).with(qip).with(ch).createContentRepository();
     }
 
     protected void createIndexNode() throws Exception {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
Tue Oct  2 10:08:02 2012
@@ -19,12 +19,12 @@ package org.apache.jackrabbit.oak.query;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.mk.index.IndexWrapper;
 import org.apache.jackrabbit.oak.AbstractOakTest;
+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.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.plugins.index.Indexer;
 import org.apache.jackrabbit.oak.plugins.index.PropertyIndexer;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
@@ -56,7 +56,7 @@ public abstract class AbstractQueryTest 
         QueryIndexProvider qip = new CompositeQueryIndexProvider(pi);
         CompositeHook hook = new CompositeHook(pi);
         createDefaultKernelTracker().available(mk);
-        return new ContentRepositoryImpl(mk, qip, hook);
+        return new Oak(mk).with(qip).with(hook).createContentRepository();
     }
 
     @Override

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=1392821&r1=1392820&r2=1392821&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
Tue Oct  2 10:08:02 2012
@@ -29,6 +29,7 @@ import javax.security.auth.login.LoginEx
 import org.apache.jackrabbit.commons.SimpleValueFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+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.core.ContentRepositoryImpl;
@@ -91,8 +92,10 @@ public class RepositoryImpl implements R
 
     public RepositoryImpl(
             MicroKernel kernel, ScheduledExecutorService executor) {
-        this(new ContentRepositoryImpl(setupInitialContent(kernel), null,
-                DEFAULT_COMMIT_HOOK), executor);
+        this(new Oak(setupInitialContent(kernel))
+                .with(DEFAULT_COMMIT_HOOK)
+                .createContentRepository(),
+                executor);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
Tue Oct  2 10:08:02 2012
@@ -22,8 +22,8 @@ import javax.jcr.Credentials;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
 
 /**
@@ -41,11 +41,12 @@ public class OsgiRepository extends Repo
     @Override
     public Session login(Credentials credentials, String workspace)
             throws RepositoryException {
+        // TODO: The context class loader hack below shouldn't be needed
+        // with a properly OSGi-compatible JAAS implementation
         Thread thread = Thread.currentThread();
         ClassLoader loader = thread.getContextClassLoader();
         try {
-            thread.setContextClassLoader(
-                    ContentRepositoryImpl.class.getClassLoader());
+            thread.setContextClassLoader(Oak.class.getClassLoader());
             return super.login(credentials, workspace);
         } finally {
             thread.setContextClassLoader(loader);

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1392821&r1=1392820&r2=1392821&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Tue
Oct  2 10:08:02 2012
@@ -24,6 +24,7 @@ import javax.jcr.Repository;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.http.OakServlet;
@@ -155,8 +156,9 @@ public class Main {
         }
 
         private void addServlets(MicroKernel kernel, String path) {
-            ContentRepository repository =
-                    new ContentRepositoryImpl(kernel, null, buildDefaultCommitHook());
+            ContentRepository repository = new Oak(kernel)
+                .with(buildDefaultCommitHook())
+                .createContentRepository();
 
             ServletHolder oak =
                     new ServletHolder(new OakServlet(repository));



Mime
View raw message