本文整理了Java中org.apache.brooklyn.util.os.Os.home()
方法的一些代码示例,展示了Os.home()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Os.home()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.os.Os
类名称:Os
方法名:home
[英]user's home directory
[中]用户的主目录
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public static String fromHome(String path) {
return new File(Os.home(), path).getAbsolutePath();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
public Builder resetGlobalFiles() {
defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties";
globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties");
globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties");
return this;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
public Builder resetGlobalFiles() {
defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties";
globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties");
globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties");
return this;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** fails if the dir is not "safe" for deletion, currently length <= 2 or the home directory */
protected static void checkSafe(File dir) throws IOException {
String dp = dir.getAbsolutePath();
dp = Strings.removeFromEnd(dp, "/");
if (dp.length()<=2)
throw new IOException("Refusing instruction to delete "+dir+": name too short");
if (Os.home().equals(dp))
throw new IOException("Refusing instruction to delete "+dir+": it's the home directory");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testHome() {
log.info("home dir is: "+Os.home());
Assert.assertNotNull(Os.home());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/**
* Tidy up a file path.
* <p>
* Removes duplicate or trailing path separators (Unix style forward
* slashes only), replaces initial {@literal ~} with the
* value of {@link #home()} and folds out use of {@literal ..} and
* {@literal .} path segments.
*
* @see com.google.common.io.Files#simplifyPath(String)
*/
public static String tidyPath(String path) {
Preconditions.checkNotNull(path, "path");
Iterable<String> segments = Splitter.on("/").split(Files.simplifyPath(path));
if (Iterables.get(segments, 0).equals("~")) { // Always at least one segment after simplifyPath
segments = Iterables.concat(ImmutableSet.of(Os.home()), Iterables.skip(segments, 1));
}
String result = Joiner.on("/").join(segments);
if (log.isTraceEnabled() && !result.equals(path)) log.trace("Quietly changing '{}' to '{}'", path, result);
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
if (matcher.matches()) {
File home = new File(Os.home());
File file = new File(home, matcher.group(1));
out = file.toURI();
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
protected synchronized boolean find() {
if (isFound()) return true;
String customtmp = System.getProperty(BROOKLYN_OS_TMPDIR_PROPERTY);
if (customtmp!=null) {
if (checkAndSet(customtmp)) return true;
log.warn("TmpDirFinder: Custom tmp directory '"+customtmp+"' in "+BROOKLYN_OS_TMPDIR_PROPERTY+" is not a valid tmp dir; ignoring");
}
String systmp = System.getProperty("java.io.tmpdir");
boolean systmpWeird = (systmp.contains("/var/") || systmp.startsWith("/private"));
if (!systmpWeird) if (checkAndSet(systmp)) return true;
if (checkAndSet(File.separator+"tmp")) return true;
if (systmpWeird) if (checkAndSet(systmp)) return true;
try {
String hometmp = mergePaths(home(), ".tmp");
File hometmpF = new File(hometmp);
hometmpF.mkdirs();
if (checkAndSet(hometmp)) return true;
} catch (Exception e) {
log.debug("TmpDirFinder: Cannot create tmp dir in user's home dir: "+e);
}
return false;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups="Integration")
public void testMachine127InHome() throws Exception {
MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class));
app.start(ImmutableList.of(machine127));
String installDir = entity.getAttribute(SoftwareProcess.INSTALL_DIR);
assertTrue(installDir.startsWith(Os.home()+"/brooklyn-managed-processes/installs/"), "installed in "+installDir);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
f = new File(Os.home(), url.substring(2));
} else if (url.startsWith("~\\")) {
f = new File(Os.home(), url.substring(2));
} else {
f = new File(url);
代码示例来源:origin: org.apache.brooklyn/brooklyn-launcher
@Test(groups="Integration")
public void testWebServerTempDirRespectsDataDirConfig() throws Exception {
String dataDirName = ".brooklyn-foo"+Strings.makeRandomId(4);
String dataDir = "~/"+dataDirName;
launcher = newLauncherForTests(true)
.brooklynProperties(BrooklynServerConfig.MGMT_BASE_DIR, dataDir)
.start();
ManagementContext managementContext = launcher.getServerDetails().getManagementContext();
String expectedTempDir = Os.mergePaths(Os.home(), dataDirName, "planes", managementContext.getManagementNodeId(), "jetty");
File webappTempDir = launcher.getServerDetails().getWebServer().getWebappTempDir();
assertEquals(webappTempDir.getAbsolutePath(), expectedTempDir);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test
public void testInstallDirAndRunDirUsingTilde() throws Exception {
String dataDirName = ".brooklyn-foo"+Strings.makeRandomId(4);
String dataDir = "~/"+dataDirName;
String resolvedDataDir = Os.mergePaths(Os.home(), dataDirName);
MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
.configure(BrooklynConfigKeys.ONBOX_BASE_DIR, dataDir));
entity.start(ImmutableList.of(loc));
Assert.assertEquals(Os.nativePath(entity.getAttribute(SoftwareProcess.INSTALL_DIR)),
Os.nativePath(Os.mergePaths(resolvedDataDir, "installs/MyService")));
Assert.assertEquals(Os.nativePath(entity.getAttribute(SoftwareProcess.RUN_DIR)),
Os.nativePath(Os.mergePaths(resolvedDataDir, "apps/"+entity.getApplicationId()+"/entities/MyService_"+entity.getId())));
}
内容来源于网络,如有侵权,请联系作者删除!