Search in sources :

Example 1 with ConfigurableWebServerApplicationContext

use of org.springframework.boot.web.context.ConfigurableWebServerApplicationContext in project spring-native by spring-projects-experimental.

the class AotManagementContextFactoryTests method createManagementContextWithReactiveEnv.

@Test
void createManagementContextWithReactiveEnv() {
    AotManagementContextFactory factory = new AotManagementContextFactory(this::testContextInitializer, true);
    GenericApplicationContext parent = mock(GenericApplicationContext.class);
    ConfigurableWebServerApplicationContext managementContext = factory.createManagementContext(parent, DummyConfiguration.class);
    assertThat(managementContext).isExactlyInstanceOf(ReactiveWebServerApplicationContext.class).satisfies(managementContext(parent));
}
Also used : ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigurableWebServerApplicationContext

use of org.springframework.boot.web.context.ConfigurableWebServerApplicationContext in project spring-cloud-consul by spring-cloud.

the class ConsulAutoServiceRegistrationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
    if (applicationEvent instanceof WebServerInitializedEvent) {
        WebServerInitializedEvent event = (WebServerInitializedEvent) applicationEvent;
        ApplicationContext context = event.getApplicationContext();
        if (context instanceof ConfigurableWebServerApplicationContext) {
            if ("management".equals(((ConfigurableWebServerApplicationContext) context).getServerNamespace())) {
                return;
            }
        }
        this.autoServiceRegistration.setPortIfNeeded(event.getWebServer().getPort());
        this.autoServiceRegistration.start();
    }
}
Also used : ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) WebServerInitializedEvent(org.springframework.boot.web.context.WebServerInitializedEvent)

Example 3 with ConfigurableWebServerApplicationContext

use of org.springframework.boot.web.context.ConfigurableWebServerApplicationContext in project spring-native by spring-projects-experimental.

the class AotManagementContextFactoryTests method createManagementContextWithServletEnv.

@Test
void createManagementContextWithServletEnv() {
    AotManagementContextFactory factory = new AotManagementContextFactory(this::testContextInitializer, false);
    GenericApplicationContext parent = mock(GenericApplicationContext.class);
    ConfigurableWebServerApplicationContext managementContext = factory.createManagementContext(parent, DummyConfiguration.class);
    assertThat(managementContext).isExactlyInstanceOf(ServletWebServerApplicationContext.class).satisfies(managementContext(parent));
}
Also used : ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurableWebServerApplicationContext

use of org.springframework.boot.web.context.ConfigurableWebServerApplicationContext in project spring-native by spring-projects-experimental.

the class AotManagementContextFactory method createManagementContext.

@Override
public ConfigurableWebServerApplicationContext createManagementContext(ApplicationContext parent, Class<?>... configurationClasses) {
    ConfigurableWebServerApplicationContext actuatorContext = createContext();
    actuatorContext.setParent(parent);
    actuatorContextInitializer.get().initialize((GenericApplicationContext) actuatorContext);
    return actuatorContext;
}
Also used : ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext)

Example 5 with ConfigurableWebServerApplicationContext

use of org.springframework.boot.web.context.ConfigurableWebServerApplicationContext in project spring-cloud-huawei-samples by huaweicloud.

the class ServiceCombListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
    ApplicationContext context = event.getApplicationContext();
    if (context instanceof ConfigurableWebServerApplicationContext) {
        if ("management".equals(((ConfigurableWebServerApplicationContext) context).getServerNamespace())) {
            return;
        }
    }
    registration.start();
}
Also used : ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) ConfigurableWebServerApplicationContext(org.springframework.boot.web.context.ConfigurableWebServerApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext)

Aggregations

ConfigurableWebServerApplicationContext (org.springframework.boot.web.context.ConfigurableWebServerApplicationContext)5 Test (org.junit.jupiter.api.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2 WebServerInitializedEvent (org.springframework.boot.web.context.WebServerInitializedEvent)1 ReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext)1 ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext)1