commit
54604805ae
|
|
@ -95,7 +95,7 @@ public class ApplicationHome {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the underlying source used to find the home folder. This is usually the jar
|
* Returns the underlying source used to find the home directory. This is usually the jar
|
||||||
* file or a directory. Can return {@code null} if the source cannot be determined.
|
* file or a directory. Can return {@code null} if the source cannot be determined.
|
||||||
* @return the underlying source or {@code null}
|
* @return the underlying source or {@code null}
|
||||||
*/
|
*/
|
||||||
|
|
@ -104,8 +104,8 @@ public class ApplicationHome {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the application home folder.
|
* Returns the application home directory.
|
||||||
* @return the home folder (never {@code null})
|
* @return the home directory (never {@code null})
|
||||||
*/
|
*/
|
||||||
public File getDir() {
|
public File getDir() {
|
||||||
return this.dir;
|
return this.dir;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple detection for well known cloud platforms. For more advanced cloud provider
|
* Simple detection for well known cloud platforms. For more advanced cloud provider
|
||||||
* integration consider the Spring Clould project.
|
* integration consider the Spring Cloud project.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 1.3.0
|
* @since 1.3.0
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ public abstract class AbstractConfigurableEmbeddedServletContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not he JSP servlet should be registered with the embedded
|
* Returns whether or not the JSP servlet should be registered with the embedded
|
||||||
* container.
|
* container.
|
||||||
* @return {@code true} if the container should be registered, otherwise {@code false}
|
* @return {@code true} if the container should be registered, otherwise {@code false}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public abstract class AbstractEmbeddedServletContainerFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute document root when it points to a valid folder, logging a
|
* Returns the absolute document root when it points to a valid directory, logging a
|
||||||
* warning and returning {@code null} otherwise.
|
* warning and returning {@code null} otherwise.
|
||||||
* @return the valid document root
|
* @return the valid document root
|
||||||
*/
|
*/
|
||||||
|
|
@ -171,15 +171,15 @@ public abstract class AbstractEmbeddedServletContainerFactory
|
||||||
*/
|
*/
|
||||||
protected File createTempDir(String prefix) {
|
protected File createTempDir(String prefix) {
|
||||||
try {
|
try {
|
||||||
File tempFolder = File.createTempFile(prefix + ".", "." + getPort());
|
File tempDir = File.createTempFile(prefix + ".", "." + getPort());
|
||||||
tempFolder.delete();
|
tempDir.delete();
|
||||||
tempFolder.mkdir();
|
tempDir.mkdir();
|
||||||
tempFolder.deleteOnExit();
|
tempDir.deleteOnExit();
|
||||||
return tempFolder;
|
return tempDir;
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new EmbeddedServletContainerException(
|
throw new EmbeddedServletContainerException(
|
||||||
"Unable to create tempdir. java.io.tmpdir is set to "
|
"Unable to create tempDir. java.io.tmpdir is set to "
|
||||||
+ System.getProperty("java.io.tmpdir"),
|
+ System.getProperty("java.io.tmpdir"),
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public interface ConfigurableEmbeddedServletContainer {
|
||||||
void setMimeMappings(MimeMappings mimeMappings);
|
void setMimeMappings(MimeMappings mimeMappings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the document root folder which will be used by the web context to serve static
|
* Sets the document root directory which will be used by the web context to serve static
|
||||||
* files.
|
* files.
|
||||||
* @param documentRoot the document root or {@code null} if not required
|
* @param documentRoot the document root or {@code null} if not required
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -411,8 +411,8 @@ public class TomcatEmbeddedServletContainerFactory
|
||||||
Assert.state(manager instanceof StandardManager,
|
Assert.state(manager instanceof StandardManager,
|
||||||
"Unable to persist HTTP session state using manager type "
|
"Unable to persist HTTP session state using manager type "
|
||||||
+ manager.getClass().getName());
|
+ manager.getClass().getName());
|
||||||
File folder = getValidSessionStoreDir();
|
File dir = getValidSessionStoreDir();
|
||||||
File file = new File(folder, "SESSIONS.ser");
|
File file = new File(dir, "SESSIONS.ser");
|
||||||
((StandardManager) manager).setPathname(file.getAbsolutePath());
|
((StandardManager) manager).setPathname(file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ abstract class TomcatResources {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addJar(String jar) {
|
protected void addJar(String jar) {
|
||||||
URL url = getJarUlr(jar);
|
URL url = getJarUrl(jar);
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
try {
|
try {
|
||||||
this.addResourceJarUrlMethod.invoke(getContext(), url);
|
this.addResourceJarUrlMethod.invoke(getContext(), url);
|
||||||
|
|
@ -127,7 +127,7 @@ abstract class TomcatResources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private URL getJarUlr(String jar) {
|
private URL getJarUrl(String jar) {
|
||||||
try {
|
try {
|
||||||
return new URL(jar);
|
return new URL(jar);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ import io.undertow.servlet.api.SessionPersistenceManager;
|
||||||
*/
|
*/
|
||||||
public class FileSessionPersistence implements SessionPersistenceManager {
|
public class FileSessionPersistence implements SessionPersistenceManager {
|
||||||
|
|
||||||
private final File folder;
|
private final File dir;
|
||||||
|
|
||||||
public FileSessionPersistence(File folder) {
|
public FileSessionPersistence(File dir) {
|
||||||
this.folder = folder;
|
this.dir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -124,10 +124,10 @@ public class FileSessionPersistence implements SessionPersistenceManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getSessionFile(String deploymentName) {
|
private File getSessionFile(String deploymentName) {
|
||||||
if (!this.folder.exists()) {
|
if (!this.dir.exists()) {
|
||||||
this.folder.mkdirs();
|
this.dir.mkdirs();
|
||||||
}
|
}
|
||||||
return new File(this.folder, deploymentName + ".session");
|
return new File(this.dir, deploymentName + ".session");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine
|
||||||
}
|
}
|
||||||
catch (ServletException ex) {
|
catch (ServletException ex) {
|
||||||
throw new EmbeddedServletContainerException(
|
throw new EmbeddedServletContainerException(
|
||||||
"Unable to start embdedded Undertow", ex);
|
"Unable to start embedded Undertow", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -358,8 +358,8 @@ public class UndertowEmbeddedServletContainerFactory
|
||||||
configureAccessLog(deployment);
|
configureAccessLog(deployment);
|
||||||
}
|
}
|
||||||
if (isPersistSession()) {
|
if (isPersistSession()) {
|
||||||
File folder = getValidSessionStoreDir();
|
File dir = getValidSessionStoreDir();
|
||||||
deployment.setSessionPersistenceManager(new FileSessionPersistence(folder));
|
deployment.setSessionPersistenceManager(new FileSessionPersistence(dir));
|
||||||
}
|
}
|
||||||
DeploymentManager manager = Servlets.defaultContainer().addDeployment(deployment);
|
DeploymentManager manager = Servlets.defaultContainer().addDeployment(deployment);
|
||||||
manager.deploy();
|
manager.deploy();
|
||||||
|
|
@ -433,7 +433,7 @@ public class UndertowEmbeddedServletContainerFactory
|
||||||
return new FileResourceManager(root, 0);
|
return new FileResourceManager(root, 0);
|
||||||
}
|
}
|
||||||
if (root.isFile()) {
|
if (root.isFile()) {
|
||||||
return new JarResourcemanager(root);
|
return new JarResourceManager(root);
|
||||||
}
|
}
|
||||||
return ResourceManager.EMPTY_RESOURCE_MANAGER;
|
return ResourceManager.EMPTY_RESOURCE_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
@ -532,15 +532,15 @@ public class UndertowEmbeddedServletContainerFactory
|
||||||
/**
|
/**
|
||||||
* Undertow {@link ResourceManager} for JAR resources.
|
* Undertow {@link ResourceManager} for JAR resources.
|
||||||
*/
|
*/
|
||||||
private static class JarResourcemanager implements ResourceManager {
|
private static class JarResourceManager implements ResourceManager {
|
||||||
|
|
||||||
private final String jarPath;
|
private final String jarPath;
|
||||||
|
|
||||||
JarResourcemanager(File jarFile) {
|
JarResourceManager(File jarFile) {
|
||||||
this(jarFile.getAbsolutePath());
|
this(jarFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
JarResourcemanager(String jarPath) {
|
JarResourceManager(String jarPath) {
|
||||||
this.jarPath = jarPath;
|
this.jarPath = jarPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import org.springframework.mock.web.MockServletContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link MockServletContext} implementation for Spring Boot. Respects well know Spring
|
* {@link MockServletContext} implementation for Spring Boot. Respects well know Spring
|
||||||
* Boot resource locations and uses an empty folder for "/" if no locations can be found.
|
* Boot resource locations and uses an empty directory for "/" if no locations can be found.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
*/
|
*/
|
||||||
|
|
@ -88,7 +88,7 @@ public class SpringBootMockServletContext extends MockServletContext {
|
||||||
public URL getResource(String path) throws MalformedURLException {
|
public URL getResource(String path) throws MalformedURLException {
|
||||||
URL resource = super.getResource(path);
|
URL resource = super.getResource(path);
|
||||||
if (resource == null && "/".equals(path)) {
|
if (resource == null && "/".equals(path)) {
|
||||||
// Liquibase assumes that "/" always exists, if we don't have a folder
|
// Liquibase assumes that "/" always exists, if we don't have a directory
|
||||||
// use a temporary location.
|
// use a temporary location.
|
||||||
try {
|
try {
|
||||||
if (this.emptyRootFolder == null) {
|
if (this.emptyRootFolder == null) {
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ public class TomcatEmbeddedServletContainerFactoryTests
|
||||||
public void disableDoesNotSaveSessionFiles() throws Exception {
|
public void disableDoesNotSaveSessionFiles() throws Exception {
|
||||||
File baseDir = this.temporaryFolder.newFolder();
|
File baseDir = this.temporaryFolder.newFolder();
|
||||||
TomcatEmbeddedServletContainerFactory factory = getFactory();
|
TomcatEmbeddedServletContainerFactory factory = getFactory();
|
||||||
// If baseDir is not set SESSIONS.ser is written to a different temp folder
|
// If baseDir is not set SESSIONS.ser is written to a different temp directory
|
||||||
// each time. By setting it we can really ensure that data isn't saved
|
// each time. By setting it we can really ensure that data isn't saved
|
||||||
factory.setBaseDirectory(baseDir);
|
factory.setBaseDirectory(baseDir);
|
||||||
this.container = factory
|
this.container = factory
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class FileSessionPersistenceTests {
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temp = new TemporaryFolder();
|
public TemporaryFolder temp = new TemporaryFolder();
|
||||||
|
|
||||||
private File folder;
|
private File dir;
|
||||||
|
|
||||||
private FileSessionPersistence persistence;
|
private FileSessionPersistence persistence;
|
||||||
|
|
||||||
|
|
@ -53,8 +53,8 @@ public class FileSessionPersistenceTests {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
this.folder = this.temp.newFolder();
|
this.dir = this.temp.newFolder();
|
||||||
this.persistence = new FileSessionPersistence(this.folder);
|
this.persistence = new FileSessionPersistence(this.dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -97,7 +97,7 @@ public class FileSessionPersistenceTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteFileOnClear() throws Exception {
|
public void deleteFileOnClear() throws Exception {
|
||||||
File sessionFile = new File(this.folder, "test.session");
|
File sessionFile = new File(this.dir, "test.session");
|
||||||
Map<String, PersistentSession> sessionData = new LinkedHashMap<String, PersistentSession>();
|
Map<String, PersistentSession> sessionData = new LinkedHashMap<String, PersistentSession>();
|
||||||
this.persistence.persistSessions("test", sessionData);
|
this.persistence.persistSessions("test", sessionData);
|
||||||
assertThat(sessionFile.exists(), equalTo(true));
|
assertThat(sessionFile.exists(), equalTo(true));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue