Search in sources :

Example 1 with ApplicationHome

use of org.springframework.boot.system.ApplicationHome in project spring-boot by spring-projects.

the class AbstractServletWebServerFactoryTests method getValidSessionStoreWhenSessionStoreIsRelative.

@Test
void getValidSessionStoreWhenSessionStoreIsRelative() {
    AbstractServletWebServerFactory factory = getFactory();
    factory.getSession().setStoreDir(new File("sessions"));
    File dir = factory.getValidSessionStoreDir(false);
    assertThat(dir.getName()).isEqualTo("sessions");
    assertThat(dir.getParentFile()).isEqualTo(new ApplicationHome().getDir());
}
Also used : ApplicationHome(org.springframework.boot.system.ApplicationHome) File(java.io.File) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 2 with ApplicationHome

use of org.springframework.boot.system.ApplicationHome in project spring-boot by spring-projects.

the class SessionStoreDirectory method getValidDirectory.

File getValidDirectory(boolean mkdirs) {
    File dir = getDirectory();
    if (dir == null) {
        return new ApplicationTemp().getDir("servlet-sessions");
    }
    if (!dir.isAbsolute()) {
        dir = new File(new ApplicationHome().getDir(), dir.getPath());
    }
    if (!dir.exists() && mkdirs) {
        dir.mkdirs();
    }
    assertDirectory(mkdirs, dir);
    return dir;
}
Also used : ApplicationHome(org.springframework.boot.system.ApplicationHome) File(java.io.File) ApplicationTemp(org.springframework.boot.system.ApplicationTemp)

Example 3 with ApplicationHome

use of org.springframework.boot.system.ApplicationHome in project spring-boot by spring-projects.

the class StartupInfoLogger method appendContext.

private void appendContext(StringBuilder message) {
    StringBuilder context = new StringBuilder();
    ApplicationHome home = new ApplicationHome(this.sourceClass);
    if (home.getSource() != null) {
        context.append(home.getSource().getAbsolutePath());
    }
    append(context, "started by ", () -> System.getProperty("user.name"));
    append(context, "in ", () -> System.getProperty("user.dir"));
    if (context.length() > 0) {
        message.append(" (");
        message.append(context);
        message.append(")");
    }
}
Also used : ApplicationHome(org.springframework.boot.system.ApplicationHome)

Aggregations

ApplicationHome (org.springframework.boot.system.ApplicationHome)3 File (java.io.File)2 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ApplicationTemp (org.springframework.boot.system.ApplicationTemp)1