jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1400168 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/ oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/ oak-core/src/main/java/org/apac...
Date Fri, 19 Oct 2012 16:59:04 GMT
Author: jukka
Date: Fri Oct 19 16:59:03 2012
New Revision: 1400168

URL: http://svn.apache.org/viewvc?rev=1400168&view=rev
Log:
OAK-41: Initial repository setup

Rename MicroKernelTracker to RepositoryInitializer since it's now based on NodeState and in
any case only does initialization

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
  (contents, props changed)
      - copied, changed from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiMicroKernelTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
  (contents, props changed)
      - copied, changed from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeMicroKernelTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
  (contents, props changed)
      - copied, changed from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/MicroKernelTracker.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiMicroKernelTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeMicroKernelTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/DefaultMicroKernelTracker.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/MicroKernelTracker.java
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/osgi/Activator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.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=1400168&r1=1400167&r2=1400168&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 Fri Oct
19 16:59:03 2012
@@ -38,7 +38,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-import org.apache.jackrabbit.oak.spi.lifecycle.MicroKernelTracker;
+import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
@@ -61,7 +61,7 @@ public class Oak {
 
     private final MicroKernel kernel;
 
-    private final List<MicroKernelTracker> initializers = Lists.newArrayList();
+    private final List<RepositoryInitializer> initializers = Lists.newArrayList();
 
     private final List<QueryIndexProvider> queryIndexProviders = Lists.newArrayList();
 
@@ -82,7 +82,7 @@ public class Oak {
     }
 
     @Nonnull
-    public Oak with(@Nonnull MicroKernelTracker initializer) {
+    public Oak with(@Nonnull RepositoryInitializer initializer) {
        initializers.add(checkNotNull(initializer));
        return this;
     }
@@ -186,8 +186,8 @@ public class Oak {
 
     public ContentRepository createContentRepository() {
         KernelNodeStore store = new KernelNodeStore(kernel);
-        for (MicroKernelTracker initializer : initializers) {
-            initializer.available(store);
+        for (RepositoryInitializer initializer : initializers) {
+            initializer.initialize(store);
         }
 
         withValidatorHook();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java?rev=1400168&r1=1400167&r2=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
Fri Oct 19 16:59:03 2012
@@ -44,7 +44,7 @@ public class Activator implements Bundle
 
     private final OsgiValidatorProvider validatorProvider = new OsgiValidatorProvider();
 
-    private final OsgiMicroKernelTracker kernelTracker = new OsgiMicroKernelTracker();
+    private final OsgiRepositoryInitializer kernelTracker = new OsgiRepositoryInitializer();
 
     private final Map<ServiceReference, ServiceRegistration> services =
             new HashMap<ServiceReference, ServiceRegistration>();
@@ -80,7 +80,7 @@ public class Activator implements Bundle
         Object service = context.getService(reference);
         if (service instanceof MicroKernel) {
             MicroKernel kernel = (MicroKernel) service;
-            kernelTracker.available(new KernelNodeStore(kernel));
+            kernelTracker.initialize(new KernelNodeStore(kernel));
             Oak oak = new Oak(kernel)
                     .with(new CompositeHook(
                         // TODO: DefaultTypeEditor is JCR specific and does not belong here

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
(from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiMicroKernelTracker.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiMicroKernelTracker.java&r1=1400143&r2=1400168&rev=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiMicroKernelTracker.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
Fri Oct 19 16:59:03 2012
@@ -18,45 +18,45 @@
  */
 package org.apache.jackrabbit.oak.osgi;
 
-import org.apache.jackrabbit.oak.spi.lifecycle.MicroKernelTracker;
+import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.osgi.framework.ServiceReference;
 
 /**
  * Implements a service tracker that keeps track of all
- * {@link MicroKernelTracker}s in the system and calls the available
+ * {@link RepositoryInitializer}s in the system and calls the available
  * method once the micro kernel is available.
  */
-public class OsgiMicroKernelTracker
-        extends AbstractServiceTracker<MicroKernelTracker>
-        implements MicroKernelTracker {
+public class OsgiRepositoryInitializer
+        extends AbstractServiceTracker<RepositoryInitializer>
+        implements RepositoryInitializer {
 
     /**
      * The reference to the micro kernel once available.
      */
     private volatile NodeStore store;
 
-    public OsgiMicroKernelTracker() {
-        super(MicroKernelTracker.class);
+    public OsgiRepositoryInitializer() {
+        super(RepositoryInitializer.class);
     }
 
     @Override
-    public void available(NodeStore store) {
+    public void initialize(NodeStore store) {
         this.store = store;
         if (store != null) {
-            for (MicroKernelTracker mki : getServices()) {
-                mki.available(store);
+            for (RepositoryInitializer mki : getServices()) {
+                mki.initialize(store);
             }
         }
     }
 
     @Override
     public Object addingService(ServiceReference reference) {
-        MicroKernelTracker mki =
-                (MicroKernelTracker) super.addingService(reference);
+        RepositoryInitializer mki =
+                (RepositoryInitializer) super.addingService(reference);
         NodeStore store = this.store;
         if (store != null) {
-            mki.available(store);
+            mki.initialize(store);
         }
         return mki;
     }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiRepositoryInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java?rev=1400168&r1=1400167&r2=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/InitialContent.java
Fri Oct 19 16:59:03 2012
@@ -21,22 +21,21 @@ import org.apache.felix.scr.annotations.
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.RootImpl;
-import org.apache.jackrabbit.oak.spi.lifecycle.DefaultMicroKernelTracker;
-import org.apache.jackrabbit.oak.spi.lifecycle.MicroKernelTracker;
+import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
 /**
- * {@code InitialContent} implements a {@link MicroKernelTracker} and
+ * {@code InitialContent} implements a {@link RepositoryInitializer} and
  * registers built-in node types when the micro kernel becomes available.
  */
 @Component
-@Service(MicroKernelTracker.class)
-public class InitialContent extends DefaultMicroKernelTracker {
+@Service(RepositoryInitializer.class)
+public class InitialContent implements RepositoryInitializer {
 
     @Override
-    public void available(NodeStore store) {
+    public void initialize(NodeStore store) {
         NodeStoreBranch branch = store.branch();
 
         NodeBuilder root = branch.getRoot().builder();

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
(from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeMicroKernelTracker.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeMicroKernelTracker.java&r1=1400143&r2=1400168&rev=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeMicroKernelTracker.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
Fri Oct 19 16:59:03 2012
@@ -18,34 +18,32 @@
  */
 package org.apache.jackrabbit.oak.spi.lifecycle;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.List;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
 /**
- * <code>CompositeMicroKernelTracker</code> consists of multiple micro kernel
- * trackers and calls them all on {@link #available(MicroKernel)}.
+ * Composite repository initializer that delegates the
+ * {@link #initialize(NodeStore)} call in sequence to all the
+ * component initializers.
  */
-public class CompositeMicroKernelTracker implements MicroKernelTracker {
+public class CompositeInitializer implements RepositoryInitializer {
 
-    private final List<MicroKernelTracker> trackers = new ArrayList<MicroKernelTracker>();
+    private final Collection<RepositoryInitializer> initializers;
 
-    public CompositeMicroKernelTracker(Collection<MicroKernelTracker> trackers) {
-        this.trackers.addAll(trackers);
+    public CompositeInitializer(Collection<RepositoryInitializer> trackers) {
+        this.initializers = trackers;
     }
 
-    public CompositeMicroKernelTracker(MicroKernelTracker... trackers) {
-        this.trackers.addAll(Arrays.asList(trackers));
+    public CompositeInitializer(RepositoryInitializer... initializers) {
+        this.initializers = Arrays.asList(initializers);
     }
 
     @Override
-    public void available(NodeStore store) {
-        for (MicroKernelTracker tracker : trackers) {
-            tracker.available(store);
+    public void initialize(NodeStore store) {
+        for (RepositoryInitializer tracker : initializers) {
+            tracker.initialize(store);
         }
     }
 }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/CompositeInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
(from r1400143, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/MicroKernelTracker.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/MicroKernelTracker.java&r1=1400143&r2=1400168&rev=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/MicroKernelTracker.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
Fri Oct 19 16:59:03 2012
@@ -18,21 +18,24 @@
  */
 package org.apache.jackrabbit.oak.spi.lifecycle;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 
 /**
- * This interface is mainly used in an OSGi environment where various components
- * of Oak are started by container and one would like to plug in some code that
- * is executed when the micro kernel becomes available in the system.
+ * Initializer of repository content. A component that needs to add specific
+ * content to a new repository can implement this interface. Then when a
+ * repository becomes available, all the configured initializers are invoked
+ * in sequence.
  */
-public interface MicroKernelTracker {
+public interface RepositoryInitializer {
 
     /**
-     * This method is called when both the {@link MicroKernel} service and this
-     * tracker become available in the system.
-     * @param mk the {@link MicroKernel} instance.
+     * Initializes repository content. This method is called as soon as a
+     * repository becomes available. Note that the repository may already
+     * have been initialized, so the implementation of this method should
+     * check for that before blindly adding new content.
+     *
+     * @param store node store of the repository
      */
-    public void available(NodeStore store);
+    public void initialize(NodeStore store);
 
 }

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/RepositoryInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java?rev=1400168&r1=1400167&r2=1400168&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/Jcr.java Fri
Oct 19 16:59:03 2012
@@ -45,7 +45,7 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-import org.apache.jackrabbit.oak.spi.lifecycle.MicroKernelTracker;
+import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 
@@ -91,7 +91,7 @@ public class Jcr {
     }
 
     @Nonnull
-    public Jcr with(@Nonnull MicroKernelTracker initializer) {
+    public Jcr with(@Nonnull RepositoryInitializer initializer) {
        oak.with(checkNotNull(initializer));
        return this;
     }



Mime
View raw message