com.sun.enterprise.util.OS.isWindows()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中com.sun.enterprise.util.OS.isWindows()方法的一些代码示例,展示了OS.isWindows()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OS.isWindows()方法的具体详情如下:
包路径:com.sun.enterprise.util.OS
类名称:OS
方法名:isWindows

OS.isWindows介绍

暂无

代码示例

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

protected static boolean isWindows()
{
return OS.isWindows();
}

代码示例来源:origin: org.glassfish.common/common-util

/**
   * @param args the command line arguments
   */
  public static void main(String args[])
  {
    System.out.println("os.version = "                  + System.getProperty("os.version"));
    System.out.println("os.name = "                     + System.getProperty("os.name"));
    System.out.println("os.arch = "                     + System.getProperty("os.arch"));
    System.out.println("isUNIX() returned: "            + isUNIX());
    System.out.println("isWindows() returned: "         + isWindows());
    System.out.println("isWindowsForSure() returned: "  + isWindowsForSure());
    System.out.println("isSun() returned: "             + isSun());
    System.out.println("isLinux() returned: "           + isLinux());
    System.out.println("isDebianLinux() returned: "     + isDebianLinux());
    System.out.println("isFedoraLinux() returned: "     + isFedoraLinux());
    System.out.println("isGentooLinux() returned: "     + isGentooLinux());
    System.out.println("isKnoppixLinux() returned: "    + isKnoppixLinux());
    System.out.println("isMandrakeLinux() returned: "   + isMandrakeLinux());
    System.out.println("isMandrivaLinux() returned: "   + isMandrivaLinux());
    System.out.println("isRedHatLinux() returned: "     + isRedHatLinux());
    System.out.println("isSlackwareLinux() returned: "  + isSlackwareLinux());
    System.out.println("isSuSELinux() returned: "       + isSuSELinux());
    System.out.println("isUbuntuLinux() returned: "     + isUbuntuLinux());
    System.out.println("isSunX86() returned: "          + isSunX86());
    System.out.println("isSunSparc() returned: "        + isSunSparc());
    System.out.println("isDarwin() returned: "          + isDarwin());
    System.out.println("isSolaris10() returned: "       + isSolaris10());
    System.out.println("isAix() returned: "             + isAix());
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

public static final String getAdminScriptLocation(String installRoot) {
  final StringBuilder sb = new StringBuilder();
  final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : "";
  final String ASADMIN = "nadmin";
  final String suffix = new StringBuilder("lib").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString();
  sb.append(installRoot);
  final String fs = System.getProperty("file.separator");
  if (!sb.toString().endsWith(fs))
    sb.append(fs);
  sb.append(suffix);
  return ( sb.toString() );
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
   * @param args the command line arguments
   */
  public static void main(String args[])
  {
    System.out.println("os.version = "                  + System.getProperty("os.version"));
    System.out.println("os.name = "                     + System.getProperty("os.name"));
    System.out.println("os.arch = "                     + System.getProperty("os.arch"));
    System.out.println("isUNIX() returned: "            + isUNIX());
    System.out.println("isWindows() returned: "         + isWindows());
    System.out.println("isWindowsForSure() returned: "  + isWindowsForSure());
    System.out.println("isSun() returned: "             + isSun());
    System.out.println("isLinux() returned: "           + isLinux());
    System.out.println("isDebianLinux() returned: "     + isDebianLinux());
    System.out.println("isFedoraLinux() returned: "     + isFedoraLinux());
    System.out.println("isGentooLinux() returned: "     + isGentooLinux());
    System.out.println("isKnoppixLinux() returned: "    + isKnoppixLinux());
    System.out.println("isMandrakeLinux() returned: "   + isMandrakeLinux());
    System.out.println("isMandrivaLinux() returned: "   + isMandrivaLinux());
    System.out.println("isRedHatLinux() returned: "     + isRedHatLinux());
    System.out.println("isSlackwareLinux() returned: "  + isSlackwareLinux());
    System.out.println("isSuSELinux() returned: "       + isSuSELinux());
    System.out.println("isUbuntuLinux() returned: "     + isUbuntuLinux());
    System.out.println("isSunX86() returned: "          + isSunX86());
    System.out.println("isSunSparc() returned: "        + isSunSparc());
    System.out.println("isDarwin() returned: "          + isDarwin());
    System.out.println("isSolaris10() returned: "       + isSolaris10());
    System.out.println("isAix() returned: "             + isAix());
  }
}

代码示例来源:origin: org.glassfish.main.common/common-util

public static final String getAdminScriptLocation(String installRoot) {
  final StringBuilder sb = new StringBuilder();
  final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : "";
  final String ASADMIN = "nadmin";
  final String suffix = new StringBuilder("lib").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString();
  sb.append(installRoot);
  final String fs = System.getProperty("file.separator");
  if (!sb.toString().endsWith(fs))
    sb.append(fs);
  sb.append(suffix);
  return ( sb.toString() );
}

代码示例来源:origin: org.glassfish.common/common-util

public static final String getAsAdminScriptLocation(String installRoot) {
  final StringBuilder sb = new StringBuilder();
  final String ext = OS.isWindows() ? OS.WINDOWS_BATCH_FILE_EXTENSION : "";
  final String ASADMIN = "asadmin";
  final String suffix = new StringBuilder("bin").append(System.getProperty("file.separator")).append(ASADMIN).append(ext).toString();
  sb.append(installRoot);
  final String fs = System.getProperty("file.separator");
  if (!sb.toString().endsWith(fs))
    sb.append(fs);
  sb.append(suffix);
  return ( sb.toString() );
}

代码示例来源:origin: org.glassfish.main.common/common-util

public static boolean isWindowsForSure()
{
  return isName("windows") && isWindows();
}
///////////////////////////////////////////////////////////////////////////

代码示例来源:origin: org.glassfish.common/common-util

public static boolean isWindowsForSure()
{
  return isName("windows") && isWindows();
}
///////////////////////////////////////////////////////////////////////////

代码示例来源:origin: eclipse-ee4j/glassfish

public static boolean isWindowsForSure()
{
  return isName("windows") && isWindows();
}
///////////////////////////////////////////////////////////////////////////

代码示例来源:origin: org.glassfish.main.admin/server-mgmt

/**
   * Determines if the NSS support is available in this installation. The
   * check involves availability of the
   * <code> certutil </code> executable.
   *
   * @return true if certutil exists false otherwise
   */
  public static boolean isNSSSupportAvailable() {
    File certUtilFile = null;
    if (OS.isWindows()) {
      certUtilFile = new File(CERTUTIL_CMD + ".exe");
    }
    else {
      certUtilFile = new File(CERTUTIL_CMD);
    }
    if (certUtilFile.exists()) {
      return (true);
    }
    return (false);
  }
}

代码示例来源:origin: org.glassfish.common/common-util

/**
 * Given a string (typically a path), quote the string such that spaces
 * are protected from interpretation by a Unix or Windows command shell.
 * Note that this method does not handle quoting for all styles of special
 * characters. Just for the basic case of strings with spaces.
 *
 * @param s input string
 * @return a String which is quoted to protect spaces
 */
public static String quoteString(String s) {
  if (s == null) {
    throw new IllegalArgumentException("null string");
  }
  if (!s.contains("\'")) {
    return("\'" + s + "\'");
  } else if(!s.contains("\"")) {
    return("\"" + s + "\"");
  } else {
    // Contains a single quote and a double quote. Use backslash
    // On Unix. Double quotes on Windows. This method does not claim
    // to support this case well if at all
    if (OS.isWindows()) {
      return("\"" + s + "\"");
    } else {
      return(s.replaceAll("\040", "\134 "));
    }
  }
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
 * Given a string (typically a path), quote the string such that spaces
 * are protected from interpretation by a Unix or Windows command shell.
 * Note that this method does not handle quoting for all styles of special
 * characters. Just for the basic case of strings with spaces.
 *
 * @param s input string
 * @return a String which is quoted to protect spaces
 */
public static String quoteString(String s) {
  if (s == null) {
    throw new IllegalArgumentException("null string");
  }
  if (!s.contains("\'")) {
    return("\'" + s + "\'");
  } else if(!s.contains("\"")) {
    return("\"" + s + "\"");
  } else {
    // Contains a single quote and a double quote. Use backslash
    // On Unix. Double quotes on Windows. This method does not claim
    // to support this case well if at all
    if (OS.isWindows()) {
      return("\"" + s + "\"");
    } else {
      return(s.replaceAll("\040", "\134 "));
    }
  }
}

代码示例来源:origin: eclipse-ee4j/glassfish

/**
 * Given a string (typically a path), quote the string such that spaces
 * are protected from interpretation by a Unix or Windows command shell.
 * Note that this method does not handle quoting for all styles of special
 * characters. Just for the basic case of strings with spaces.
 *
 * @param s input string
 * @return a String which is quoted to protect spaces
 */
public static String quoteString(String s) {
  if (s == null) {
    throw new IllegalArgumentException("null string");
  }
  if (!s.contains("\'")) {
    return("\'" + s + "\'");
  } else if(!s.contains("\"")) {
    return("\"" + s + "\"");
  } else {
    // Contains a single quote and a double quote. Use backslash
    // On Unix. Double quotes on Windows. This method does not claim
    // to support this case well if at all
    if (OS.isWindows()) {
      return("\"" + s + "\"");
    } else {
      return(s.replaceAll("\040", "\134 "));
    }
  }
}

代码示例来源:origin: org.glassfish.main.common/common-util

public static boolean safeIsRealDirectory(File f) {
  if (safeIsDirectory(f) == false)
    return false;
  // these 2 values while be different for symbolic links
  String canonical = safeGetCanonicalPath(f);
  String absolute = f.getAbsolutePath();
  if (canonical.equals(absolute))
    return true;
  /* Bug 4715043 -- WHOA -- Bug Obscura!!
    * In Windows, if you create the File object with, say, "d:/foo", then the
    * absolute path will be "d:\foo" and the canonical path will be "D:\foo"
    * and they won't match!!!
    **/
  if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
    return true;
  return false;
}

代码示例来源:origin: org.glassfish.common/common-util

public static boolean safeIsRealDirectory(File f) {
  if (safeIsDirectory(f) == false)
    return false;
  // these 2 values while be different for symbolic links
  String canonical = safeGetCanonicalPath(f);
  String absolute = f.getAbsolutePath();
  if (canonical.equals(absolute))
    return true;
  /* Bug 4715043 -- WHOA -- Bug Obscura!!
    * In Windows, if you create the File object with, say, "d:/foo", then the
    * absolute path will be "d:\foo" and the canonical path will be "D:\foo"
    * and they won't match!!!
    **/
  if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
    return true;
  return false;
}

代码示例来源:origin: eclipse-ee4j/glassfish

public static boolean safeIsRealDirectory(File f) {
  if (safeIsDirectory(f) == false)
    return false;
  // these 2 values while be different for symbolic links
  String canonical = safeGetCanonicalPath(f);
  String absolute = f.getAbsolutePath();
  if (canonical.equals(absolute))
    return true;
  /* Bug 4715043 -- WHOA -- Bug Obscura!!
    * In Windows, if you create the File object with, say, "d:/foo", then the
    * absolute path will be "d:\foo" and the canonical path will be "D:\foo"
    * and they won't match!!!
    **/
  if (OS.isWindows() && canonical.equalsIgnoreCase(absolute))
    return true;
  return false;
}

代码示例来源:origin: org.glassfish.main.cluster/cluster-admin

if (OS.isWindows()) {
  validateString(propname, value, configValue, true);
} else {

代码示例来源:origin: org.glassfish.common/common-util

/**
 * Executes the supplied work object until the work is done or the max.
 * retry count is reached.
 *
 * @param work the RetriableWork implementation to be run
 * @return the number of retries performed; 0 indicates the work succeeded without having to retry
 */
private static int doWithRetry(RetriableWork work) {
  int retries = 0;
  /*
  *Try the work the first time.  Ideally this will work.
  */
  work.run();
  /*
  *If the work failed and this is Windows - on which running gc may
  *unlock the locked file - then begin the retries.
  */
  if (!work.workComplete() && OS.isWindows()) {
    _utillogger.log(FILE_OPERATION_LOG_LEVEL, "enterprise_util.perform_gc");
    while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) {
      try {
        Thread.currentThread().sleep(FILE_OPERATION_SLEEP_DELAY_MS);
      } catch (InterruptedException ex) {
      }
      System.gc();
      work.run();
    }
  }
  return retries;
}

代码示例来源:origin: eclipse-ee4j/glassfish

/**
 * Executes the supplied work object until the work is done or the max.
 * retry count is reached.
 *
 * @param work the RetriableWork implementation to be run
 * @return the number of retries performed; 0 indicates the work succeeded without having to retry
 */
private static int doWithRetry(RetriableWork work) {
  int retries = 0;
  /*
  *Try the work the first time.  Ideally this will work.
  */
  work.run();
  /*
  *If the work failed and this is Windows - on which running gc may
  *unlock the locked file - then begin the retries.
  */
  if (!work.workComplete() && OS.isWindows()) {
    _utillogger.log(FILE_OPERATION_LOG_LEVEL, CULoggerInfo.performGC);
    while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) {
      try {
        Thread.sleep(FILE_OPERATION_SLEEP_DELAY_MS);
      } catch (InterruptedException ex) {
      }
      System.gc();
      work.run();
    }
  }
  return retries;
}

代码示例来源:origin: org.glassfish.main.common/common-util

/**
 * Executes the supplied work object until the work is done or the max.
 * retry count is reached.
 *
 * @param work the RetriableWork implementation to be run
 * @return the number of retries performed; 0 indicates the work succeeded without having to retry
 */
private static int doWithRetry(RetriableWork work) {
  int retries = 0;
  /*
  *Try the work the first time.  Ideally this will work.
  */
  work.run();
  /*
  *If the work failed and this is Windows - on which running gc may
  *unlock the locked file - then begin the retries.
  */
  if (!work.workComplete() && OS.isWindows()) {
    _utillogger.log(FILE_OPERATION_LOG_LEVEL, CULoggerInfo.performGC);
    while (!work.workComplete() && retries++ < FILE_OPERATION_MAX_RETRIES) {
      try {
        Thread.sleep(FILE_OPERATION_SLEEP_DELAY_MS);
      } catch (InterruptedException ex) {
      }
      System.gc();
      work.run();
    }
  }
  return retries;
}

相关文章