Search in sources :

Example 1 with AbstractRefreshableConfigApplicationContext

use of org.springframework.context.support.AbstractRefreshableConfigApplicationContext in project kylo by Teradata.

the class SpringContextLoaderService method loadConfiurations.

/**
 * Called by the framework to load controller configurations, this method
 * will create a spring context
 *
 * @param context not used in this case
 * @throws InitializationException an except thrown if there are any errors
 */
@OnEnabled
public void loadConfiurations(final ConfigurationContext context) throws InitializationException {
    try {
        AbstractRefreshableConfigApplicationContext appContext = new ClassPathXmlApplicationContext();
        appContext.setClassLoader(getClass().getClassLoader());
        appContext.setConfigLocation("application-context.xml");
        getLogger().info("Refreshing spring context");
        appContext.refresh();
        getLogger().info("Spring context refreshed");
        this.contextFuture.set(appContext);
    } catch (BeansException | IllegalStateException e) {
        getLogger().error("Failed to load spring configurations", e);
        throw new InitializationException(e);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AbstractRefreshableConfigApplicationContext(org.springframework.context.support.AbstractRefreshableConfigApplicationContext) InitializationException(org.apache.nifi.reporting.InitializationException) BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) BeansException(org.springframework.beans.BeansException) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Aggregations

OnEnabled (org.apache.nifi.annotation.lifecycle.OnEnabled)1 InitializationException (org.apache.nifi.reporting.InitializationException)1 BeansException (org.springframework.beans.BeansException)1 BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 AbstractRefreshableConfigApplicationContext (org.springframework.context.support.AbstractRefreshableConfigApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1