List of usage examples for java.lang System setProperties
public static void setProperties(Properties props)
From source file:com.amazonaws.kinesis.dataviz.twitter.TwitterProducer.java
private void loadFileProperties(String propFilePath, String defaultName) { try {// w w w . j ava 2 s.co m if (propFilePath == null) { String userHome = System.getProperty("user.home"); propFilePath = userHome + "/" + defaultName + ".properties"; } InputStream propFile = new FileInputStream(propFilePath); Properties p = new Properties(System.getProperties()); p.load(propFile); System.setProperties(p); // got them from the file LOG.info("Got properties from file"); } catch (FileNotFoundException e) { // file is not there... } catch (IOException e) { // can't read file } catch (Exception e) { e.printStackTrace(); } }
From source file:org.sonatype.nexus.test.PlexusTestCaseSupport.java
protected void tearDown() throws Exception { try {//from w w w.ja v a2s .com if (container != null) { container.dispose(); container = null; } } finally { System.setProperties(sysPropsBackup); } }
From source file:org.sonatype.sisu.bl.jsw.JSWConfigTest.java
@Test public void wrapperCommentsPerTypeOfOverride() throws Exception { // backup system properties Properties backup = new Properties(); backup.putAll(System.getProperties()); // setup sys props Map<String, String> testProps = Maps.newHashMap(); testProps.put("wrapper.system.prop", "bar"); System.getProperties().putAll(testProps); jswConfig.load(); // loads system properties // set an explicit property as well jswConfig.setProperty("wrapper.explicit.prop", "baz"); // save again to write out config with system properties jswConfig.save();//from ww w . ja v a2 s . c om // check that overridden properties are written assertThat(config, contains("# system overrides")); assertThat(config, contains("# explicit overrides")); assertThat(config, contains("wrapper.explicit.prop=baz")); assertThat(config, contains("wrapper.system.prop=bar")); // reset system properties System.setProperties(backup); }
From source file:com.vmware.identity.idm.server.IdmServer.java
/** * Initialize the IDM service.//w ww . java 2s . c om * * @throws Exception when something goes wrong with initialization. */ private static void initialize() throws Exception { try (IDiagnosticsContextScope diagCtxt = DiagnosticsContextFactory.createContext("IDM Startup", "")) { logger.info("Starting IDM Server..."); logger.debug("Creating RMI registry on port {}", Tenant.RMI_PORT); boolean allowRemoteConnections = Boolean .parseBoolean(System.getProperty(ALLOW_REMOTE_PROPERTY, "false")); if (allowRemoteConnections) { logger.warn("RMI registry is allowing remote connections!"); registry = LocateRegistry.createRegistry(Tenant.RMI_PORT); } else { logger.debug("RMI registry is restricted to the localhost"); RMIClientSocketFactory csf = RMISocketFactory.getDefaultSocketFactory(); RMIServerSocketFactory ssf = new LocalRMIServerSocketFactory(); registry = LocateRegistry.createRegistry(Tenant.RMI_PORT, csf, ssf); } // Assign a security manager, in the event that dynamic classes are loaded if (System.getSecurityManager() == null) { logger.debug("Creating RMI Security Manager..."); System.setSecurityManager(new RMISecurityManager()); } logger.debug("Creating Config Store factory..."); IConfigStoreFactory cfgStoreFactory = new ConfigStoreFactory(); logger.debug("Creating Identity Provider factory..."); IProviderFactory providerFactory = new ProviderFactory(); logger.debug("Checking VMware Directory Service..."); ServerUtils.check_directory_service(); logger.debug("Setting system properties..."); System.setProperties(new ThreadLocalProperties(System.getProperties())); logger.debug("Creating Identity Manager instance..."); manager = new IdentityManager(cfgStoreFactory, providerFactory); String rmiAddress = String.format("rmi://localhost:%d/%s", Tenant.RMI_PORT, IDENTITY_MANAGER_BIND_NAME); logger.debug("Binding to RMI address '{}'", rmiAddress); loginManager = new IdmLoginManager(manager); ILoginManager stub = (ILoginManager) UnicastRemoteObject.exportObject(loginManager, 0); Naming.rebind(rmiAddress, stub); startHeartbeat(); logger.info(VmEvent.SERVER_STARTED, "IDM Server has started"); } catch (Throwable t) { logger.error(VmEvent.SERVER_FAILED_TOSTART, "IDM Server has failed to start", t); throw t; } }
From source file:nz.co.fortytwo.signalk.server.SignalKServer.java
private Server startJolokia() throws Exception { Properties props = System.getProperties(); props.setProperty("jolokia.authenticationEnabled", "false"); System.setProperties(props); //System.setProperty("hawtio.authenticationEnabled",Util.getConfigPropertyBoolean(ConfigConstants.HAWTIO_AUTHENTICATE).toString()); int hawtPort = Util.getConfigPropertyInt(ConfigConstants.JOLOKIA_PORT); return startServer(hawtPort, Util.getConfigProperty(ConfigConstants.JOLOKIA_CONTEXT), Util.getConfigProperty(ConfigConstants.JOLOKIA_WAR), "/.jolokia"); }
From source file:org.sonatype.sisu.bl.jsw.JSWConfigTest.java
@Test public void wrapperSystemPropertiesOverride() throws Exception { Properties backup = new Properties(); backup.putAll(System.getProperties()); // test setup Map<String, String> testProps = Maps.newHashMap(); testProps.put(JSWConfig.WRAPPER_JAVA_COMMAND, "/my/custom/java"); testProps.put("nonwrapper.prop", "special"); testProps.put("wrapper.prop", "something"); System.getProperties().putAll(testProps); // load and then save capture system properties jswConfig.load();//from w w w .j av a2s .co m jswConfig.save(); // check that overridden properties are written assertThat(config, contains("# system overrides")); assertThat(config, contains("wrapper.java.command=/my/custom/java")); assertThat(config, contains("wrapper.prop=something")); assertThat(config, doesNotContain("nonwrapper.prop=special")); // reset system properties System.setProperties(backup); }
From source file:org.sonatype.nexus.test.NexusTestSupport.java
protected void tearDown() throws Exception { try {/*w w w .java 2s. c o m*/ if (testInjector != null) { testInjector.getInstance(BeanManager.class).unmanage(); } } finally { bootModule = null; testInjector = null; System.setProperties(sysPropsBackup); } cleanDir(testHomeDir); }
From source file:DetectLog.AbnormalLogDetect.java
public void PropertiesManager() { FileInputStream propFile = null; try {/*from ww w . j av a 2 s . c o m*/ propFile = new FileInputStream(FILENAME); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } properties = new Properties(System.getProperties()); try { properties.load(propFile); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.setProperties(properties); }
From source file:edu.umich.ctools.sectionsUtilityTool.Friend.java
public void setProperties() { if (appExtSecureProperties != null) { //PropertiesFile information friendUrl = appExtProperties.getProperty(FRIEND_URL); contactEmail = appExtProperties.getProperty(FRIEND_CONTACT_EMAIL); referrerUrl = appExtProperties.getProperty(FRIEND_REFERRER); friendEmailFile = appExtProperties.getProperty(FRIEND_FRIEND_EMAIL); requesterEmailFile = appExtProperties.getProperty(FRIEND_REQUESTER_EMAIL); mailHost = appExtProperties.getProperty(FRIEND_MAIL_HOST); subjectLine = appExtProperties.getProperty(FRIEND_SUBJECT_LINE); ksFileName = appExtSecureProperties.getProperty(FRIEND_KS_FILENAME); ksPwd = appExtSecureProperties.getProperty(FRIEND_KS_PASSWORD); M_log.debug("ksFileName: " + ksFileName); M_log.debug("ksPwd: " + ksPwd); M_log.debug("friendUrl: " + friendUrl); M_log.debug("contactEmail: " + contactEmail); M_log.debug("referrerUrl: " + referrerUrl); } else {/*from ww w .j a v a 2 s . c o m*/ M_log.error( "Failed to load Friend application properties from sectionsToolFriend.properties for SectionsTool"); } //Setting up properties for keyStore Properties systemProps = System.getProperties(); String keyStoreType = (String) systemProps.get("javax.net.ssl.keyStoreType"); String trustStoreType = (String) systemProps.get("javax.net.ssl.trustStoreType"); if (keyStoreType != null && !KEYSTORETYPE_PKCS12.equals(keyStoreType)) // existing keyStoreType { M_log.error(this + " setProperties: existing settings of SSL keyStoreType mismatch: " + keyStoreType); sslInitialized = false; } else if (trustStoreType != null && !TRUSTSTORETYPE_JKS.equals(trustStoreType)) // existing trustStoreType { M_log.error(this + " init: existing settings of SSL trustStoretype mismatch: " + trustStoreType); sslInitialized = false; } else { // key store systemProps.put("javax.net.ssl.keyStoreType", KEYSTORETYPE_PKCS12); systemProps.put("javax.net.ssl.trustStoreType", TRUSTSTORETYPE_JKS); if (ksFileName.isEmpty()) { // log error for missing keystore file path M_log.error(this + " init the umich.friend.keystorefile path is not defined. "); } else { systemProps.put("javax.net.ssl.keyStore", ksFileName); } if (ksPwd.isEmpty()) { // log error for missing keystore password M_log.error(this + " init the umich.friend.keystorepassword is not defined. "); } else { systemProps.put("javax.net.ssl.keyStorePassword", ksPwd); } // set system properties System.setProperties(systemProps); sslInitialized = true; } }
From source file:nz.co.fortytwo.signalk.server.SignalKServer.java
private Server startHawtio() throws Exception { // hawtio, auth disabled Properties props = System.getProperties(); props.setProperty("hawtio.authenticationEnabled", "false"); System.setProperties(props); //System.setProperty("hawtio.authenticationEnabled",Util.getConfigPropertyBoolean(ConfigConstants.HAWTIO_AUTHENTICATE).toString()); int hawtPort = Util.getConfigPropertyInt(ConfigConstants.HAWTIO_PORT); return startServer(hawtPort, Util.getConfigProperty(ConfigConstants.HAWTIO_CONTEXT), Util.getConfigProperty(ConfigConstants.HAWTIO_WAR), "/.hawtio"); }