* @see InitializingBean#afterPropertiesSet()
* @see #onAfterPropertiesSet()
*/
public final void afterPropertiesSet() throws FatalCacheException {
if (cacheProviderFacade == null) {
throw new FatalCacheException(
"The cache provider facade should not be null");
}
if (flushingModels == null || flushingModels.isEmpty()) {
return;
}
CacheModelValidator validator = cacheProviderFacade
.modelValidator();
if (flushingModels instanceof Properties) {
PropertyEditor editor = cacheProviderFacade.getFlushingModelEditor();
Properties properties = (Properties) flushingModels;
Map newFlushingModels = new HashMap();
String id = null;
try {
for (Iterator i = properties.keySet().iterator(); i.hasNext();) {
id = (String) i.next();
String property = properties.getProperty(id);
editor.setAsText(property);
Object flushingModel = editor.getValue();
validator.validateFlushingModel(flushingModel);
newFlushingModels.put(id, flushingModel);
}
} catch (Exception exception) {
throw new FatalCacheException(
"Unable to create the flushing model with id "
+ StringUtils.quote(id), exception);
}
setFlushingModels(newFlushingModels);
} else {
String id = null;
try {
for (Iterator i = flushingModels.keySet().iterator(); i.hasNext();) {
id = (String) i.next();
Object flushingModel = flushingModels.get(id);
validator.validateFlushingModel(flushingModel);
}
} catch (Exception exception) {
throw new FatalCacheException(
"Unable to validate flushing model with id "
+ StringUtils.quote(id), exception);
}
}