Added null file cache

This commit is contained in:
nsingh
2018-02-01 16:30:52 -08:00
parent b76e3b8e1e
commit 247623edc9
2 changed files with 8 additions and 2 deletions

View File

@@ -24,6 +24,9 @@ import org.json.JSONTokener;
import org.springframework.ide.vscode.commons.util.Log;
public class ClasspathFileBasedCache {
public static final ClasspathFileBasedCache NULL = new ClasspathFileBasedCache(null);
public static final String CLASSPATH_DATA_CACHE_FILE = "classpath-data.json";
private static final String OUTPUT_FOLDER_PROPERTY = "outputFolder";

View File

@@ -18,6 +18,8 @@ import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import org.springframework.ide.vscode.commons.util.Assert;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
@@ -46,12 +48,13 @@ public class DelegatingCachedClasspath<T extends IClasspath> implements IClasspa
private Callable<T> delegateCreator;
private AtomicReference<T> cachedDelegate;
private ClasspathFileBasedCache fileCache;
private final ClasspathFileBasedCache fileCache;
public DelegatingCachedClasspath(Callable<T> delegateCreator, ClasspathFileBasedCache fileCache) {
super();
this.fileCache = fileCache;
Assert.isLegal(delegateCreator != null);
this.fileCache = fileCache != null ? fileCache : ClasspathFileBasedCache.NULL;
this.cachedDelegate = new AtomicReference<>(null);
this.cachedData = new AtomicReference<>(loadFileBasedCache(fileCache));
this.delegateCreator = delegateCreator;