Search in sources :

Example 26 with ContextRefreshedEvent

use of org.springframework.context.event.ContextRefreshedEvent in project alfresco-remote-api by Alfresco.

the class ApiBootstrap method onBootstrap.

@Override
protected void onBootstrap(ApplicationEvent event) {
    logger.info("Bootstapping the API");
    ContextRefreshedEvent refreshEvent = (ContextRefreshedEvent) event;
    ApplicationContext ac = refreshEvent.getApplicationContext();
    Map<String, Object> entityResourceBeans = ac.getBeansWithAnnotation(EntityResource.class);
    Map<String, Object> relationResourceBeans = ac.getBeansWithAnnotation(RelationshipResource.class);
    apiDictionary.setDictionary(ResourceDictionaryBuilder.build(entityResourceBeans.values(), relationResourceBeans.values()));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent)

Example 27 with ContextRefreshedEvent

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

the class BeanFactoryPostProcessorTests method testBeanFactoryPostProcessorAsApplicationListener.

@Test
public void testBeanFactoryPostProcessorAsApplicationListener() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerBeanDefinition("bfpp", new RootBeanDefinition(ListeningBeanFactoryPostProcessor.class));
    ac.refresh();
    boolean condition = ac.getBean(ListeningBeanFactoryPostProcessor.class).received instanceof ContextRefreshedEvent;
    assertThat(condition).isTrue();
}
Also used : RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) ContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent) Test(org.junit.jupiter.api.Test)

Example 28 with ContextRefreshedEvent

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

the class SpringApplicationAdminMXBeanRegistrarTests method validateReadyFlag.

@Test
void validateReadyFlag() {
    final ObjectName objectName = createObjectName(OBJECT_NAME);
    SpringApplication application = new SpringApplication(Config.class);
    application.setWebApplicationType(WebApplicationType.NONE);
    application.addListeners((ContextRefreshedEvent event) -> {
        try {
            assertThat(isApplicationReady(objectName)).isFalse();
        } catch (Exception ex) {
            throw new IllegalStateException("Could not contact spring application admin bean", ex);
        }
    });
    this.context = application.run();
    assertThat(isApplicationReady(objectName)).isTrue();
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectName(javax.management.ObjectName) ContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent) Test(org.junit.jupiter.api.Test)

Aggregations

ContextRefreshedEvent (org.springframework.context.event.ContextRefreshedEvent)28 Test (org.junit.Test)8 Test (org.junit.jupiter.api.Test)8 ApplicationContext (org.springframework.context.ApplicationContext)6 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 ContextClosedEvent (org.springframework.context.event.ContextClosedEvent)4 Notification (javax.management.Notification)3 BeanFactory (org.springframework.beans.factory.BeanFactory)3 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)3 QueueChannel (org.springframework.integration.channel.QueueChannel)3 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)2 XpipeRuntimeException (com.ctrip.xpipe.exception.XpipeRuntimeException)1 Field (java.lang.reflect.Field)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)1 RoutesCollector (org.apache.camel.spring.boot.RoutesCollector)1 BeansException (org.springframework.beans.BeansException)1