Java Code Examples for org.springframework.boot.web.context.WebServerInitializedEvent#getApplicationContext()
The following examples show how to use
org.springframework.boot.web.context.WebServerInitializedEvent#getApplicationContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsulAutoServiceRegistrationListener.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
@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(); } }
Example 2
Source File: AbstractAutoServiceRegistration.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Deprecated public void bind(WebServerInitializedEvent event) { ApplicationContext context = event.getApplicationContext(); if (context instanceof ConfigurableWebServerApplicationContext) { if ("management".equals(((ConfigurableWebServerApplicationContext) context) .getServerNamespace())) { return; } } this.port.compareAndSet(0, event.getWebServer().getPort()); this.start(); }