protected void populateHabitat(final Habitat habitat, InhabitantsParser ip) {
final ClassPath classpath = ClassPath.create(habitat, true);
Callable<InhabitantsParsingContextGenerator> populator = new Callable<InhabitantsParsingContextGenerator>() {
@Override
public InhabitantsParsingContextGenerator call() throws Exception {
InhabitantsParsingContextGenerator ipcgen = InhabitantsParsingContextGenerator.create(habitat);
Set<String> cpSet = classpath.getEntries();
for (String fileName : cpSet) {
File f = new File(fileName);
if (f.exists()) {
try {
ipcgen.parse(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
return ipcgen;
}
};
InhabitantsParsingContextGenerator ipcgen;
try {
InhabitantsFeed feed = InhabitantsFeed.create(habitat, ip);
ipcgen = (USE_CACHE) ? ipcgCache.get(classpath, populator) : populator.call();
feed.populate(ipcgen);