org.apache.commons.lang.SystemUtils#IS_OS_UNIX源码实例Demo

下面列出了org.apache.commons.lang.SystemUtils#IS_OS_UNIX 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: citrus-admin   文件: AbstractTerminalCommand.java
@Override
public ProcessBuilder getProcessBuilder() {
    validateWorkingDirectory(workingDirectory);

    List<String> commands = new ArrayList<>();
    if (SystemUtils.IS_OS_UNIX) {
        commands.add(BASH);
        commands.add(BASH_OPTION_C);
    } else {
        commands.add(CMD);
        commands.add(CMD_OPTION_C);
    }

    commands.add(buildCommand());

    ProcessBuilder pb = new ProcessBuilder(commands);
    pb.directory(workingDirectory);

    LOG.debug("Process builder commands: " + commands);
    return pb;
}
 
源代码2 项目: oodt   文件: TestEnvUtilities.java
/**
 * Tests two environment variables that should exist in any build 
 * environment. USER, HOME
 * By getting the environment (EnvUtilities.getEnv()) and reading from this.
 */
public void testGetEnvironment() {
    //Test if an only if HOME and USER is defined (Assumed to be true on unix)
    if (SystemUtils.IS_OS_UNIX) {
        //Makes the assumption that System.properties() is correct.
        String userHomeTruth = System.getProperty("user.home");
        String userNameTruth = System.getProperty("user.name");
        Properties env = EnvUtilities.getEnv();
        //Test values
        String userHomeTest = env.getProperty("HOME");
        String userNameTest = env.getProperty("USER");
        //Check all three tests
        assertEquals(userHomeTruth,userHomeTest);
        assertEquals(userNameTruth,userNameTest);
    } 
}
 
源代码3 项目: hadoop   文件: StringUtils.java
static void startupShutdownMessage(Class<?> clazz, String[] args,
                                   final LogAdapter LOG) { 
  final String hostname = NetUtils.getHostname();
  final String classname = clazz.getSimpleName();
  LOG.info(
      toStartupShutdownString("STARTUP_MSG: ", new String[] {
          "Starting " + classname,
          "  host = " + hostname,
          "  args = " + Arrays.asList(args),
          "  version = " + VersionInfo.getVersion(),
          "  classpath = " + System.getProperty("java.class.path"),
          "  build = " + VersionInfo.getUrl() + " -r "
                       + VersionInfo.getRevision()  
                       + "; compiled by '" + VersionInfo.getUser()
                       + "' on " + VersionInfo.getDate(),
          "  java = " + System.getProperty("java.version") }
      )
    );

  if (SystemUtils.IS_OS_UNIX) {
    try {
      SignalLogger.INSTANCE.register(LOG);
    } catch (Throwable t) {
      LOG.warn("failed to register any UNIX signal loggers: ", t);
    }
  }
  ShutdownHookManager.get().addShutdownHook(
    new Runnable() {
      @Override
      public void run() {
        LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ", new String[]{
          "Shutting down " + classname + " at " + hostname}));
      }
    }, SHUTDOWN_HOOK_PRIORITY);

}
 
源代码4 项目: hadoop   文件: SharedFileDescriptorFactory.java
public static String getLoadingFailureReason() {
  if (!NativeIO.isAvailable()) {
    return "NativeIO is not available.";
  }
  if (!SystemUtils.IS_OS_UNIX) {
    return "The OS is not UNIX.";
  }
  return null;
}
 
源代码5 项目: big-c   文件: StringUtils.java
static void startupShutdownMessage(Class<?> clazz, String[] args,
                                   final LogAdapter LOG) { 
  final String hostname = NetUtils.getHostname();
  final String classname = clazz.getSimpleName();
  LOG.info(
      toStartupShutdownString("STARTUP_MSG: ", new String[] {
          "Starting " + classname,
          "  host = " + hostname,
          "  args = " + Arrays.asList(args),
          "  version = " + VersionInfo.getVersion(),
          "  classpath = " + System.getProperty("java.class.path"),
          "  build = " + VersionInfo.getUrl() + " -r "
                       + VersionInfo.getRevision()  
                       + "; compiled by '" + VersionInfo.getUser()
                       + "' on " + VersionInfo.getDate(),
          "  java = " + System.getProperty("java.version") }
      )
    );

  if (SystemUtils.IS_OS_UNIX) {
    try {
      SignalLogger.INSTANCE.register(LOG);
    } catch (Throwable t) {
      LOG.warn("failed to register any UNIX signal loggers: ", t);
    }
  }
  ShutdownHookManager.get().addShutdownHook(
    new Runnable() {
      @Override
      public void run() {
        LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ", new String[]{
          "Shutting down " + classname + " at " + hostname}));
      }
    }, SHUTDOWN_HOOK_PRIORITY);

}
 
源代码6 项目: big-c   文件: SharedFileDescriptorFactory.java
public static String getLoadingFailureReason() {
  if (!NativeIO.isAvailable()) {
    return "NativeIO is not available.";
  }
  if (!SystemUtils.IS_OS_UNIX) {
    return "The OS is not UNIX.";
  }
  return null;
}
 
