Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CacheLocalTransform into a class, testing
- Loading branch information
Showing
5 changed files
with
169 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
fcrepo-kernel/src/main/java/org/fcrepo/services/functions/CacheLocalTransform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.fcrepo.services.functions; | ||
|
||
import java.util.Set; | ||
|
||
import org.fcrepo.utils.LowLevelCacheEntry; | ||
import org.infinispan.Cache; | ||
import org.infinispan.distexec.DistributedCallable; | ||
import org.infinispan.loaders.CacheStore; | ||
import org.modeshape.jcr.value.BinaryKey; | ||
import org.modeshape.jcr.value.binary.BinaryStore; | ||
|
||
import com.google.common.base.Function; | ||
|
||
|
||
public class CacheLocalTransform<K, V, T> | ||
implements DistributedCallable<K, V, T> { | ||
|
||
private static GetCacheStore TRANSFORM = new GetCacheStore(); | ||
|
||
private BinaryStore binStore; | ||
private BinaryKey key; | ||
private Function<LowLevelCacheEntry, T> entryTransform; | ||
private CacheStore store; | ||
|
||
public CacheLocalTransform(final BinaryStore store, | ||
final BinaryKey key, final Function<LowLevelCacheEntry, T> entryTransform) { | ||
this.key = key; | ||
this.entryTransform = entryTransform; | ||
this.binStore = store; | ||
} | ||
|
||
@Override | ||
public T call() throws Exception { | ||
LowLevelCacheEntry entry = new LowLevelCacheEntry(binStore, store, key); | ||
return this.entryTransform.apply(entry); | ||
} | ||
|
||
@Override | ||
public void setEnvironment(Cache<K, V> cache, Set<K> keys) { | ||
this.store = TRANSFORM.apply(cache); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.