org.springframework.boot.context.embedded.EmbeddedWebApplicationContext Java Examples
The following examples show how to use
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.
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: DiscoveryClientRegistrationInvoker.java From Moss with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableApplicationContext context) { if (context instanceof EmbeddedWebApplicationContext && !AdminEndpointApplicationRunListener.isEmbeddedServletServer(context.getEnvironment())) { MetaDataProvider metaDataProvider = context.getBean(MetaDataProvider.class); EmbeddedServletContainer embeddedServletContainer = new EmbeddedServletContainer() { @Override public void start() throws EmbeddedServletContainerException { } @Override public void stop() throws EmbeddedServletContainerException { } @Override public int getPort() { return metaDataProvider.getServerPort(); } }; context.publishEvent(new EmbeddedServletContainerInitializedEvent((EmbeddedWebApplicationContext) context, embeddedServletContainer)); } }
Example #2
Source File: Bootstrap.java From mywx with Apache License 2.0 | 6 votes |
/** * spring boot 服务主入口 * * @param args */ public static void main(String[] args) { ApplicationContext context = SpringApplication.run(Bootstrap.class, args); if (context instanceof EmbeddedWebApplicationContext) { int port = ((EmbeddedWebApplicationContext) context).getEmbeddedServletContainer().getPort(); String contextPath = context.getApplicationName(); String url = String.format(Locale.US, "http://localhost:%d%s", port, contextPath); if (log.isInfoEnabled()) { //提示项目用到的相关配置文件 log.info(" =========== ${user.dir}={} =========== ", System.getProperty("user.dir")); log.info(" =========== ${java.io.tmpdir}={} =========== ", System.getProperty("java.io.tmpdir")); String dashes = "------------------------------------------------------------------------"; log.info("Access URLs:\n{}\n\tLocal: \t\t{}\n{}", dashes, url, dashes); } } }
Example #3
Source File: TomcatMetricsBinder.java From foremast with Apache License 2.0 | 5 votes |
private Manager findManager(ApplicationContext applicationContext) { if (applicationContext instanceof EmbeddedWebApplicationContext) { EmbeddedServletContainer container = ((EmbeddedWebApplicationContext) applicationContext).getEmbeddedServletContainer(); if (container instanceof TomcatEmbeddedServletContainer) { Context context = findContext((TomcatEmbeddedServletContainer) container); if (context != null) { return context.getManager(); } } } return null; }
Example #4
Source File: DiscardListener.java From minicubes with Apache License 2.0 | 5 votes |
@Override public void finished(ConfigurableApplicationContext context, Throwable exception) { applicationContext = (EmbeddedWebApplicationContext) context; cdl.countDown(); }