当前位置: 首页>>代码示例>>Java>>正文


Java SystemUtils.IS_OS_UNIX属性代码示例

本文整理汇总了Java中org.apache.commons.lang.SystemUtils.IS_OS_UNIX属性的典型用法代码示例。如果您正苦于以下问题:Java SystemUtils.IS_OS_UNIX属性的具体用法?Java SystemUtils.IS_OS_UNIX怎么用?Java SystemUtils.IS_OS_UNIX使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.lang.SystemUtils的用法示例。


在下文中一共展示了SystemUtils.IS_OS_UNIX属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProcessBuilder

@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;
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:21,代码来源:AbstractTerminalCommand.java

示例2: obtainConfigurationFile

/**
 * Returns the configuration file, possibly considering OS-specific default file locations.
 * 
 * @param fileName the file name
 * @return the related file object
 */
static File obtainConfigurationFile(String fileName) {
    File result = null;
    if (SystemUtils.IS_OS_UNIX) {
        File tmp = new File("/etc/qualiMaster", fileName);
        if (isReadable(tmp)) {
            result = tmp;
        } else {
            tmp = relocate(fileName);
            if (isReadable(tmp)) {
                result = tmp;
            }
        }
    }
    if (null == result) {
        // use local directory instead (interactive mode)
        result = new File(fileName); 
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:25,代码来源:ToolBase.java

示例3: startupShutdownMessage

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,
          "  user = " + System.getProperty("user.name"),
          "  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);

}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:37,代码来源:StringUtils.java

示例4: getLoadingFailureReason

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;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:SharedFileDescriptorFactory.java

示例5: create

static BaseConnection create()
{
    if (SystemUtils.IS_OS_MAC_OSX)
        return new BaseConnectionOsx();

    if (SystemUtils.IS_OS_UNIX)
        return new BaseConnectionUnix();

    if (SystemUtils.IS_OS_WINDOWS)
        return new BaseConnectionWindows();

    throw new IllegalStateException("This OS is not supported");
}
 
开发者ID:PSNRigner,项目名称:discord-rpc-java,代码行数:13,代码来源:BaseConnection.java

示例6: startupShutdownMessage

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);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:StringUtils.java

示例7: getShell

@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;
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:15,代码来源:AbstractTerminalCommand.java

示例8: getSleepCommand

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; } };
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:9,代码来源:ProcessLauncherTest.java

示例9: osShellPath

protected String osShellPath()
{

    if (SystemUtils.IS_OS_UNIX)
    {
        return "/bin/sh";
    }

    throw new IllegalArgumentException("At the moment your system is not supported");
}
 
开发者ID:fbalicchia,项目名称:graylog-plugin-backup-configuration,代码行数:10,代码来源:AbstractMongoBackupStrategy.java

示例10: getDirInAppData

public static @Nullable String getDirInAppData(String dir) {
  if (SystemUtils.IS_OS_WINDOWS) {
    return System.getenv("APPDATA") + "/." + dir;
  } else if (SystemUtils.IS_OS_MAC) {
    return SystemUtils.USER_HOME + "/Library/Application Support/" + dir;
  } else if (SystemUtils.IS_OS_UNIX) {
    return SystemUtils.USER_HOME + "/." + dir;
  }
  return null;
}
 
开发者ID:Adrodoc55,项目名称:MPL,代码行数:10,代码来源:CommonDirectories.java

示例11: startupShutdownMessage

/**
 * 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 Log log) {
    final String classname = clazz.getSimpleName();
    final String hostname = NetUtils.getHostname();

    final String build = VersionInfo.getUrl()
            + ", rev. " + VersionInfo.getRevision()
            + "; compiled by '" + VersionInfo.getUser()
            + "' on " + VersionInfo.getDate();
    String[] msg = new String[] {
        "Starting " + classname,
        "  host = " + hostname,
        "  args = " + Arrays.asList(args),
        "  version = " + VersionInfo.getVersion(),
        "  classpath = " + System.getProperty("java.class.path"),
        "  build = " + build,
        "  java = " + System.getProperty("java.version")
    };
    log.info(toStartupShutdownString("STARTUP_MSG: ", msg));

    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);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:43,代码来源:StringUtils.java

示例12: startupShutdownMessage

/**
 * 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 = 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);

}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:42,代码来源:StringUtils.java

示例13: configureLogging

/**
 * Configures logging from a given file.
 * 
 * @param file the file to be used for logging
 * @param reset whether the logging context shall be reset (may be relevant for single-step configurations)
 */
public static void configureLogging(File file, boolean reset) {
    File logDir = new File(System.getProperty("java.io.tmpdir"));
    if (SystemUtils.IS_OS_UNIX) {
        File tmp = new File("/var/log");
        if (isAccessibleDir(tmp)) {
            logDir = tmp;
        }
    }
    System.setProperty("qm.log.dir", logDir.getAbsolutePath());

    if (file.exists() && file.canRead()) {
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        try {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            // Call context.reset() to clear any previous configuration, e.g. default 
            // configuration. For multi-step configuration, omit calling context.reset().
            if (reset) {
                context.reset();
            }
            context.reset(); 
            configurator.doConfigure(file);
        } catch (JoranException je) {
            // StatusPrinter will handle this
        }
        StatusPrinter.printInCaseOfErrorsOrWarnings(context);
    } // ignore and use default configuration
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:34,代码来源:ToolBase.java

示例14: isUnixOrLinux

/**
 * @return 当前操作系统是否为类Unix系统
 */
public static boolean isUnixOrLinux() {
    return SystemUtils.IS_OS_UNIX;
}
 
开发者ID:suninformation,项目名称:ymate-platform-v2,代码行数:6,代码来源:RuntimeUtils.java

示例15: updateDeviceState

/**
 * Try's to reach the Device by Ping
 */
private static boolean updateDeviceState(String hostname, int port, int timeout, boolean useSystemPing) throws InvalidConfigurationException {
	boolean success = false;
	
	try {
		if( !useSystemPing ) {
			success = Ping.checkVitality(hostname, port, timeout);				
		} else {
			Process proc;
			if( SystemUtils.IS_OS_UNIX ) {
				proc = new ProcessBuilder("ping", "-t", String.valueOf((int)(timeout / 1000)), "-c", "1", hostname).start();
			} else if( SystemUtils.IS_OS_WINDOWS) {
				proc = new ProcessBuilder("ping", "-w", String.valueOf(timeout), "-n", "1", hostname).start();
			} else {
				logger.error("The System Ping is not supported on this Operating System");
				throw new InvalidConfigurationException("System Ping not supported");
			}
			
			int exitValue = proc.waitFor();
			success = exitValue == 0;
			if( exitValue != 2 && exitValue != 0 ) {
				logger.debug("Ping stopped with Error Number: " + exitValue + 
						" on Command :" + "ping" + 
						(SystemUtils.IS_OS_UNIX ? " -t " : " -w ") + 
						String.valueOf(timeout) + 
						(SystemUtils.IS_OS_UNIX ? " -c" : " -n") + 
						" 1 " + hostname);
				return false;
			}
		}
		
		logger.debug("established connection [host '{}' port '{}' timeout '{}']", new Object[] {hostname, port, timeout});
	} 
	catch (SocketTimeoutException se) {
		logger.debug("timed out while connecting to host '{}' port '{}' timeout '{}'", new Object[] {hostname, port, timeout});
	}
	catch (IOException ioe) {
		logger.debug("couldn't establish network connection [host '{}' port '{}' timeout '{}']", new Object[] {hostname, port, timeout});
	} catch (InterruptedException e) {
		logger.debug("ping program was interrupted");
	}
	
	return success ? true : false;
	
}
 
开发者ID:Neulinet,项目名称:Zoo,代码行数:47,代码来源:NetworkService.java


注:本文中的org.apache.commons.lang.SystemUtils.IS_OS_UNIX属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。