org.bidib.wizard.common.autoconfig.SettingsBeanPostProcessor Maven / Gradle / Ivy
package org.bidib.wizard.common.autoconfig;
import org.bidib.wizard.common.model.settings.AbstractSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
public class SettingsBeanPostProcessor implements BeanPostProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(SettingsBeanPostProcessor.class);
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
handleSettingsBean(bean, beanName);
return bean;
}
private void handleSettingsBean(Object bean, String beanName) {
if (bean instanceof AbstractSettings) {
try {
LOGGER.info("Migrate settings of bean: {}", beanName);
((AbstractSettings) bean).migrate();
}
catch (Exception ex) {
LOGGER.warn("Migrate settings failed.", ex);
}
}
}
}