List of usage examples for java.lang System getProperties
public static Properties getProperties()
From source file:is.landsbokasafn.deduplicator.indexer.IndexingLauncher.java
private static void loadConfiguration() { // Load properties file, either from heritrix.home/conf or // path specified via -Ddeduplicator.config JVM option String configFilename = System.getProperty("deduplicator.config"); if (configFilename == null || configFilename.isEmpty()) { // Configuration file not explicitly set. Use default. // This works if invoked via the provided script. Will fail otherwise unless -Ddeduplicator.home is set configFilename = System.getProperty("deduplicator.home") + File.separator + "conf" + File.separator + "deduplicator.properties"; }//w w w. ja va 2 s . c om File configFile = new File(configFilename); if (configFile.exists() == false) { System.out.println("Unable to find configuration file " + configFilename); System.exit(1); } // Load log4j config, assumes same path as config file String log4jconfig = configFile.getParent() + File.separator + "deduplicator-log4j.properties"; PropertyConfigurator.configure(log4jconfig); // Copy properties from config file to System properties try { System.getProperties().load(new FileReader(configFile)); } catch (IOException e) { System.err.println("Unable to read configuration file"); e.printStackTrace(); System.exit(1); } }
From source file:ch.cyberduck.core.sds.SDSMultipartWriteFeatureTest.java
@Test public void testReadWrite() throws Exception { final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials( System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key"))); final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path room = new SDSDirectoryFeature(session) .mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus()); final byte[] content = RandomUtils.nextBytes(32769); final TransferStatus status = new TransferStatus(); status.setLength(-1L);/*w w w. j a v a 2s. c o m*/ final Path test = new Path(room, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final SDSMultipartWriteFeature writer = new SDSMultipartWriteFeature(session); final HttpResponseOutputStream<VersionId> out = writer.write(test, status, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out); final VersionId version = out.getStatus(); assertNotNull(version); assertTrue(new DefaultFindFeature(session).find(test)); final byte[] compare = new byte[content.length]; final InputStream stream = new SDSReadFeature(session).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(stream, compare); stream.close(); assertArrayEquals(content, compare); new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:org.wallride.web.controller.admin.system.SystemIndexController.java
@RequestMapping(method = RequestMethod.GET) public String index(Model model) { model.addAttribute("system", System.getProperties()); return "system/index"; }
From source file:de.tud.inf.db.sparqlytics.bench.LDBCBenchmark.java
public LDBCBenchmark() { globalVariables = new HashMap<>(); Properties systemProperties = System.getProperties(); for (String name : systemProperties.stringPropertyNames()) { globalVariables.put(name, systemProperties.getProperty(name)); }//from w w w . j av a 2 s. c o m }
From source file:ch.cyberduck.core.shared.DefaultUploadFeatureTest.java
@Test public void testTransferAppend() throws Exception { final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"))); final SFTPSession session = new SFTPSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final byte[] content = new byte[32770]; new Random().nextBytes(content); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out);/*from w w w. ja va2 s . c o m*/ out.close(); final Path test = new Path(new SFTPHomeDirectoryService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().length(content.length / 2); new DefaultUploadFeature<Void>(new SFTPWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); } { final TransferStatus status = new TransferStatus().length(content.length / 2).skip(content.length / 2) .append(true); new DefaultUploadFeature<Void>(new SFTPWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); } final byte[] buffer = new byte[content.length]; final Read read = session.getFeature(Read.class); final InputStream in = read.read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); assertArrayEquals(content, buffer); final Delete delete = session.getFeature(Delete.class); delete.delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); local.delete(); session.close(); }
From source file:com.dataartisans.flink.cascading.platform.FlinkTestPlatform.java
@Override public void setUp() throws IOException { if (!this.isUseCluster()) { this.numMappers = 1; this.numGatherPartitions = 1; }/*www. j a va 2 s .c om*/ Properties properties = System.getProperties(); File testDataLocation = new File("./target/data/"); if (testDataLocation.exists() && testDataLocation.canRead()) { properties.setProperty(InputData.TEST_DATA_PATH, testDataLocation.getAbsolutePath() + "/"); } else { throw new IllegalStateException("The test data is not available. To extract the data, " + "please execute 'mvn clean compile' once."); } }
From source file:com.sec.ose.osi.UIMain.java
private static double getJavaVersion() { Properties prop = System.getProperties(); String java_specification_version = prop.getProperty("java.specification.version"); StringTokenizer st = new StringTokenizer(java_specification_version, "."); String major = st.nextToken(); String minor = st.nextToken(); try {//from w ww . ja v a 2 s .c om double version = Double.parseDouble(major + "." + minor); return version; } catch (NumberFormatException e) { log.warn(e); return 0; } }
From source file:de.hoegertn.demo.cxfsimple.SpringStarter.java
public final void doStart() throws Exception { try {//from w ww. j av a2 s . com this.doBeforeSpringStart(); } catch (Exception e) { throw new RuntimeException("Before spring failed", e); } Lock writeLock = this.rwLock.writeLock(); AbstractXmlApplicationContext ctx = null; try { writeLock.lock(); if (this.context.get() != null) { throw new RuntimeException("Already started"); } ctx = this.createSpringContext(); final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setProperties(System.getProperties()); ctx.addBeanFactoryPostProcessor(configurer); ctx.setConfigLocation(this.getSpringResource()); ctx.refresh(); } catch (Exception e) { if (ctx != null) { try { ctx.close(); } catch (Exception e1) { this.logger.warn("Failed to close context", e1); } ctx = null; } throw new RuntimeException("Spring context failed", e); } finally { if (ctx != null) { this.context.set(ctx); } writeLock.unlock(); } try { this.doAfterSpringStart(); } catch (Exception e) { throw new RuntimeException("After spring failed", e); } }
From source file:io.apiman.common.config.SystemPropertiesConfiguration.java
/** * @see org.apache.commons.configuration.Configuration#getKeys() *//* ww w . j ava 2 s . c om*/ @Override public Iterator<String> getKeys() { Set<String> keys = new HashSet<>(); Set<Object> keySet = System.getProperties().keySet(); for (Object object : keySet) { keys.add(String.valueOf(object)); } return keys.iterator(); }
From source file:cloud.elasticity.elastman.Props.java
public static void load(String filename, CommandLine cmd) { FileInputStream propFile;//from www. j a v a 2 s . c om try { propFile = new FileInputStream(filename); properties = new Properties(System.getProperties()); properties.load(propFile); propFile.close(); } catch (FileNotFoundException e1) { log.warn("Properties file not found!! Using defaults"); // e1.printStackTrace(); } catch (IOException e) { log.error("Properties file I/O error!! using defaults"); // e.printStackTrace(); } // TODO: make text constants to avoid typo bugs if (cmd.hasOption("u")) { properties.setProperty("username", cmd.getOptionValue("u")); } if (cmd.hasOption("p")) { properties.setProperty("password", cmd.getOptionValue("p")); } if (cmd.hasOption("k")) { properties.setProperty("keyname", cmd.getOptionValue("k")); } if (cmd.hasOption("z")) { properties.setProperty("zone", cmd.getOptionValue("z")); } if (cmd.hasOption("e")) { properties.setProperty("endpoint", cmd.getOptionValue("e")); } if (cmd.hasOption("s")) { properties.setProperty("webSyncServer", cmd.getOptionValue("s")); } username = properties.getProperty("username", "OpenstackDemo:user"); password = properties.getProperty("password"); keyname = properties.getProperty("keyname", "mykey"); zone = properties.getProperty("zone", "RegionOne"); endpoint = properties.getProperty("endpoint", "http://192.168.1.1:5000/v2.0/"); webSyncServer = properties.getProperty("webSyncServer", "http://192.168.1.1:8080/cloud/voldcache.php"); server_port = Integer.parseInt(properties.getProperty("server.port", "4444")); ident_client_min = Integer.parseInt(properties.getProperty("ident.client.min", "1")); ident_client_max = Integer.parseInt(properties.getProperty("ident.client.max", "18")); ident_client_delta = Integer.parseInt(properties.getProperty("ident.client.delta", "1")); ident_client_delay = Integer.parseInt(properties.getProperty("ident.client.delay", "900")); ident_period = Integer.parseInt(properties.getProperty("ident.period", "4")); ident_sampling = Integer.parseInt(properties.getProperty("ident.sampling", "300")); ident_client_manual = Boolean.parseBoolean(properties.getProperty("ident.client.manual", "false")); control_interval = Integer.parseInt(properties.getProperty("control.interval", "300")); voldCount = Integer.parseInt(properties.getProperty("cloud.voldVMs", "0")); createVMs = Boolean.parseBoolean(properties.getProperty("act.createVMs", "true")); voldMax = Integer.parseInt(properties.getProperty("act.voldMax", "27")); voldMin = Integer.parseInt(properties.getProperty("act.voldMin", "3")); voldDeltaMax = Integer.parseInt(properties.getProperty("act.voldDeltaMax", "7")); control_kp = Double.parseDouble(properties.getProperty("control.kp", "0")); control_ki = Double.parseDouble(properties.getProperty("control.ki", "0")); control_kd = Double.parseDouble(properties.getProperty("control.kd", "0")); control_inOp = Double.parseDouble(properties.getProperty("control.inOp", "6000000")); control_outOp = Double.parseDouble(properties.getProperty("control.outOp", "1400")); filter_alpha = Double.parseDouble(properties.getProperty("filter.alpha", "0.4")); control_warmup = Integer.parseInt(properties.getProperty("control.warmup", "4")); control_dead = Double.parseDouble(properties.getProperty("control.dead", "500000")); control_ff_throughputDelta = Double .parseDouble(properties.getProperty("control.ff.throughputDelta", "1400")); control_ffr1 = Double.parseDouble(properties.getProperty("control.ff.r1", "1980")); control_ffw1 = Double.parseDouble(properties.getProperty("control.ff.w1", "220")); control_ffr2 = Double.parseDouble(properties.getProperty("control.ff.r2", "0")); control_ffw2 = Double.parseDouble(properties.getProperty("control.ff.w2", "1000")); voldPrefix = properties.getProperty("voldPrefix", "vold"); voldImage = properties.getProperty("voldImage"); voldFlavor = properties.getProperty("voldFlavor", "3"); voldReplicationFactor = Integer.parseInt(properties.getProperty("voldReplicationFactor", "3")); ycsbPrefix = properties.getProperty("ycsbPrefix", "ycsb"); ycsbImage = properties.getProperty("ycsbImage"); ycsbFlavor = properties.getProperty("ycsbFlavor", "3"); }