Java 类com.google.common.base.StandardSystemProperty 实例源码

项目:jabref    文件:Globals.java   
private static void startTelemetryClient() {
    TelemetryConfiguration telemetryConfiguration = TelemetryConfiguration.getActive();
    telemetryConfiguration.setInstrumentationKey(Globals.BUILD_INFO.getAzureInstrumentationKey());
    telemetryConfiguration.setTrackingIsDisabled(!Globals.prefs.shouldCollectTelemetry());
    telemetryClient = new TelemetryClient(telemetryConfiguration);
    telemetryClient.getContext().getProperties().put("JabRef version", Globals.BUILD_INFO.getVersion().toString());
    telemetryClient.getContext().getProperties().put("Java version", StandardSystemProperty.JAVA_VERSION.value());
    telemetryClient.getContext().getUser().setId(Globals.prefs.getOrCreateUserId());
    telemetryClient.getContext().getSession().setId(UUID.randomUUID().toString());
    telemetryClient.getContext().getDevice().setOperatingSystem(StandardSystemProperty.OS_NAME.value());
    telemetryClient.getContext().getDevice().setOperatingSystemVersion(StandardSystemProperty.OS_VERSION.value());
    telemetryClient.getContext().getDevice().setScreenResolution(
            Toolkit.getDefaultToolkit().getScreenSize().toString());

    telemetryClient.trackSessionState(SessionState.Start);
}
项目:Reer    文件:DefaultTaskExecutionPlan.java   
private boolean pathsOverlap(String firstPath, String secondPath) {
    if (firstPath.equals(secondPath)) {
        return true;
    }

    String shorter;
    String longer;
    if (firstPath.length() > secondPath.length()) {
        shorter = secondPath;
        longer = firstPath;
    } else {
        shorter = firstPath;
        longer = secondPath;
    }
    return longer.startsWith(shorter + StandardSystemProperty.FILE_SEPARATOR.value());
}
项目:n4js    文件:SshSessionFactory.java   
private JSch configureIdentity(final JSch jsch) throws JSchException {

        final File sshDirectory = new File(StandardSystemProperty.USER_HOME.value() + "/.ssh");
        checkState(sshDirectory.exists(), ".ssh directory does not exist under home folder.");
        checkState(sshDirectory.canRead(), ".ssh directory content cannot be read.");
        checkState(sshDirectory.isDirectory(), sshDirectory.getAbsoluteFile() + " is not a directory.");
        final File[] keyFiles = sshDirectory.listFiles();
        checkState(null != keyFiles && keyFiles.length > 0, "No SSH key files exist.");

        jsch.removeAllIdentity();
        for (final File keyFile : keyFiles) {
            if (keyFile.isFile()) {
                final String keyUri = keyFile.toURI().toString();
                final int lastIndexOf = keyUri.lastIndexOf("/");
                if (lastIndexOf > 0) {
                    final String keyFileName = keyUri.substring(lastIndexOf + 1);
                    if ("id_rsa".equals(keyFileName) || "id_dsa".equals(keyFileName)) {
                        if (isEncrypted(keyFile)) {
                            String pw = getPassphrase(keyFile);
                            jsch.addIdentity(keyFile.getAbsolutePath(), pw);
                        } else {
                            jsch.addIdentity(keyFile.getAbsolutePath());
                        }

                        break;
                    }
                }
            }
        }

        return jsch;
    }
项目:nebo    文件:NettyEmbeddedServletContainer.java   
private void groups(ServerBootstrap b) {
    if (StandardSystemProperty.OS_NAME.value().equals("Linux")) {
        bossGroup = new EpollEventLoopGroup(1);
        workerGroup = new EpollEventLoopGroup();
        b.channel(EpollServerSocketChannel.class)
                .group(bossGroup, workerGroup)
                .option(EpollChannelOption.TCP_CORK, true);
    } else {
        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();
        b.channel(NioServerSocketChannel.class)
                .group(bossGroup, workerGroup);
    }
    b.option(ChannelOption.TCP_NODELAY, true)
            .option(ChannelOption.SO_REUSEADDR, true)
            .option(ChannelOption.SO_BACKLOG, 100);
    logger.info("Bootstrap configuration: " + b.toString());
}
项目:bdio    文件:ConcatenateTool.java   
@Override
protected void execute() throws Exception {
    checkState(!inputs.isEmpty(), "input is not set");

    RxJavaBdioDocument document = new RxJavaBdioDocument(new BdioOptions.Builder().build());
    StreamSupplier out = new BdioWriter.BdioFile(output.openStream());

    BdioMetadata metadata = new BdioMetadata();
    metadata.id(id.orElseGet(BdioObject::randomId));
    metadata.publisher(ProductList.of(getProduct()));
    metadata.creationDateTime(ZonedDateTime.now());
    metadata.creator(StandardSystemProperty.USER_NAME.value());

    // Read all the configured inputs into a single sequence of entries
    Flowable<InputStream> data = Flowable.fromIterable(inputs).map(ByteSource::openStream);

    // Only collect limited entries for metadata if possible
    document.metadata(data.flatMap(in -> document.read(in).takeUntil((Predicate<Object>) ConcatenateTool::needsMoreMetadata)))
            .subscribe(m -> combineMetadata(metadata, m))
            .isDisposed();

    // Write the all the entries back out using the new metadata
    data.flatMap(document::read).subscribe(document.write(metadata, out));
}
项目:copybara    文件:Workflow.java   
private String computeIdentity(String type, String ref) {
  ToStringHelper helper = MoreObjects.toStringHelper(type)
      .add("type", "workflow")
      .add("config_path", mainConfigFile.relativeToRoot())
      .add("workflow_name", this.name)
      .add("context_ref", ref);
  helper.add("user", workflowOptions.workflowIdentityUser != null
      ? workflowOptions.workflowIdentityUser
      : StandardSystemProperty.USER_NAME.value());
  String identity = helper.toString();
  String hash = BaseEncoding.base16().encode(
      Hashing.md5()
                  .hashString(identity, StandardCharsets.UTF_8)
                  .asBytes());

  // Important to log the source of the hash and the hash for debugging purposes.
  logger.info("Computed migration identity hash for " + identity + " as " + hash);
  return hash;
}
项目:copybara    文件:Main.java   
/**
 * Returns the base directory to be used by Copybara to write execution related files (Like
 * logs).
 */
