All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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);
            }
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy