List of usage examples for com.google.common.base StandardSystemProperty USER_DIR
StandardSystemProperty USER_DIR
To view the source code for com.google.common.base StandardSystemProperty USER_DIR.
Click Source Link
From source file:org.n52.matlab.connector.server.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 {/*from www . ja v a2 s . com*/ 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); } } }
From source file:com.codebullets.external.party.simulator.config.ServiceConfig.java
private Path getPath(final String property, final String defaultVal) { Path path;//from ww w . j a v a 2s . co m String configVal = System.getProperty(property); if (configVal != null) { path = Paths.get(configVal); } else { path = Paths.get(StandardSystemProperty.USER_DIR.value(), defaultVal); } return path; }
From source file:ratpack.configuration.internal.DefaultConfigurationFactoryFactory.java
@Override public ConfigurationFactory build(ConfigurationSource configurationSource) throws ConfigurationException { TypeCoercingProperties props = LaunchConfigsInternal.consolidatePropertiesFromGlobalProperties( StandardSystemProperty.USER_DIR.value(), classLoader, configurationSource.getOverrideProperties(), configurationSource.getDefaultProperties()); try {//from w w w. j av a 2 s .co m Class<ConfigurationFactory> configurationFactoryClass = props.asClass(CONFIGURATION_FACTORY, ConfigurationFactory.class); if (configurationFactoryClass != null) { return configurationFactoryClass.newInstance(); } } catch (ReflectiveOperationException ex) { throw new ConfigurationException("Could not instantiate specified configuration factory class " + props.asString(CONFIGURATION_FACTORY, null), ex); } ServiceLoader<ConfigurationFactory> serviceLoader = ServiceLoader.load(ConfigurationFactory.class, classLoader); try { return Iterables.getOnlyElement(serviceLoader, new DefaultConfigurationFactory()); } catch (IllegalArgumentException ex) { throw new ConfigurationException( "Multiple possible configuration factories were found; please specify one with the '" + CONFIGURATION_FACTORY + "' property", ex); } }
From source file:ratpack.groovy.internal.StandaloneScriptBacking.java
public void execute(final Closure<?> closure) throws Exception { GroovyVersionCheck.ensureRequiredVersionUsed(GroovySystem.getVersion()); Path scriptFile = ClosureUtil.findScript(closure); Properties defaultProperties = new Properties(); Path baseDir;//w w w .j a va 2 s . c o m if (scriptFile == null) { baseDir = new File(StandardSystemProperty.USER_DIR.value()).toPath(); } else { baseDir = scriptFile.getParent(); } Properties properties = createProperties(scriptFile); Path configFile = new DefaultFileSystemBinding(baseDir).file(LaunchConfigs.CONFIG_RESOURCE_DEFAULT); LaunchConfig launchConfig = LaunchConfigs.createFromFile(closure.getClass().getClassLoader(), baseDir, configFile, properties, defaultProperties); if (scriptFile == null) { launchConfig = new DelegatingLaunchConfig(launchConfig) { @Override public HandlerFactory getHandlerFactory() { return new GroovyClosureHandlerFactory(closure); } }; } RatpackServer server = RatpackServerBuilder.build(launchConfig); Action<? super RatpackServer> action = CAPTURE_ACTION.getAndSet(null); if (action != null) { action.execute(server); } server.start(); try { while (server.isRunning() && !Thread.interrupted()) { Thread.sleep(1000); } } catch (InterruptedException ignore) { // do nothing } server.stop(); }
From source file:ratpack.configuration.internal.DefaultLaunchConfigFactory.java
private static Path determineDefaultBaseDir(ConfigurationSource configurationSource) { String workingDir = StandardSystemProperty.USER_DIR.value(); String configResourceValue = configurationSource.getOverrideProperties() .getProperty(LaunchConfigs.CONFIG_RESOURCE_PROPERTY, LaunchConfigs.CONFIG_RESOURCE_DEFAULT); URL configResourceUrl = configurationSource.getClassLoader().getResource(configResourceValue); Path configPath = LaunchConfigsInternal.determineConfigPath(workingDir, configResourceValue, configResourceUrl);// w ww . ja va 2 s.c o m return LaunchConfigsInternal.determineBaseDir(configPath); }
From source file:ratpack.launch.LaunchConfigs.java
/** * Delegates to {@link #createFromGlobalProperties(ClassLoader, String, java.util.Properties, java.util.Properties)}, extracting the propertyPrefix? from the globalProperties?. <p> Determines the * propertyPrefix? value and delegates to {@link #createFromGlobalProperties(ClassLoader, String, java.util.Properties, java.util.Properties)}. The value is determined by: {@code * globalProperties.getProperty(SYSPROP_PREFIX_PROPERTY, SYSPROP_PREFIX_DEFAULT)} * * @param classLoader The classloader to use to find the properties file. * @param globalProperties The environmental (override) properties * @param defaultProperties The default properties to use when a property is omitted * @return A launch config//from w ww . ja va 2 s .c om */ public static LaunchConfig createFromGlobalProperties(ClassLoader classLoader, Properties globalProperties, Properties defaultProperties) { return createLaunchConfig(LaunchConfigsInternal.createFromGlobalProperties( StandardSystemProperty.USER_DIR.value(), classLoader, globalProperties, defaultProperties)); }
From source file:ratpack.configuration.internal.DefaultConfigurationFactory.java
@Override public <T extends Configuration> T build(Class<T> configurationClass, ConfigurationSource configurationSource) throws ConfigurationException { T configuration;//from w w w.j a v a 2s. com try { configuration = configurationClass.newInstance(); } catch (ReflectiveOperationException ex) { throw new ConfigurationException( "Could not instantiate configuration class " + configurationClass.getName(), ex); } LaunchConfigData launchConfigData = LaunchConfigsInternal.createFromGlobalProperties( StandardSystemProperty.USER_DIR.value(), configurationSource.getClassLoader(), configurationSource.getOverrideProperties(), configurationSource.getDefaultProperties(), Registries.empty()); LaunchConfigFactory launchConfigFactory = configuration.getLaunchConfigFactory(); if (launchConfigFactory instanceof DefaultLaunchConfigFactory) { populateLaunchConfigFactory(launchConfigData, (DefaultLaunchConfigFactory) launchConfigFactory); } return configuration; }
From source file:ratpack.server.internal.DefaultServerConfigBuilder.java
public static ServerConfig.Builder findBaseDirProps(ServerEnvironment serverEnvironment, String propertiesPath) {// ww w . j ava2s. c om String workingDir = StandardSystemProperty.USER_DIR.value(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); BaseDirFinder.Result result = BaseDirFinder.find(workingDir, classLoader, propertiesPath) .orElseThrow(() -> new IllegalStateException("Could not find properties file '" + propertiesPath + "' in working dir '" + workingDir + "' or context class loader classpath")); return baseDir(serverEnvironment, result.getBaseDir()).props(result.getResource()); }
From source file:com.google.copybara.testing.OptionsBuilder.java
public final OptionsBuilder setWorkdirToRealTempDir() throws IOException { general = new GeneralOptions( updateEnvironment(general.getEnvironment(), "PWD", StandardSystemProperty.USER_DIR.value()), FileSystems.getDefault(), /*verbose=*/true, LogConsole.readWriteConsole(System.in, System.out), general.isValidate(), general.getConfigRoot(), general.isDisableReversibleCheck()); return this; }
From source file:demetra.cli.tsproviders.ProviderToolImpl.java
@Override public void applyWorkingDir(IFileLoader provider) { provider.setPaths(new File[] { new File(StandardSystemProperty.USER_DIR.value()) }); }