All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.jackrabbit.oak.plugins.document.util.SynchronizingDocumentStoreWrapper Maven / Gradle / Ivy

There is a newer version: 1.62.0
Show newest version
/*
 * 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.plugins.document.util;

import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

import org.apache.jackrabbit.oak.cache.CacheStats;
import org.apache.jackrabbit.oak.plugins.document.Collection;
import org.apache.jackrabbit.oak.plugins.document.Document;
import org.apache.jackrabbit.oak.plugins.document.DocumentStore;
import org.apache.jackrabbit.oak.plugins.document.DocumentStoreException;
import org.apache.jackrabbit.oak.plugins.document.RevisionListener;
import org.apache.jackrabbit.oak.plugins.document.RevisionVector;
import org.apache.jackrabbit.oak.plugins.document.UpdateOp;
import org.apache.jackrabbit.oak.plugins.document.cache.CacheInvalidationStats;

/**
 * Implements a DocumentStore wrapper which synchronizes on all
 * methods.
 */
public class SynchronizingDocumentStoreWrapper implements DocumentStore, RevisionListener {

    final DocumentStore store;

    public SynchronizingDocumentStoreWrapper(DocumentStore store) {
        this.store = store;
    }

    @Override
    public synchronized  T find(final Collection collection, final String key) {
        return store.find(collection, key);
    }

    @Override
    public synchronized  T find(final Collection collection, final String key, final int maxCacheAge) {
        return store.find(collection, key, maxCacheAge);
    }

    @Override
    @Nonnull
    public synchronized  List query(final Collection collection, final String fromKey,
            final String toKey, final int limit) {
        return store.query(collection, fromKey, toKey, limit);
    }

    @Override
    @Nonnull
    public synchronized  List query(final Collection collection, final String fromKey,
            final String toKey, final String indexedProperty, final long startValue, final int limit) {
        return store.query(collection, fromKey, toKey, indexedProperty, startValue, limit);
    }

    @Override
    public synchronized  void remove(Collection collection, String key) {
        store.remove(collection, key);
    }

    @Override
    public synchronized  void remove(Collection collection, List keys) {
        store.remove(collection, keys);
    }

    @Override
    public synchronized  int remove(Collection collection,
                                                        Map> toRemove) {
        return store.remove(collection, toRemove);
    }

    @Override
    public  int remove(Collection collection,
                                           String indexedProperty, long startValue, long endValue)
            throws DocumentStoreException {
        return store.remove(collection, indexedProperty, startValue, endValue);
    }

    @Override
    public synchronized  boolean create(final Collection collection, final List updateOps) {
        return store.create(collection, updateOps);
    }

    @Override
    public synchronized  void update(final Collection collection, final List keys,
            final UpdateOp updateOp) {
        store.update(collection, keys, updateOp);
    }

    @Override
    public synchronized  T createOrUpdate(final Collection collection, final UpdateOp update) {
        return store.createOrUpdate(collection, update);
    }

    @Override
    public synchronized  List createOrUpdate(Collection collection, List updateOps) {
        return store.createOrUpdate(collection, updateOps);
    }

    @Override
    public synchronized  T findAndUpdate(final Collection collection, final UpdateOp update) {
        return store.findAndUpdate(collection, update);
    }

    @Override
    public synchronized CacheInvalidationStats invalidateCache() {
        return store.invalidateCache();
    }

    @Override
    public synchronized CacheInvalidationStats invalidateCache(Iterable keys) {
        return store.invalidateCache(keys);
    }
    
    @Override
    public synchronized  void invalidateCache(Collection collection, String key) {
        store.invalidateCache(collection, key);
    }

    @Override
    public synchronized void dispose() {
        store.dispose();
    }

    @Override
    public synchronized  T getIfCached(final Collection collection, final String key) {
        return store.getIfCached(collection, key);
    }

    @Override
    public synchronized void setReadWriteMode(String readWriteMode) {
        store.setReadWriteMode(readWriteMode);
    }

    @Override
    public synchronized Iterable getCacheStats() {
        return store.getCacheStats();
    }

    @Override
    public synchronized long determineServerTimeDifferenceMillis() {
        return store.determineServerTimeDifferenceMillis();
    }

    @Override
    public synchronized Map getMetadata() {
        return store.getMetadata();
    }

    @Override
    public synchronized void updateAccessedRevision(RevisionVector revision, int currentClusterId) {
        if (store instanceof RevisionListener) {
            ((RevisionListener) store).updateAccessedRevision(revision, currentClusterId);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy