Permalink
Browse files

adding KratiStorage.Factory

  • Loading branch information...
1 parent 7666d8f commit b204b682e18d7a8573461a9ee82d2ca8204f7b2f @dbuthay committed Feb 15, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/main/java/com/flaptor/indextank/index/storage/KratiStorage.java
@@ -7,8 +7,10 @@
import com.flaptor.indextank.index.Document;
import com.flaptor.indextank.storage.alternatives.DocumentStorage;
+import com.flaptor.indextank.storage.alternatives.DocumentStorageFactory;
import com.google.common.collect.Maps;
+import com.google.common.base.Preconditions;
import krati.core.StoreConfig;
import krati.core.StoreFactory;
@@ -65,4 +67,24 @@ public void dump() throws IOException {
return Maps.newHashMap();
}
+
+ public class Factory implements DocumentStorageFactory {
+
+ public static final String DIR = "dir";
+
+ @Override
+ public DocumentStorage fromConfiguration(Map<?, ?> config) {
+ Preconditions.checkNotNull(config);
+ Preconditions.checkNotNull(config.get(DIR), "config needs '" + DIR + "' value");
+
+ File backupDir = new File(config.get(DIR).toString());
+
+ try {
+ return new KratiStorage(backupDir);
+ } catch (Exception e) {
+ throw new RuntimeException("while creating a KratiStorage: " + e.getMessage(), e);
+ }
+ }
+ }
+
}

0 comments on commit b204b68

Please sign in to comment.