/** * Return the temporary directory for the current web application, * as provided by the servlet container. * @return the File representing the temporary directory * @throws IllegalStateException if not running within a ServletContext * @see org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext) */ protected final File getTempDir() throws IllegalStateException { ServletContext servletContext = getServletContext(); Assert.state(servletContext != null, "ServletContext is required"); return WebUtils.getTempDir(servletContext); }
/** * Return the temporary directory for the current web application, * as provided by the servlet container. * @return the File representing the temporary directory * @throws IllegalStateException if not running within a ServletContext * @see org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext) */ protected final File getTempDir() throws IllegalStateException { ServletContext servletContext = getServletContext(); Assert.state(servletContext != null, "ServletContext is required"); return WebUtils.getTempDir(servletContext); }
@Test @SuppressWarnings("resource") public void testWebApplicationObjectSupport() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); File tempDir = new File(""); wac.getServletContext().setAttribute(WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE, tempDir); wac.registerBeanDefinition("test", new RootBeanDefinition(TestWebApplicationObject.class)); wac.refresh(); WebApplicationObjectSupport wao = (WebApplicationObjectSupport) wac.getBean("test"); assertEquals(wao.getServletContext(), wac.getServletContext()); assertEquals(wao.getTempDir(), tempDir); }
/** * Return the temporary directory for the current web application, * as provided by the servlet container. * @return the File representing the temporary directory * @throws IllegalStateException if not running within a ServletContext * @see org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext) */ protected final File getTempDir() throws IllegalStateException { ServletContext servletContext = getServletContext(); Assert.state(servletContext != null, "ServletContext is required"); return WebUtils.getTempDir(servletContext); }
/** * Return the temporary directory for the current web application, * as provided by the servlet container. * @return the File representing the temporary directory * @throws IllegalStateException if not running in a WebApplicationContext */ protected final File getTempDir() { return WebUtils.getTempDir(getServletContext()); }
/** * Return the temporary directory for the current web application, * as provided by the servlet container. * @return the File representing the temporary directory * @throws IllegalStateException if not running within a ServletContext * @see org.springframework.web.util.WebUtils#getTempDir(javax.servlet.ServletContext) */ protected final File getTempDir() throws IllegalStateException { ServletContext servletContext = getServletContext(); Assert.state(servletContext != null, "ServletContext is required"); return WebUtils.getTempDir(servletContext); }