/** * Return the absolute temp dir for given web server. * @param prefix server name * @return the temp dir for given server. */ protected final File createTempDir(String prefix) { try { File tempDir = File.createTempFile(prefix + ".", "." + getPort()); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); return tempDir; } catch (IOException ex) { throw new WebServerException( "Unable to create tempDir. java.io.tmpdir is set to " + System.getProperty("java.io.tmpdir"), ex); } }
@Override @SuppressWarnings("try") public void onStartup(ServletContext servletContext) throws ServletException { if (factory.getPort() == 0) { LOGGER.warn( "spring boot embed web container listen port is 0, serviceComb will not use container's port to handler RESTful request."); return; } // web container did not did listen now. // so mock to listen, and then close. try (ServerSocket ss = new ServerSocket(factory.getPort(), 0, factory.getAddress())) { if (StringUtils.isEmpty(ServletConfig.getServletUrlPattern())) { // ensure the servlet will be instantiated Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, ServletConfig.DEFAULT_URL_PATTERN); } ServletUtils.init(servletContext); } catch (IOException e) { throw new ServletException(e); } } }