private String getBaseExecDir() {
  // In this case we are not using GeneralOptions.getEnvironment() because we still haven't built
  // the options, but it's fine. This is the tool's Main and is also injecting System.getEnv()
  // to the options, so the value is the same.
  String userHome = StandardSystemProperty.USER_HOME.value();

  switch (StandardSystemProperty.OS_NAME.value()) {
    case "Linux":
      String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
      return Strings.isNullOrEmpty(xdgCacheHome)
          ? userHome + "/.cache/" + COPYBARA_NAMESPACE
          : xdgCacheHome + COPYBARA_NAMESPACE;
    case "Mac OS X":
      return userHome + "/Library/Logs/" + COPYBARA_NAMESPACE;
    default:
      return "/var/tmp/" + COPYBARA_NAMESPACE;
  }
}
项目:xtext-core    文件:URIBasedFileSystemAccessTest.java   
@Before
public void before() {
  try {
    final Path tmpPath = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("tempFolder_");
    UUID _randomUUID = UUID.randomUUID();
    _builder.append(_randomUUID);
    final Path output = Files.createTempDirectory(tmpPath, _builder.toString());
    final Path resource = Files.createFile(output.resolve(URIBasedFileSystemAccessTest.EXISTING_RESOURCE_NAME));
    resource.toFile().deleteOnExit();
    output.toFile().deleteOnExit();
    final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configProvider.getOutputConfigurations());
    config.setOutputDirectory(output.toString());
    Pair<String, OutputConfiguration> _mappedTo = Pair.<String, OutputConfiguration>of(IFileSystemAccess.DEFAULT_OUTPUT, config);
    this.fsa.setOutputConfigurations(Collections.<String, OutputConfiguration>unmodifiableMap(CollectionLiterals.<String, OutputConfiguration>newHashMap(_mappedTo)));
    this.fsa.setConverter(this.uriConverter);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:jackrabbit-dynamodb-store    文件:MongoVersionGCSupport.java   
private void logSplitDocIdsTobeDeleted(DBObject query) {
    // Fetch only the id
    final BasicDBObject keys = new BasicDBObject(Document.ID, 1);
    List<String> ids;
    DBCursor cursor = getNodeCollection().find(query, keys)
            .setReadPreference(store.getConfiguredReadPreference(Collection.NODES));
    try {
         ids = ImmutableList.copyOf(Iterables.transform(cursor, new Function<DBObject, String>() {
             @Override
             public String apply(@Nullable DBObject input) {
                 return (String) input.get(Document.ID);
             }
         }));
    } finally {
        cursor.close();
    }
    StringBuilder sb = new StringBuilder("Split documents with following ids were deleted as part of GC \n");
    Joiner.on(StandardSystemProperty.LINE_SEPARATOR.value()).appendTo(sb, ids);
    log.debug(sb.toString());
}
项目:spring-boot-starter-netty    文件:NettyEmbeddedServletContainer.java   
private void groups(ServerBootstrap b) {
    if (StandardSystemProperty.OS_NAME.value().equals("Linux")) {
        bossGroup = new EpollEventLoopGroup(1);
        workerGroup = new EpollEventLoopGroup();
        b.channel(EpollServerSocketChannel.class)
                .group(bossGroup, workerGroup)
                .option(EpollChannelOption.TCP_CORK, true);
    } else {
        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();
        b.channel(NioServerSocketChannel.class)
                .group(bossGroup, workerGroup);
    }
    b.option(ChannelOption.TCP_NODELAY, true)
            .option(ChannelOption.SO_REUSEADDR, true)
            .option(ChannelOption.SO_BACKLOG, 100);
    logger.info("Bootstrap configuration: " + b.toString());
}
项目:kurento-java    文件:KurentoClient.java   
public static synchronized String getKmsUrl(String id, Properties properties) {

    if (properties == null) {
      properties = new Properties();
    }

    if (kmsUrlLoader == null) {

      Path configFile =
          Paths.get(StandardSystemProperty.USER_HOME.value(), ".kurento", "config.properties");

      kmsUrlLoader = new KmsUrlLoader(configFile);
    }

    Object load = properties.get("loadPoints");
    if (load == null) {
      return kmsUrlLoader.getKmsUrl(id);
    } else {
      if (load instanceof Number) {
        return kmsUrlLoader.getKmsUrlLoad(id, ((Number) load).intValue());
      } else {
        return kmsUrlLoader.getKmsUrlLoad(id, Integer.parseInt(load.toString()));
      }
    }
  }
项目:glowroot    文件:TempDirs.java   
public static File createTempDir(String prefix) throws IOException {
    final int tempDirAttempts = 10000;
    String javaTempDir =
            MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
    File baseDir = new File(javaTempDir);
    String baseName = prefix + "-" + System.currentTimeMillis() + "-";
    for (int counter = 0; counter < tempDirAttempts; counter++) {
        File tempDir = new File(baseDir, baseName + counter);
        if (tempDir.mkdir()) {
            return tempDir;
        }
    }
    throw new IOException(
            "Failed to create directory within " + tempDirAttempts + " attempts (tried "
                    + baseName + "0 to " + baseName + (tempDirAttempts - 1) + ')');
}
项目:glowroot    文件:MainEntryPoint.java   
static void runViewer(Directories directories) throws InterruptedException {
    // initLogging() already called by OfflineViewer.main()
    checkNotNull(startupLogger);
    String version;
    try {
        version = Version.getVersion(MainEntryPoint.class);
        startupLogger.info("Glowroot version: {}", version);
        startupLogger.info("Java version: {}", StandardSystemProperty.JAVA_VERSION.value());
        ImmutableMap<String, String> properties =
                getGlowrootProperties(directories.getConfDir(), directories.getSharedConfDir());
        new EmbeddedGlowrootAgentInit(directories.getDataDir(), true)
                .init(directories.getPluginsDir(), directories.getConfDir(),
                        directories.getSharedConfDir(), directories.getLogDir(),
                        directories.getTmpDir(), directories.getGlowrootJarFile(), properties,
                        null, version);
    } catch (AgentDirsLockedException e) {
        logAgentDirsLockedException(directories.getConfDir(), e.getLockFile());
        return;
    } catch (Throwable t) {
        startupLogger.error("Glowroot cannot start: {}", t.getMessage(), t);
        return;
    }
    // Glowroot does not create any non-daemon threads, so need to block jvm from exiting when
    // running the viewer
    Thread.sleep(Long.MAX_VALUE);
}
项目:glowroot    文件:MainEntryPoint.java   
@RequiresNonNull("startupLogger")
private static void start(Directories directories, Map<String, String> properties,
        @Nullable Instrumentation instrumentation) throws Exception {
    ManagementFactory.getThreadMXBean().setThreadCpuTimeEnabled(true);
    ManagementFactory.getThreadMXBean().setThreadContentionMonitoringEnabled(true);
    String version = Version.getVersion(MainEntryPoint.class);
    startupLogger.info("Glowroot version: {}", version);
    startupLogger.info("Java version: {}", StandardSystemProperty.JAVA_VERSION.value());
    String collectorAddress = properties.get("glowroot.collector.address");
    Collector customCollector = loadCustomCollector(directories.getGlowrootDir());
    if (Strings.isNullOrEmpty(collectorAddress) && customCollector == null) {
        glowrootAgentInit = new EmbeddedGlowrootAgentInit(directories.getDataDir(), false);
    } else {
        if (customCollector != null) {
            startupLogger.info("using collector: {}", customCollector.getClass().getName());
        }
        String collectorAuthority = properties.get("glowroot.collector.authority");
        glowrootAgentInit = new NonEmbeddedGlowrootAgentInit(collectorAddress,
                collectorAuthority, customCollector);
    }
    glowrootAgentInit.init(directories.getPluginsDir(), directories.getConfDir(),
            directories.getSharedConfDir(), directories.getLogDir(), directories.getTmpDir(),
            directories.getGlowrootJarFile(), properties, instrumentation, version);
}
项目:glowroot    文件:EnvironmentCreator.java   
private static JavaInfo createJavaInfo(String glowrootVersion, JvmConfig jvmConfig,
        RuntimeMXBean runtimeMXBean) {
    String jvm = "";
    String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value();
    if (javaVmName != null) {
        jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", "
                + System.getProperty("java.vm.info") + ")";
    }
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    String heapDumpPath = getHeapDumpPathFromCommandLine();
    if (heapDumpPath == null) {
        String javaTempDir =
                MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
        heapDumpPath = new File(javaTempDir).getAbsolutePath();
    }
    return JavaInfo.newBuilder()
            .setVersion(Strings.nullToEmpty(javaVersion))
            .setVm(jvm)
            .addAllArg(SystemProperties.maskJvmArgs(runtimeMXBean.getInputArguments(),
                    jvmConfig.maskSystemProperties()))
            .setHeapDumpDefaultDir(heapDumpPath)
            .setGlowrootAgentVersion(glowrootVersion)
            .build();
}
项目:glowroot    文件:JvmTool.java   
private static List<String> buildClasspath(@Nullable File glowrootJarFile) {
    if (glowrootJarFile == null || !isShaded()) {
        // this is just to support testing
        List<String> classpath = Lists.newArrayList();
        if (glowrootJarFile != null) {
            classpath.add(glowrootJarFile.getAbsolutePath());
        }
        classpath.addAll(splitClasspath(StandardSystemProperty.JAVA_CLASS_PATH.value()));
        for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
            if (jvmArg.startsWith("-Xbootclasspath/a:")) {
                classpath.addAll(
                        splitClasspath(jvmArg.substring("-Xbootclasspath/a:".length())));
                break;
            }
        }
        return classpath;
    } else {
        return ImmutableList.of(glowrootJarFile.getAbsolutePath());
    }
}
项目:matlab-connector    文件:MatlabServerCLI.java   
public static void main(String[] args) throws IOException {
    MatlabServerCLIOptions options = new MatlabServerCLIOptions()
            .setPort(DEFAULT_PORT)
            .setThreads(DEFAULT_THREADS)
            .setPath(StandardSystemProperty.USER_DIR.value());
    JCommander cli = new JCommander(options);
    cli.setProgramName("java " + MatlabServerCLI.class.getName());
    MatlabServerConfiguration config = null;
    try {
        cli.parse(args);
        config = createConfig(options);
    } catch (ParameterException e) {
        cli.usage();
        printAndExit(e);
    }
    if (options.isHelp()) {
        cli.usage();
    } else {
        try {
            start(config);
        } catch (Exception ex) {
            printAndExit(ex);
        }
    }
}
项目:n4js    文件:ShippedCodeAccess.java   
private static File getTempFolder() {
    final String tempFolder = StandardSystemProperty.JAVA_IO_TMPDIR.value();
    final File file = new File(tempFolder);
    if (!file.exists() || !file.canWrite()) {
        throw new RuntimeException("Cannot access temporary directory under: " + tempFolder);
    }
    return file;
}
项目:grakn    文件:CommonUtil.java   
/**
 * @return The project path. If it is not specified as a JVM parameter it will be set equal to
 * user.dir folder.
 */
public static Path getProjectPath() {
    if (GraknSystemProperty.CURRENT_DIRECTORY.value() == null) {
        GraknSystemProperty.CURRENT_DIRECTORY.set(StandardSystemProperty.USER_DIR.value());
    }
    return Paths.get(GraknSystemProperty.CURRENT_DIRECTORY.value());
}
项目:repositable    文件:Server.java   
public static void main(String[] args) throws IOException {
    String workingDirectory = StandardSystemProperty.USER_DIR.value();
    LOGGER.info("Starting server; Working directory is {}", workingDirectory);
    if (args.length < REQUIRED_ARGUMENTS_COUNT) {
        LOGGER.error("No configuration file provided");
        return;
    }
    ServerConfiguration serverConfiguration = parseConfiguration(args[0]);
    Server server = serverConfiguration.build();
    server.serveBlocking();
}
项目:copybara    文件:OptionsBuilder.java   
public OptionsBuilder setOutputRootToTmpDir() throws IOException {
  general = new GeneralOptions(
      general.getEnvironment(),
      general.getFileSystem(), general.isVerbose(), general.console(),
      general.getConfigRoot(),
      // Using Files.createTempDirectory() generates paths > 255 in some tests and that causes
      // 'File name too long' exceptions in Linux
      FileSystems.getDefault().getPath(StandardSystemProperty.JAVA_IO_TMPDIR.value()),
      general.isNoCleanup(), general.isDisableReversibleCheck(), general.isForced(),
      /*outputLimit*/ 0);
  return this;
}
项目:copybara    文件:FolderDestinationTest.java   
@Before
public void setup() throws IOException, RepoException {
  workdir = Files.createTempDirectory("workdir");
  options = new OptionsBuilder()
      .setWorkdirToRealTempDir()
      .setHomeDir(StandardSystemProperty.USER_HOME.value());
  Files.createDirectory(workdir.resolve("dir"));
  Files.write(workdir.resolve("test.txt"), new byte[]{});
  Files.write(workdir.resolve("dir/file.txt"), new byte[]{});
  excludedPathsForDeletion = ImmutableList.of();
  skylark = new SkylarkTestExecutor(options, FolderModule.class);
}
项目:copybara    文件:FolderOriginTest.java   
@Before
public void setup() throws IOException, RepoException {
  workdir = Files.createTempDirectory("workdir");
  options = new OptionsBuilder()
      .setWorkdirToRealTempDir()
      .setHomeDir(StandardSystemProperty.USER_HOME.value());
  skylark = new SkylarkTestExecutor(options, FolderModule.class);
}
项目:LagMonitor    文件:VmCommand.java   
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!isAllowed(sender, command)) {
        sender.sendMessage(org.bukkit.ChatColor.DARK_RED + "Not whitelisted");
        return true;
    }

    RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();

    //java info
    sender.sendMessage(PRIMARY_COLOR + "Java VM: " + SECONDARY_COLOR + runtimeBean.getVmName());
    sender.sendMessage(PRIMARY_COLOR + "Java Version: " + SECONDARY_COLOR + StandardSystemProperty.JAVA_VERSION.value());
    sender.sendMessage(PRIMARY_COLOR + "Java Vendor: " + SECONDARY_COLOR
            + runtimeBean.getVmVendor() + ' ' + runtimeBean.getVmVersion());

    //vm specification
    sender.sendMessage(PRIMARY_COLOR + "Spec name: " + SECONDARY_COLOR + runtimeBean.getSpecName());
    sender.sendMessage(PRIMARY_COLOR + "Spec Vendor: " + SECONDARY_COLOR + runtimeBean.getSpecVendor());
    sender.sendMessage(PRIMARY_COLOR + "Spec Version: " + SECONDARY_COLOR + runtimeBean.getSpecVersion());

    //class loading
    ClassLoadingMXBean classBean = ManagementFactory.getClassLoadingMXBean();
    sender.sendMessage(PRIMARY_COLOR + "Loaded Classes: " + SECONDARY_COLOR + classBean.getLoadedClassCount());
    sender.sendMessage(PRIMARY_COLOR + "Total Loaded: " + SECONDARY_COLOR + classBean.getTotalLoadedClassCount());
    sender.sendMessage(PRIMARY_COLOR + "Unloaded Classes: " + SECONDARY_COLOR + classBean.getUnloadedClassCount());

    //garbage collector
    List<GarbageCollectorMXBean> gcBean = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean collector : gcBean) {
        sender.sendMessage(PRIMARY_COLOR + "Garbage Collector: " + SECONDARY_COLOR + collector.getName());
        sender.sendMessage(PRIMARY_COLOR + "    Time: " + SECONDARY_COLOR + collector.getCollectionTime());
        sender.sendMessage(PRIMARY_COLOR + "    Count: " + SECONDARY_COLOR + collector.getCollectionCount());
    }

    return true;
}
项目:theta    文件:OsHelper.java   
public static OperatingSystem getOs() {

        final String os = StandardSystemProperty.OS_NAME.value();

        if (os.toLowerCase().startsWith("linux")) {
            return OperatingSystem.LINUX;
        } else if (os.toLowerCase().startsWith("windows")) {
            return OperatingSystem.WINDOWS;
        } else {
            throw new RuntimeException("Operating system \"" + os + "\" not supported.");
        }
    }
