當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。