Search in sources :

Example 1 with WebServerApplicationContext

use of org.springframework.boot.web.context.WebServerApplicationContext in project springboot-demo by small-rose.

the class AppServerInfo method onApplicationEvent.

@SneakyThrows
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
    WebServer server = event.getWebServer();
    WebServerApplicationContext context = event.getApplicationContext();
    Environment env = context.getEnvironment();
    String ip = InetAddress.getLocalHost().getHostAddress();
    int port = server.getPort();
    String contextPath = env.getProperty("server.servlet.context-path");
    if (contextPath == null) {
        contextPath = "";
    }
    String termsOfServiceUrl = swaggerConfig.apiInfo().getTermsOfServiceUrl();
    log.info("\n------------------------------------------------------------\n" + "\tApplication is running! Access address:\n" + "\tLocal:\t\thttp://localhost:{}{}" + "\n\tExternal:\thttp://{}:{}{}" + "\n\tCheckUrl:\thttp://{}:{}{}{}" + "\n\tApiInfo:\t{}" + "\n------------------------------------------------------------\n", port, contextPath, ip, port, contextPath, ip, port, contextPath, "/path", termsOfServiceUrl);
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) Environment(org.springframework.core.env.Environment) SneakyThrows(lombok.SneakyThrows)

Example 2 with WebServerApplicationContext

use of org.springframework.boot.web.context.WebServerApplicationContext in project springboot-demo by small-rose.

the class AppServerInfo method onApplicationEvent.

@SneakyThrows
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
    WebServer server = event.getWebServer();
    WebServerApplicationContext context = event.getApplicationContext();
    Environment env = context.getEnvironment();
    String ip = InetAddress.getLocalHost().getHostAddress();
    int port = server.getPort();
    String contextPath = env.getProperty("server.servlet.context-path");
    if (contextPath == null) {
        contextPath = "";
    }
    String termsOfServiceUrl = swaggerConfig.apiInfo().getTermsOfServiceUrl();
    log.info("\n------------------------------------------------------------\n" + "\tApplication is running! Access address:\n" + "\tLocal:\t\thttp://localhost:{}{}" + "\n\tExternal:\thttp://{}:{}{}" + "\n\tCheckUrl:\thttp://{}:{}{}{}" + "\n\tApiInfo:\t{}" + "\n------------------------------------------------------------\n", port, contextPath, ip, port, contextPath, ip, port, contextPath, "/path", termsOfServiceUrl);
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) Environment(org.springframework.core.env.Environment) SneakyThrows(lombok.SneakyThrows)

Example 3 with WebServerApplicationContext

use of org.springframework.boot.web.context.WebServerApplicationContext in project springboot-demo by small-rose.

the class AppServerInfo method onApplicationEvent.

@SneakyThrows
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
    WebServer server = event.getWebServer();
    WebServerApplicationContext context = event.getApplicationContext();
    Environment env = context.getEnvironment();
    String ip = InetAddress.getLocalHost().getHostAddress();
    int port = server.getPort();
    String contextPath = env.getProperty("server.servlet.context-path");
    if (contextPath == null) {
        contextPath = "";
    }
    log.info("\n------------------------------------------------------------\n" + "\tApplication is running! Access address:\n" + "\tLocal:\t\thttp://localhost:{}{}" + "\n\tExternal:\thttp://{}:{}{}" + "\n------------------------------------------------------------\n", port, contextPath, ip, port, contextPath);
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) Environment(org.springframework.core.env.Environment) SneakyThrows(lombok.SneakyThrows)

Example 4 with WebServerApplicationContext

use of org.springframework.boot.web.context.WebServerApplicationContext in project springboot-demo by small-rose.

the class AppServerInfo method onApplicationEvent.

@SneakyThrows
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
    WebServer server = event.getWebServer();
    WebServerApplicationContext context = event.getApplicationContext();
    Environment env = context.getEnvironment();
    String ip = InetAddress.getLocalHost().getHostAddress();
    int port = server.getPort();
    String contextPath = env.getProperty("server.servlet.context-path");
    if (contextPath == null) {
        contextPath = "";
    }
    String termsOfServiceUrl = swaggerConfig.apiInfo().getTermsOfServiceUrl();
    log.info("\n------------------------------------------------------------\n" + "\tApplication is running! Access address:\n" + "\tLocal:\t\thttp://localhost:{}{}" + "\n\tExternal:\thttp://{}:{}{}" + "\n\tCheckUrl:\thttp://{}:{}{}{}" + "\n\tApiInfo:\t{}" + "\n------------------------------------------------------------\n", port, contextPath, ip, port, contextPath, ip, port, contextPath, "/path", termsOfServiceUrl);
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) Environment(org.springframework.core.env.Environment) SneakyThrows(lombok.SneakyThrows)

Example 5 with WebServerApplicationContext

use of org.springframework.boot.web.context.WebServerApplicationContext in project dynamic-tp by lyh200.

the class AbstractWebServerTpHandler method getWebServerTp.

@Override
public Executor getWebServerTp() {
    if (webServerExecutor == null) {
        synchronized (AbstractWebServerTpHandler.class) {
            if (webServerExecutor == null) {
                ApplicationContext applicationContext = ApplicationContextHolder.getInstance();
                WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer();
                webServerExecutor = doGetTp(webServer);
            }
        }
    }
    return webServerExecutor;
}
Also used : WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) WebServer(org.springframework.boot.web.server.WebServer) WebServerApplicationContext(org.springframework.boot.web.context.WebServerApplicationContext)

Aggregations

WebServerApplicationContext (org.springframework.boot.web.context.WebServerApplicationContext)20 WebServer (org.springframework.boot.web.server.WebServer)15 Environment (org.springframework.core.env.Environment)11 SneakyThrows (lombok.SneakyThrows)8 ApplicationContext (org.springframework.context.ApplicationContext)7 EventListener (org.springframework.context.event.EventListener)2 Order (org.springframework.core.annotation.Order)2 Async (org.springframework.scheduling.annotation.Async)2 WebServerTpHandler (com.dtp.adapter.web.handler.WebServerTpHandler)1 MobileAutomationServer (com.testsigma.agent.mobile.MobileAutomationServer)1 AgentWebServer (com.testsigma.agent.ws.server.AgentWebServer)1 UnknownHostException (java.net.UnknownHostException)1 Server (org.eclipse.jetty.server.Server)1 Test (org.junit.Test)1 JettyWebServer (org.springframework.boot.web.embedded.jetty.JettyWebServer)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 ContextRefreshedEvent (org.springframework.context.event.ContextRefreshedEvent)1