项目:capnp-maven-plugin    文件:NativesManager.java   
public NativesInfo getNativesInfoForCurrentPlatform()
{
    Os currentOs = Os.getCurrentOs();
    String currentArch = getCanonicalArchitecture( StandardSystemProperty.OS_ARCH.value() ).toUpperCase();

    return nativesTable.get( currentOs.name(), currentArch );
}
项目:environment-api    文件:Environment.java   
/**
 * The description of the environment.
 *
 * @return a formatted {@link StringBuilder} to describe the
 *         environment instance.
 */
default StringBuilder getDescription() {
  final String newLine = StandardSystemProperty.LINE_SEPARATOR.value();
  final StringBuilder sb = new StringBuilder("");
  sb.append(newLine);
  try (final Formatter f = new Formatter(sb)) {
    final String format = "%1$24s     %2$s" + newLine;
    sb.append(newLine);
    f.format(format, "OS",
        StandardSystemProperty.OS_NAME.value() + " " + StandardSystemProperty.OS_ARCH.value()
            + " " + StandardSystemProperty.OS_VERSION.value());
    f.format(format, "Java Runtime", System.getProperty("java.runtime.name") + " "
        + System.getProperty("java.runtime.version"));
    f.format(format, "Java VM",
        StandardSystemProperty.JAVA_VM_NAME.value() + " "
            + StandardSystemProperty.JAVA_VM_VENDOR.value() + " "
            + StandardSystemProperty.JAVA_VM_VERSION.value());
    f.format(format, "Java Class Ver.", StandardSystemProperty.JAVA_CLASS_VERSION.value());
    f.format(format, "Environment ID", getId());
    f.format(format, "Environment Ver.",
        Environment.class.getPackage().getImplementationVersion());
    f.format(format, "Environment Name", getEnvironmentName());
    f.format(format, "Runtime Mode", RuntimeMode.fromEnvironment(this));
    f.format(format, "Application", getApplicationName());
    f.format(format, "Application Root", getApplicationRoot());
    f.format(format, "Application Logs", getApplicationLogsRoot());
    f.format(format, "Server Host", getServerHost());
    f.format(format, "Server Port", getServerPort());
    sb.append(newLine);
  } catch (Exception e) {
    // Ignore
  }
  return sb;
}
项目:mclab-core    文件:FileEnvironment.java   
/**
 * builds a file environment by reading the information from an options object.
 * Throws an unsupported operations exception if the options are malformed (i.e. 
 * no main file supplied)
 */
