org.springframework.boot.system.ApplicationHome Java Examples

The following examples show how to use org.springframework.boot.system.ApplicationHome. 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: ShellSpawner.java    From djl-demo with Apache License 2.0 6 votes vote down vote up
static InteractiveShell createShell(String engine) {
    InteractiveShell shell = new InteractiveShell();
    ApplicationHome home = new ApplicationHome(BlockRunnerController.class);
    Path targetDir = home.getDir().toPath().resolve("djl");
    extractJars(targetDir);
    shell.addDependencyDir(targetDir.resolve("basic"));
    File[] engineFiles = targetDir.resolve("engines").toFile().listFiles();
    if (engineFiles == null) {
        throw new IllegalStateException("Cannot find Engine files");
    }
    for (File file : engineFiles) {
        if (file.getName().startsWith(engine)) {
            shell.addDependency(file.toPath());
        }
    }
    return shell;
}
 
Example #2
Source File: NarayanaConfiguration.java    From narayana-spring-boot with Apache License 2.0 5 votes vote down vote up
private File getLogDir() {
    if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
        return new File(this.jtaProperties.getLogDir());
    }
    File home = new ApplicationHome().getDir();
    return new File(home, "transaction-logs");
}
 
Example #3
Source File: NarayanaConfigurationTest.java    From narayana-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void narayanaPropertiesInitializerShouldUseDefaultLogDir() {
    this.configuration.narayanaPropertiesInitializer(this.mockNarayanaProperties);
    File applicationHomeDir = new ApplicationHome().getDir();
    File expectedLogDir = new File(applicationHomeDir, "transaction-logs");
    verify(this.mockNarayanaProperties).setLogDir(expectedLogDir.getAbsolutePath());
}
 
Example #4
Source File: ResourceUtil.java    From das with Apache License 2.0 4 votes vote down vote up
public String getClasspath() {
    ApplicationHome h = new ApplicationHome(DbUtil.class);
    File jarF = h.getSource();
    return jarF.getParentFile().toString();
}
 
Example #5
Source File: JpomManifest.java    From Jpom with MIT License 4 votes vote down vote up
/**
 * 获取当前运行的路径
 *
 * @return jar 或者classPath
 */
public static File getRunPath() {
    ApplicationHome home = new ApplicationHome(JpomApplication.getAppClass());
    String path = (home.getSource() == null ? "" : home.getSource().getAbsolutePath());
    return FileUtil.file(path);
}