use of org.springframework.boot.web.context.WebServerInitializedEvent 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();
}
}
Aggregations