public FileEnvironment(Options options,BuiltinQuery query){
    this.query = query;

    //parse main file
    String main = "";
    if (options.main() != null && options.main().length() > 0){
        main = options.main();
    } else {
        List<String> list = options.files();
        if (list != null && list.size() > 0){
            main = list.get(0);
        }
    }
    if (main.length() == 0) throw new UnsupportedOperationException("no main file provided");
    this.main = GenericFile.create(main);
    if (this.main == null || !this.main.exists()){
        throw new UnsupportedOperationException("file "+main+" not found");
    }
    this.pwd = this.main.getParent();
    this.pwdHandler = FolderHandler.getFolderHandler(this.pwd);


    //get path
    @SuppressWarnings("unchecked")
    List<String> paths = (List<String>)options.lp();
    if (paths == null || paths.size() == 0){
         this.natlabPath = MatlabPath.getNatlabPath();
         this.matlabPath = MatlabPath.getMatlabPath();
    } else {
      this.natlabPath = new MatlabPath(paths.stream()
          .collect(Collectors.joining(StandardSystemProperty.PATH_SEPARATOR.value())));
    }
    this.folderHandlers = getFolderHandlers();
}
项目:mclab-core    文件:MatlabPath.java   
/**
 * creates a path environment from the ';'-separated String of directories
 * if the persistent flag is set, the directories will be cached persistently 
 * (i.e. they will be more quickly available during the next VM session)
 */
