Search in sources :

Example 31 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-cloud-microservice-example by kbastani.

the class Application method main.

public static void main(String[] args) {
    ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
    RepositoryRestConfiguration restConfiguration = ctx.getBean("config", RepositoryRestConfiguration.class);
    restConfiguration.exposeIdsFor(User.class);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) RepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)

Example 32 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project cucumber-jvm by cucumber.

the class CucumberTestContextManager method createFallbackContext.

@SuppressWarnings("resource")
private ConfigurableListableBeanFactory createFallbackContext() {
    ConfigurableApplicationContext applicationContext;
    if (getClass().getClassLoader().getResource("cucumber.xml") != null) {
        applicationContext = new ClassPathXmlApplicationContext("cucumber.xml");
    } else {
        applicationContext = new GenericApplicationContext();
    }
    applicationContext.registerShutdownHook();
    ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    beanFactory.registerScope(GlueCodeScope.NAME, new GlueCodeScope());
    for (Class<?> stepClass : stepClasses) {
        registerStepClassBeanDefinition(beanFactory, stepClass);
    }
    return beanFactory;
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)

Example 33 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project POL-POM-5 by PlayOnLinux.

the class JavaFXApplication method start.

@Override
public void start(Stage primaryStage) {
    primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("views/common/phoenicis.png")));
    primaryStage.setTitle("Phoenicis");
    loadFonts();
    ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfiguration.class);
    final MainController mainController = applicationContext.getBean(MainController.class);
    mainController.show();
    mainController.setOnClose(() -> {
        applicationContext.getBean(ControlledThreadPoolExecutorServiceCloser.class).setCloseImmediately(true);
        applicationContext.close();
    });
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ControlledThreadPoolExecutorServiceCloser(org.phoenicis.multithreading.ControlledThreadPoolExecutorServiceCloser) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MainController(org.phoenicis.javafx.controller.MainController) Image(javafx.scene.image.Image)

Example 34 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method initializeAndRun.

private ConfigurableApplicationContext initializeAndRun(Class<?> config, Map<String, Object> properties, String... args) {
    Restarter.initialize(new String[0], false, new MockRestartInitializer(), false);
    SpringApplication application = new SpringApplication(config);
    application.setDefaultProperties(getDefaultProperties(properties));
    ConfigurableApplicationContext context = application.run(args);
    return context;
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringApplication(org.springframework.boot.SpringApplication) MockRestartInitializer(org.springframework.boot.devtools.restart.MockRestartInitializer)

Example 35 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class FrameworkServlet method refresh.

/**
	 * Refresh this servlet's application context, as well as the
	 * dependent state of the servlet.
	 * @see #getWebApplicationContext()
	 * @see org.springframework.context.ConfigurableApplicationContext#refresh()
	 */
public void refresh() {
    WebApplicationContext wac = getWebApplicationContext();
    if (!(wac instanceof ConfigurableApplicationContext)) {
        throw new IllegalStateException("WebApplicationContext does not support refresh: " + wac);
    }
    ((ConfigurableApplicationContext) wac).refresh();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ConfigurableWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) XmlWebApplicationContext(org.springframework.web.context.support.XmlWebApplicationContext)

Aggregations

ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)177 Test (org.junit.Test)110 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)42 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)17 ApplicationContext (org.springframework.context.ApplicationContext)17 SpringApplication (org.springframework.boot.SpringApplication)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 DataSource (javax.sql.DataSource)8 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)7 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)7 MBeanServer (javax.management.MBeanServer)6 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)6 Statement (java.sql.Statement)5 ArrayList (java.util.ArrayList)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)5 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)5 ObjectName (javax.management.ObjectName)4