源代码7 项目: citrus-admin   文件: AbstractTerminalCommand.java
@Override
public ProcessBuilder getShell() {
    validateWorkingDirectory(workingDirectory);

    List<String> commands = new ArrayList<>();
    if (SystemUtils.IS_OS_UNIX) {
        commands.add(BASH);
    } else {
        commands.add(CMD);
    }

    ProcessBuilder pb = new ProcessBuilder(commands);
    pb.directory(workingDirectory);
    return pb;
}
 
源代码8 项目: citrus-admin   文件: ProcessLauncherTest.java
private TerminalCommand getSleepCommand(int sleepInSeconds) throws InterruptedException {
    String command;
    if (SystemUtils.IS_OS_UNIX) {
        command = String.format("ping -c %s 127.0.0.1", sleepInSeconds);
    } else {
        command = String.format("ping -n %s 127.0.0.1", sleepInSeconds);
    }
    return new AbstractTerminalCommand(new File(System.getProperty("user.dir"))) { public String buildCommand() { return command; } };
}
 
源代码9 项目: tajo   文件: StringUtils.java
/**
 * Print a log message for starting up and shutting down
 * @param clazz the class of the server
 * @param args arguments
 * @param LOG the target log object
 */
public static void startupShutdownMessage(Class<?> clazz, String[] args,
                                          final org.apache.commons.logging.Log LOG) {
  final String hostname = org.apache.hadoop.net.NetUtils.getHostname();
  final String classname = clazz.getSimpleName();
  LOG.info(
      toStartupShutdownString("STARTUP_MSG: ", new String[] {
          "Starting " + classname,
          "  host = " + hostname,
          "  args = " + Arrays.asList(args),
          "  version = " + org.apache.tajo.util.VersionInfo.getVersion(),
          "  classpath = " + System.getProperty("java.class.path"),
          "  build = " + org.apache.tajo.util.VersionInfo.getUrl() + " -r "
              + org.apache.tajo.util.VersionInfo.getRevision()
              + "; compiled by '" + org.apache.tajo.util.VersionInfo.getUser()
              + "' on " + org.apache.tajo.util.VersionInfo.getDate(),
          "  java = " + System.getProperty("java.version") }
      )
  );

  if (SystemUtils.IS_OS_UNIX) {
    try {
      SignalLogger.INSTANCE.register(LOG);
    } catch (Throwable t) {
      LOG.warn("failed to register any UNIX signal loggers: ", t);
    }
  }
  ShutdownHookManager.get().addShutdownHook(
      new Runnable() {
        @Override
        public void run() {
          LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ", new String[]{
              "Shutting down " + classname + " at " + hostname}));
        }
      }, SHUTDOWN_HOOK_PRIORITY);
}
 
源代码10 项目: oodt   文件: TestEnvUtilities.java
/**
 * Tests two environment variables that should exist in any build 
 * environment. USER, HOME
 * By calling (EnvUtilities.getEnv(String))
 */
public void testSetEnvironmentVar() {
    //Test if an only if HOME and USER is defined (Assumed to be true on unix)
    if (SystemUtils.IS_OS_UNIX) {
        //Makes the assumption that System.properties() is correct.
        String userHomeTruth = System.getProperty("user.home");
        String userNameTruth = System.getProperty("user.name");
        //Test values
        String userHomeTest = EnvUtilities.getEnv("HOME");
        String userNameTest = EnvUtilities.getEnv("USER");
        //Check all three tests
        assertEquals(userHomeTruth,userHomeTest);
        assertEquals(userNameTruth,userNameTest);
    } 
}
 
源代码11 项目: oodt   文件: TestEnvUtilities.java
/**
 * Tests for consistency between the two methods for getting environment variables
 * in EnvUtilities calling getEnv(String) and calling getEnv().getProperty(String).
 */
public void testGetEnvironmentConsistency() {
    //Test if an only if HOME and USER is defined (Assumed to be true on unix)
    if (SystemUtils.IS_OS_UNIX) {
        Properties env = EnvUtilities.getEnv();
        //Test values
        String userHomeTest1 = env.getProperty("HOME");
        String userNameTest1 = env.getProperty("USER");
        String userHomeTest2 = EnvUtilities.getEnv("HOME");
        String userNameTest2 = EnvUtilities.getEnv("USER");
        //Check all three tests
        assertEquals(userHomeTest1,userHomeTest2);
        assertEquals(userNameTest1,userNameTest2);
    }
}
 
源代码12 项目: oodt   文件: TestEnvUtilities.java
public void testStaticEnvironment(){
  if(SystemUtils.IS_OS_UNIX){
    Properties env = EnvUtilities.getEnv();
    Properties env2 = EnvUtilities.getEnv();
    
    assertEquals(env, env2);
  }
}
 
源代码13 项目: ymate-platform-v2   文件: RuntimeUtils.java
/**
 * @return 当前操作系统是否为类Unix系统
 */
public static boolean isUnixOrLinux() {
    return SystemUtils.IS_OS_UNIX;
}