Example usage for org.springframework.beans.factory.support BeanDefinitionValidationException BeanDefinitionValidationException

List of usage examples for org.springframework.beans.factory.support BeanDefinitionValidationException BeanDefinitionValidationException

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support BeanDefinitionValidationException BeanDefinitionValidationException.

Prototype

public BeanDefinitionValidationException(String msg, Throwable cause) 

Source Link

Document

Create a new BeanDefinitionValidationException with the specified message and root cause.

Usage

From source file:org.bigtester.ate.model.data.CaseDataProcessor.java

/**
 * {@inheritDoc}/*from ww w .ja  v a2  s.com*/
 */
@Override
public void postProcessBeanFactory(@Nullable ConfigurableListableBeanFactory beanFactory)
        throws BeansException {
    if (beanFactory == null)
        throw new IllegalStateException("Spring Container initialization error");
    String[] homePageNames = beanFactory.getBeanNamesForType(Homepage.class, true, false);
    String[] lastPageNames = beanFactory.getBeanNamesForType(Lastpage.class, true, false);
    String[] regularPageNames = beanFactory.getBeanNamesForType(RegularPage.class, true, false);

    allPageNames = ArrayUtils.addAll(homePageNames, lastPageNames);
    allPageNames = ArrayUtils.addAll(allPageNames, regularPageNames);

    for (int i = 0; i < getAllPageNames().length; i++) {
        pageBeanDefs.add(beanFactory.getBeanDefinition(getAllPageNames()[i]));
    }

    for (int j = 0; j < pageBeanDefs.size(); j++) {
        if (null != pageBeanDefs.get(j).getPropertyValues()
                .getPropertyValue(XsdElementConstants.ATTR_BASEPAGEOBJECT_DATAFILE)) {
            caseDataFiles.add(new FileSystemResource((String) pageBeanDefs.get(j).getPropertyValues()
                    .getPropertyValue(XsdElementConstants.ATTR_BASEPAGEOBJECT_DATAFILE).getValue()));
        }
    }

    if (!caseDataFiles.isEmpty()) {
        dbInit = GlobalUtils.findDBInitializer(beanFactory);
        try {
            getDbInit().setInitXmlFiles(caseDataFiles);
        } catch (IOException e) {
            throw new BeanDefinitionValidationException("Page data file in page attribute can't be read!", e);
        }
        try {
            getDbInit().initialize(beanFactory);
        } catch (MalformedURLException | DatabaseUnitException | SQLException e) {
            throw new FatalBeanException("Case database creation error!", e);
        }
    }
}