jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1548500 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: plugins/segment/SegmentNodeStoreService.java spi/state/ProxyNodeStore.java
Date Fri, 06 Dec 2013 12:20:01 GMT
Author: jukka
Date: Fri Dec  6 12:20:00 2013
New Revision: 1548500

URL: http://svn.apache.org/r1548500
Log:
OAK-17: Modularisation and configuration concept

Simplify SegmentNodeStoreService

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1548500&r1=1548499&r2=1548500&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Fri Dec  6 12:20:00 2013
@@ -16,38 +16,31 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment;
 
+import static com.google.common.base.Preconditions.checkState;
+
 import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Dictionary;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.jackrabbit.oak.api.Blob;
-import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.osgi.ObserverTracker;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
-import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.Observable;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
-import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
 import org.osgi.service.component.ComponentContext;
 
 @Component(policy = ConfigurationPolicy.REQUIRE)
 @Service(NodeStore.class)
-public class SegmentNodeStoreService implements NodeStore, Observable {
+public class SegmentNodeStoreService extends ProxyNodeStore
+        implements Observable {
 
     @Property(description="The unique name of this instance")
     public static final String NAME = "name";
@@ -72,8 +65,9 @@ public class SegmentNodeStoreService imp
 
     private ObserverTracker observerTracker;
 
-    private synchronized NodeStore getDelegate() {
-        assert delegate != null : "service must be activated when used";
+    @Override
+    protected synchronized SegmentNodeStore getNodeStore() {
+        checkState(delegate != null, "service must be activated when used");
         return delegate;
     }
 
@@ -131,55 +125,14 @@ public class SegmentNodeStoreService imp
 
     @Override
     public Closeable addObserver(Observer observer) {
-        return ((Observable) getDelegate()).addObserver(observer);
-    }
-
-
-    //---------------------------------------------------------< NodeStore >--
-
-    @Override @Nonnull
-    public NodeState getRoot() {
-        return getDelegate().getRoot();
-    }
-
-    @Nonnull
-    @Override
-    public NodeState merge(
-            @Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook,
-            @Nullable CommitInfo info) throws CommitFailedException {
-        return getDelegate().merge(builder, commitHook, info);
-    }
-
-    @Override
-    public NodeState rebase(@Nonnull NodeBuilder builder) {
-        return getDelegate().rebase(builder);
-    }
-
-    @Override
-    public NodeState reset(@Nonnull NodeBuilder builder) {
-        return getDelegate().reset(builder);
-    }
-
-    @Override
-    public Blob createBlob(InputStream stream) throws IOException {
-        return getDelegate().createBlob(stream);
-    }
-
-    @Override @Nonnull
-    public String checkpoint(long lifetime) {
-        return getDelegate().checkpoint(lifetime);
-    }
-
-    @Override @CheckForNull
-    public NodeState retrieve(@Nonnull String checkpoint) {
-        return getDelegate().retrieve(checkpoint);
+        return getNodeStore().addObserver(observer);
     }
 
     //------------------------------------------------------------< Object >--
 
     @Override
-    public synchronized String toString() {
-        return name + ": " + super.toString();
+    public String toString() {
+        return name + ": " + delegate;
     }
 
 }

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java?rev=1548500&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ProxyNodeStore.java
Fri Dec  6 12:20:00 2013
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.state;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+
+public abstract class ProxyNodeStore implements NodeStore {
+
+    protected abstract NodeStore getNodeStore();
+
+    @Override
+    public NodeState getRoot() {
+        return getNodeStore().getRoot();
+    }
+
+    @Override
+    public NodeState merge(
+            NodeBuilder builder, CommitHook commitHook, CommitInfo info)
+            throws CommitFailedException {
+        return getNodeStore().merge(builder, commitHook, info);
+    }
+
+    @Override
+    public NodeState rebase(NodeBuilder builder) {
+        return getNodeStore().rebase(builder);
+    }
+
+    @Override
+    public NodeState reset(NodeBuilder builder) {
+        return getNodeStore().reset(builder);
+    }
+
+    @Override
+    public Blob createBlob(InputStream inputStream) throws IOException {
+        return getNodeStore().createBlob(inputStream);
+    }
+
+    @Override
+    public String checkpoint(long lifetime) {
+        return getNodeStore().checkpoint(lifetime);
+    }
+
+    @Override
+    public NodeState retrieve(String checkpoint) {
+        return getNodeStore().retrieve(checkpoint);
+    }
+
+}



Mime
View raw message