public MatlabPath(String path,boolean persistent){
    super(null);
    this.persistent = persistent;
    if (path == null || path.length() == 0){
        return;
    }
    //put all directories in
    for (String s : Splitter.on(StandardSystemProperty.PATH_SEPARATOR.value()).split(path)) {
        GenericFile file = GenericFile.create(s);
        DirectoryCache.put(file,persistent);
        directories.add(DirectoryCache.get(file));
    }
}
项目:mclab-core    文件:PrettyPrintTest.java   
public static void testProgFile()
{
    StringBuffer inline = null;
    String basePath = StandardSystemProperty.USER_DIR.value() + "/languages/Natlab/test/";
    //System.out.println(basePath);
    String filename = basePath + "prettyprinttest.in";
    try
    {
        Scanner reader = new Scanner(new File(filename));
        inline = new StringBuffer();
        while ( reader.hasNext() )
            inline.append(reader.nextLine() + '\n' );
    }
    catch(Exception e){ e.printStackTrace(); }

    Assert.assertNotNull(inline.toString());

    System.out.println("=======================Input=================================");
    System.out.println(inline);

    String line1 = genFile(filename);
    Assert.assertNotNull(line1);
    writeToFile(line1, "parsedprettyprinttest.out" );

    String line2 = genFile("parsedprettyprinttest.out");
    Assert.assertNotNull(line2);
    writeToFile(line2, "parsedprettyprinttest.out" );

    String regex = "%Declare [a-z A-Z]*\n";

    System.out.println("=======================Input'=================================");
    System.out.println(line1);
    System.out.println("=======================Input''=================================");
    System.out.println(line2);

    // compare results; exclude those strings matching the pattern from the comparison

    Assert.assertTrue("Different ", line1.replaceAll(regex, "").equals(line2.replaceAll(regex, "")) );          
}
项目:embedded-rest-server    文件:HandlerCollectionLoaderTest.java   
@Before
public void before() throws Exception {
  defaultEnv = new HashMap<>();
  String name = UUID.randomUUID().toString();
  defaultEnv.put(Environment.APPLICATION_NAME, name);
  defaultEnv.put(name + Environment.ROOT_SUFFIX, StandardSystemProperty.JAVA_IO_TMPDIR.value());
  defaultEnv.put(name + Environment.SERVER_HOST_SUFFIX, "localhost");
  defaultEnv.put(name + Environment.SERVER_PORT_SUFFIX, "7777");
  env = Environment.createEnvironment(defaultEnv);
}
项目:embedded-rest-server    文件:EmbeddedServerTest.java   
@Before
public void before() throws Exception {
  defaultEnv = new HashMap<>();
  String name = UUID.randomUUID().toString();
  defaultEnv.put(Environment.APPLICATION_NAME, name);
  defaultEnv.put(name + Environment.ROOT_SUFFIX, StandardSystemProperty.JAVA_IO_TMPDIR.value());
  defaultEnv.put(name + Environment.SERVER_HOST_SUFFIX, "localhost");
  defaultEnv.put(name + Environment.SERVER_PORT_SUFFIX, "7777");
  env = Environment.createEnvironment(defaultEnv);
}
项目:presto    文件:PrestoSystemRequirements.java   
public static void verifyJvmRequirements()
{
    String specVersion = StandardSystemProperty.JAVA_SPECIFICATION_VERSION.value();
    if ((specVersion == null) || (specVersion.compareTo("1.8") < 0)) {
        failRequirement("Presto requires Java 1.8+ (found %s)", specVersion);
    }

    String vendor = StandardSystemProperty.JAVA_VENDOR.value();
    if (!"Oracle Corporation".equals(vendor)) {
        failRequirement("Presto requires an Oracle or OpenJDK JVM (found %s)", vendor);
    }

    String dataModel = System.getProperty("sun.arch.data.model");
    if (!"64".equals(dataModel)) {
        failRequirement("Presto requires a 64-bit JVM (found %s)", dataModel);
    }

    String osName = StandardSystemProperty.OS_NAME.value();
    String osArch = StandardSystemProperty.OS_ARCH.value();
    if ("Linux".equals(osName)) {
        if (!"amd64".equals(osArch)) {
            failRequirement("Presto requires x86-64 or amd64 on Linux (found %s)", osArch);
        }
    }
    else if ("Mac OS X".equals(osName)) {
        if (!"x86_64".equals(osArch)) {
            failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
        }
    }
    else {
        failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
    }

    if (!ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
        failRequirement("Presto requires a little endian platform (found %s)", ByteOrder.nativeOrder());
    }

    verifySlice();
}
项目:presto    文件:HiveWriteUtils.java   
public static Path createTemporaryPath(HdfsEnvironment hdfsEnvironment, Path targetPath)
{
    // use a per-user temporary directory to avoid permission problems
    // TODO: this should use Hadoop UserGroupInformation
    String temporaryPrefix = "/tmp/presto-" + StandardSystemProperty.USER_NAME.value();

    // create a temporary directory on the same filesystem
    Path temporaryRoot = new Path(targetPath, temporaryPrefix);
    Path temporaryPath = new Path(temporaryRoot, randomUUID().toString());

    createDirectory(hdfsEnvironment, temporaryPath);

    return temporaryPath;
}
项目:GRIP    文件:CameraSource.java   
@Subscribe
public void onSourceRemovedEvent(SourceRemovedEvent event) throws InterruptedException,
    TimeoutException, IOException {
  if (event.getSource() == this) {
    try {
      // Stop the camera service and wait for it to terminate.
      // If we just use stopAsync(), the camera service won't always have terminated by the time
      // a new camera source is added. For webcam sources, this means that the video stream
      // won't be freed and new sources won't be able to connect to the webcam until the
      // application is closed.
      if (StandardSystemProperty.OS_NAME.value().toLowerCase(Locale.ENGLISH).contains("mac")) {
        // Workaround for #716. This affects webcams as well as IP camera sources.
        // Use only stopAsync() to avoid blocking. Since we have no way of knowing when
        // the capture has actually been freed, we use a dumb delay to try to make sure it's
        // freed before returning. THIS IS NOT A GOOD SOLUTION. But it's the best one we have
        // until the bug is fixed.
        stopAsync();
        try {
          // Wait a bit to try to make sure the capture is actually freed before returning
          Thread.sleep(100);
        } catch (InterruptedException ignore) {
          // We did our best. Hopefully, the webcam has been freed at this point.
          Thread.currentThread().interrupt();
        }
      } else {
        this.stopAndAwait();
      }
    } finally {
      this.eventBus.unregister(this);
    }
  }
}
项目:GRIP    文件:CameraSource.java   
@Override
public FrameGrabber create(int deviceNumber) {
  // On Windows, videoInput is much more reliable for webcam capture.  On other platforms,
  // OpenCV's frame
  // grabber class works fine.
  if (StandardSystemProperty.OS_NAME.value().contains("Windows")) {
    return new VideoInputFrameGrabber(deviceNumber);
  } else {
    return new OpenCVFrameGrabber(deviceNumber);
  }
}