Skip to content

Commit

Permalink
adding KratiStorage.Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuthay committed Feb 15, 2012
1 parent 7666d8f commit b204b68
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -65,4 +67,24 @@ public Map<String, String> getStats() {
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.