List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.olat.core.util.i18n.I18nManager.java
public void setAnnotation(I18nItem i18nItem, String annotation) { Properties properties = getPropertiesWithoutResolvingRecursively(null, i18nItem.getBundleName()); String key = i18nItem.getKey() + METADATA_ANNOTATION_POSTFIX; if (StringHelper.containsNonWhitespace(annotation)) { properties.setProperty(key, annotation); } else if (properties.containsKey(key)) { properties.remove(key); }/*from w w w . j a va 2 s . c om*/ if (properties.size() == 0) { // delete empty files deleteProperties(null, i18nItem.getBundleName()); } else { // update saveOrUpdateProperties(properties, null, i18nItem.getBundleName()); } }
From source file:org.apache.axis2.clustering.tribes.TribesClusterManager.java
private void setMemberInfo() throws ClusteringFault { Properties memberInfo = new Properties(); AxisConfiguration axisConfig = configurationContext.getAxisConfiguration(); TransportInDescription httpTransport = axisConfig.getTransportIn("http"); if (httpTransport != null) { Parameter port = httpTransport.getParameter("port"); if (port != null) { memberInfo.put("httpPort", port.getValue()); }/*from w ww. j a va 2 s .co m*/ } TransportInDescription httpsTransport = axisConfig.getTransportIn("https"); if (httpsTransport != null) { Parameter port = httpsTransport.getParameter("port"); if (port != null) { memberInfo.put("httpsPort", port.getValue()); } } Parameter isActiveParam = getParameter(ClusteringConstants.Parameters.IS_ACTIVE); if (isActiveParam != null) { memberInfo.setProperty(ClusteringConstants.Parameters.IS_ACTIVE, (String) isActiveParam.getValue()); } memberInfo.setProperty("hostName", TribesUtil.getLocalHost(getParameter(TribesConstants.LOCAL_MEMBER_HOST))); Parameter propsParam = getParameter("properties"); if (propsParam != null) { OMElement paramEle = propsParam.getParameterElement(); for (Iterator iter = paramEle.getChildrenWithLocalName("property"); iter.hasNext();) { OMElement propEle = (OMElement) iter.next(); OMAttribute nameAttrib = propEle.getAttribute(new QName("name")); if (nameAttrib != null) { OMAttribute valueAttrib = propEle.getAttribute(new QName("value")); if (valueAttrib != null) { String attribVal = valueAttrib.getAttributeValue(); attribVal = replaceProperty(attribVal, memberInfo); memberInfo.setProperty(nameAttrib.getAttributeValue(), attribVal); } } } } memberInfo.remove("hostName"); // this was needed only to populate other properties. No need to send it. ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { memberInfo.store(bout, ""); } catch (IOException e) { String msg = "Cannot store member transport properties in the ByteArrayOutputStream"; log.error(msg, e); throw new ClusteringFault(msg, e); } channel.getMembershipService().setPayload(bout.toByteArray()); }
From source file:org.apache.axis2.clustering.zookeeper.ZooKeeperClusteringAgent.java
/** * Sets member information by retrieving info from Configuration * //from w w w . j av a2 s. c o m * @throws ClusteringFault */ private void setMemberInfo() throws ClusteringFault { Properties memberInfo = new Properties(); AxisConfiguration axisConfig = configurationContext.getAxisConfiguration(); TransportInDescription httpTransport = axisConfig.getTransportIn("http"); int portOffset = 0; if (System.getProperty("portOffset") != null) { portOffset = Integer.parseInt(System.getProperty("portOffset")); } if (httpTransport != null) { Parameter port = httpTransport.getParameter("port"); if (port != null) { memberInfo.put("httpPort", String.valueOf(Integer.valueOf((String) port.getValue()) + portOffset)); } } TransportInDescription httpsTransport = axisConfig.getTransportIn("https"); if (httpsTransport != null) { Parameter port = httpsTransport.getParameter("port"); if (port != null) { memberInfo.put("httpsPort", String.valueOf(Integer.valueOf((String) port.getValue()) + portOffset)); } } memberInfo.setProperty("hostName", ZooKeeperUtils.getLocalHost(getParameter(ZooKeeperConstants.LOCAL_MEMBER_HOST))); Parameter propsParam = getParameter("properties"); if (propsParam != null) { OMElement paramEle = propsParam.getParameterElement(); for (Iterator<?> iter = paramEle.getChildrenWithLocalName("property"); iter.hasNext();) { OMElement propEle = (OMElement) iter.next(); OMAttribute nameAttrib = propEle.getAttribute(new QName("name")); if (nameAttrib != null) { String attribName = nameAttrib.getAttributeValue(); attribName = replaceProperty(attribName, memberInfo); OMAttribute valueAttrib = propEle.getAttribute(new QName("value")); if (valueAttrib != null) { String attribVal = valueAttrib.getAttributeValue(); attribVal = replaceProperty(attribVal, memberInfo); memberInfo.setProperty(attribName, attribVal); } } } } memberInfo.remove("hostName"); // this was needed only to populate other // properties. No need to send it. ByteArrayOutputStream bout = new ByteArrayOutputStream(); try { memberInfo.store(bout, ""); } catch (IOException e) { String msg = "Cannot store member transport properties in the ByteArrayOutputStream"; log.error(msg, e); throw new ClusteringFault(msg, e); } ZkMember member = primaryMembershipManager.getLocalMember(); member.setPayLoad(bout.toByteArray()); primaryMembershipManager.setLocalMember(member); // channel.getMembershipService().setPayload(bout.toByteArray()); }
From source file:org.apache.directory.fortress.core.ant.FortressAntTask.java
/** * @throws BuildException/*from w w w . j a v a 2 s .com*/ */ private void deleteConfig() throws BuildException { if (delconfig == null) { return; } Properties props = new Properties(); String configNodeName = ""; // Loop through the entityclass elements for (Delconfig delcfg : delconfig) { try { List<ConfigAnt> cfgs = delcfg.getConfig(); for (ConfigAnt cfg : cfgs) { String val = cfg.getProps(); int indx = val.indexOf(GlobalIds.PROP_SEP); if (indx >= 1) { String name = val.substring(0, indx); String value = val.substring(indx + 1); props.setProperty(name, value); } } configNodeName = props.getProperty(GlobalIds.CONFIG_REALM); LOG.info("delConfig realm name [{}]", configNodeName); props.remove(GlobalIds.CONFIG_REALM); cfgMgr.delete(configNodeName, props); } catch (SecurityException se) { String warning = "deleteConfig [" + configNodeName + "] caught SecurityException=" + se; LOG.warn(warning); } } }
From source file:me.mast3rplan.phantombot.PhantomBot.java
public static void main(String[] args) throws IOException { /* List of properties that must exist. */ String requiredProperties[] = new String[] { "oauth", "channel", "owner", "user" }; String requiredPropertiesErrorMessage = ""; /* Properties configuration */ Properties startProperties = new Properties(); /* Indicates that the botlogin.txt file should be overwritten/created. */ Boolean changed = false;/* w w w .j a v a2 s . c o m*/ /* Print the user dir */ com.gmt2001.Console.out.println("The working directory is: " + System.getProperty("user.dir")); /* Load up the bot info from the bot login file */ try { if (new File("./botlogin.txt").exists()) { try { FileInputStream inputStream = new FileInputStream("botlogin.txt"); startProperties.load(inputStream); inputStream.close(); if (startProperties.getProperty("debugon", "false").equals("true")) { com.gmt2001.Console.out.println("Debug Mode Enabled via botlogin.txt"); PhantomBot.enableDebugging = true; } if (startProperties.getProperty("debuglog", "false").equals("true")) { com.gmt2001.Console.out.println("Debug Log Only Mode Enabled via botlogin.txt"); PhantomBot.enableDebugging = true; PhantomBot.enableDebuggingLogOnly = true; } if (startProperties.getProperty("reloadscripts", "false").equals("true")) { com.gmt2001.Console.out.println("Enabling Script Reloading"); PhantomBot.reloadScripts = true; } if (startProperties.getProperty("rhinodebugger", "false").equals("true")) { com.gmt2001.Console.out.println("Rhino Debugger will be launched if system supports it."); PhantomBot.enableRhinoDebugger = true; } } catch (IOException ex) { com.gmt2001.Console.err.printStackTrace(ex); } } else { /* Fill in the Properties object with some default values. Note that some values are left * unset to be caught in the upcoming logic to enforce settings. */ startProperties.setProperty("baseport", "25000"); startProperties.setProperty("usehttps", "false"); startProperties.setProperty("webenable", "true"); startProperties.setProperty("msglimit30", "18.75"); startProperties.setProperty("musicenable", "true"); startProperties.setProperty("whisperlimit60", "60.0"); } } catch (Exception ex) { com.gmt2001.Console.err.printStackTrace(ex); } /* Check to see if there's a webOauth set */ if (startProperties.getProperty("webauth") == null) { startProperties.setProperty("webauth", generateWebAuth()); com.gmt2001.Console.debug.println("New webauth key has been generated for botlogin.txt"); changed = true; } /* Check to see if there's a webOAuthRO set */ if (startProperties.getProperty("webauthro") == null) { startProperties.setProperty("webauthro", generateWebAuth()); com.gmt2001.Console.debug.println("New webauth read-only key has been generated for botlogin.txt"); changed = true; } /* Check to see if there's a panelUsername set */ if (startProperties.getProperty("paneluser") == null) { com.gmt2001.Console.debug.println( "No Panel Username, using default value of 'panel' for Control Panel and YouTube Player"); startProperties.setProperty("paneluser", "panel"); changed = true; } /* Check to see if there's a panelPassword set */ if (startProperties.getProperty("panelpassword") == null) { com.gmt2001.Console.debug.println( "No Panel Password, using default value of 'panel' for Control Panel and YouTube Player"); startProperties.setProperty("panelpassword", "panel"); changed = true; } /* Check to see if there's a youtubeOAuth set */ if (startProperties.getProperty("ytauth") == null) { startProperties.setProperty("ytauth", generateWebAuth()); com.gmt2001.Console.debug.println("New YouTube websocket key has been generated for botlogin.txt"); changed = true; } /* Check to see if there's a youtubeOAuthThro set */ if (startProperties.getProperty("ytauthro") == null) { startProperties.setProperty("ytauthro", generateWebAuth()); com.gmt2001.Console.debug .println("New YouTube read-only websocket key has been generated for botlogin.txt"); changed = true; } /* Make a new botlogin with the botName, oauth or channel is not found */ if (startProperties.getProperty("user") == null || startProperties.getProperty("oauth") == null || startProperties.getProperty("channel") == null) { try { com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print("Welcome to the PhantomBot setup process!\r\n"); com.gmt2001.Console.out .print("If you have any issues please report them on our forum or Tweet at us!\r\n"); com.gmt2001.Console.out.print("Forum: https://community.phantombot.tv/\r\n"); com.gmt2001.Console.out.print("Twitter: https://twitter.com/phantombotapp/\r\n"); com.gmt2001.Console.out.print("PhantomBot Knowledgebase: https://docs.phantombot.tv/\r\n"); com.gmt2001.Console.out.print("PhantomBot WebPanel: https://docs.phantombot.tv/kb/panel/\r\n"); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print("1. Please enter the bot's Twitch username: "); startProperties.setProperty("user", System.console().readLine().trim()); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out .print("2. You will now need a OAuth token for the bot to be able to chat.\r\n"); com.gmt2001.Console.out.print( "Please note, this OAuth token needs to be generated while you're logged in into the bot's Twitch account.\r\n"); com.gmt2001.Console.out.print( "If you're not logged in as the bot, please go to https://twitch.tv/ and login as the bot.\r\n"); com.gmt2001.Console.out.print("Get the bot's OAuth token here: https://twitchapps.com/tmi/\r\n"); com.gmt2001.Console.out.print("Please enter the bot's OAuth token: "); startProperties.setProperty("oauth", System.console().readLine().trim()); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print( "3. You will now need your channel OAuth token for the bot to be able to change your title and game.\r\n"); com.gmt2001.Console.out.print( "Please note, this OAuth token needs to be generated while you're logged in into your caster account.\r\n"); com.gmt2001.Console.out.print( "If you're not logged in as the caster, please go to https://twitch.tv/ and login as the caster.\r\n"); com.gmt2001.Console.out.print("Get the your OAuth token here: https://phantombot.tv/oauth/\r\n"); com.gmt2001.Console.out.print("Please enter your OAuth token: "); startProperties.setProperty("apioauth", System.console().readLine().trim()); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out .print("4. Please enter the name of the Twitch channel the bot should join: "); startProperties.setProperty("channel", System.console().readLine().trim()); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print("5. Please enter a custom username for the web panel: "); startProperties.setProperty("paneluser", System.console().readLine().trim()); com.gmt2001.Console.out.print("\r\n"); com.gmt2001.Console.out.print("6. Please enter a custom password for the web panel: "); startProperties.setProperty("panelpassword", System.console().readLine().trim()); changed = true; newSetup = true; } catch (NullPointerException ex) { com.gmt2001.Console.err.printStackTrace(ex); com.gmt2001.Console.out.println("[ERROR] Failed to setup PhantomBot. Now exiting..."); System.exit(0); } } /* Make sure the oauth has been set correctly */ if (startProperties.getProperty("oauth") != null) { if (!startProperties.getProperty("oauth").startsWith("oauth") && !startProperties.getProperty("oauth").isEmpty()) { startProperties.setProperty("oauth", "oauth:" + startProperties.getProperty("oauth")); changed = true; } } /* Make sure the apiOAuth has been set correctly */ if (startProperties.getProperty("apioauth") != null) { if (!startProperties.getProperty("apioauth").startsWith("oauth") && !startProperties.getProperty("apioauth").isEmpty()) { startProperties.setProperty("apioauth", "oauth:" + startProperties.getProperty("apioauth")); changed = true; } } /* Make sure the channelName does not have a # */ if (startProperties.getProperty("channel").startsWith("#")) { startProperties.setProperty("channel", startProperties.getProperty("channel").substring(1)); changed = true; } else if (startProperties.getProperty("channel").contains(".tv")) { startProperties.setProperty("channel", startProperties.getProperty("channel") .substring(startProperties.getProperty("channel").indexOf(".tv/") + 4).replaceAll("/", "")); changed = true; } /* Check for the owner after the channel check is done. */ if (startProperties.getProperty("owner") == null) { if (startProperties.getProperty("channel") != null) { if (!startProperties.getProperty("channel").isEmpty()) { startProperties.setProperty("owner", startProperties.getProperty("channel")); changed = true; } } } /* Iterate the properties and delete entries for anything that does not have a * value. */ for (String propertyKey : startProperties.stringPropertyNames()) { if (startProperties.getProperty(propertyKey).isEmpty()) { changed = true; startProperties.remove(propertyKey); } } /* * Check for required settings. */ for (String requiredProperty : requiredProperties) { if (startProperties.getProperty(requiredProperty) == null) { requiredPropertiesErrorMessage += requiredProperty + " "; } } if (!requiredPropertiesErrorMessage.isEmpty()) { com.gmt2001.Console.err.println(); com.gmt2001.Console.err.println("Missing Required Properties: " + requiredPropertiesErrorMessage); com.gmt2001.Console.err.println("Exiting PhantomBot"); System.exit(0); } /* Check to see if anything changed */ if (changed) { Properties outputProperties = new Properties() { @Override public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<>(super.keySet())); } }; try { try (FileOutputStream outputStream = new FileOutputStream("botlogin.txt")) { outputProperties.putAll(startProperties); outputProperties.store(outputStream, "PhantomBot Configuration File"); } } catch (IOException ex) { com.gmt2001.Console.err.printStackTrace(ex); } } /* Start PhantomBot */ PhantomBot.instance = new PhantomBot(startProperties); }
From source file:cz.alej.michalik.totp.client.OtpPanel.java
/** * Pid jeden panel se zznamem//from ww w . j a va2 s. c o m * * @param raw_data * Data z Properties * @param p * Properties * @param index * Index zznamu - pro vymazn */ public OtpPanel(String raw_data, final Properties p, final int index) { // Data jsou oddlena stednkem final String[] data = raw_data.split(";"); // this.setBackground(App.COLOR); this.setLayout(new GridBagLayout()); // Mkov rozloen prvk GridBagConstraints c = new GridBagConstraints(); this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100)); // Tla?tko pro zkoprovn hesla final JButton passPanel = new JButton(""); passPanel.setFont(passPanel.getFont().deriveFont(App.FONT_SIZE)); passPanel.setBackground(App.COLOR); // Zabere celou ku c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 100; this.add(passPanel, c); passPanel.setText(data[0]); // Tla?tko pro smazn JButton delete = new JButton("X"); try { String path = "/material-design-icons/action/drawable-xhdpi/ic_delete_black_24dp.png"; Image img = ImageIO.read(App.class.getResource(path)); delete.setIcon(new ImageIcon(img)); delete.setText(""); } catch (Exception e) { System.out.println("Icon not found"); } delete.setFont(delete.getFont().deriveFont(App.FONT_SIZE)); delete.setBackground(App.COLOR); // Zabere kousek vpravo c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.anchor = GridBagConstraints.EAST; this.add(delete, c); // Akce pro vytvoen a zkoprovn hesla do schrnky passPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Generuji kod pro " + data[1]); System.out.println(new Base32().decode(data[1].getBytes()).length); clip.set(new TOTP(new Base32().decode(data[1].getBytes())).toString()); System.out.printf("Kd pro %s je ve schrnce\n", data[0]); passPanel.setText("Zkoprovno"); // Zobraz zprvu na 1 vteinu int time = 1000; // Animace zobrazen zprvy po zkoprovn final Timer t = new Timer(time, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { passPanel.setText(data[0]); } }); t.start(); t.setRepeats(false); } }); // Akce pro smazn panelu a uloen zmn delete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.printf("Odstrann %s s indexem %d\n", data[0], index); p.remove(String.valueOf(index)); App.saveProperties(); App.loadProperties(); } }); }
From source file:org.soaplab.clients.BatchTestClient.java
/************************************************************************* * Call service as define in 'locator' (which also has an input * data for the service) and report results into a new entry in * 'reports'./* w ww . j a va2 s . co m*/ * * It also returns its own report. *************************************************************************/ private static Properties callService(MyLocator locator, List<Properties> reports) { Properties report = new Properties(); reports.add(report); String serviceName = locator.getServiceName(); String inputLine = locator.getInputLine(); report.setProperty(REPORT_SERVICE_NAME, serviceName); report.setProperty(REPORT_INPUT_LINE, inputLine); try { SoaplabBaseClient client = new SoaplabBaseClient(locator); // collect inputs from the input line BaseCmdLine cmd = null; if (StringUtils.isBlank(inputLine)) { cmd = new BaseCmdLine(new String[] {}, true); } else { cmd = new BaseCmdLine( new StrTokenizer(inputLine, StrMatcher.charSetMatcher(" \t\f"), StrMatcher.quoteMatcher()) .getTokenArray(), true); } SoaplabMap inputs = SoaplabMap .fromMap(InputUtils.collectInputs(cmd, SoaplabMap.toMaps(client.getInputSpec()))); // any unrecognized inputs on the command-line? if (cmd.params.length > 0) { StringBuilder buf = new StringBuilder(); buf.append("Unrecognized inputs: "); for (String arg : cmd.params) buf.append(arg + " "); report.setProperty(REPORT_ERROR_MESSAGE, buf.toString()); report.setProperty(REPORT_JOB_STATUS, "NOT STARTED"); return report; } // start service and wait for its completion String jobId = client.createAndRun(inputs); report.setProperty(REPORT_JOB_ID, jobId); client.waitFor(jobId); // save all info about just finished job String status = client.getStatus(jobId); report.setProperty(REPORT_JOB_STATUS, status); SoaplabMap times = client.getCharacteristics(jobId); Object elapsed = times.get(SoaplabConstants.TIME_ELAPSED); if (elapsed != null) { try { report.setProperty(REPORT_ELAPSED_TIME, DurationFormatUtils.formatDurationHMS(Long.decode(elapsed.toString()))); } catch (NumberFormatException e) { } } String lastEvent = client.getLastEvent(jobId); if (lastEvent != null) report.setProperty(REPORT_LAST_EVENT, lastEvent); if (!client.getLocator().getProtocol().equals(ClientConfig.PROTOCOL_AXIS1)) { // get result infos (about all available results) ByteArrayOutputStream bos = new ByteArrayOutputStream(); ResultUtils.formatResultInfo(SoaplabMap.toStringMaps(client.getResultsInfo(jobId)), new PrintStream(bos)); report.setProperty(REPORT_RESULTS_INFO, bos.toString()); } // get results (but ignore them - except the special ones) client.getResults(jobId); Map<String, Object> results = SoaplabMap.toMap(client.getSomeResults(jobId, new String[] { SoaplabConstants.RESULT_REPORT, SoaplabConstants.RESULT_DETAILED_STATUS })); for (Iterator<String> it = results.keySet().iterator(); it.hasNext();) { String resultName = it.next(); report.setProperty(resultName, results.get(resultName).toString()); } // clean the job if (!locator.isEnabledKeepResults()) { client.destroy(jobId); report.remove(REPORT_JOB_ID); } } catch (Throwable e) { reportError(report, e); } return report; }
From source file:org.esigate.extension.http.DNSTest.java
public void testInit() throws Exception { Properties properties = new Properties(); properties.put(Parameters.EXTENSIONS.getName(), "org.esigate.extension.http.DNS"); // Test one IP and one host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost/"); properties.put(DNS.REMOTE_IP.getName(), "127.0.0.1"); Driver driver = TestUtils.createMockDriver(properties, (HttpClientConnectionManager) null); DNS dns = new DNS(); // Test one IP and one host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost/"); properties.put(DNS.REMOTE_IP.getName(), "127.0.0.1"); dns.init(driver, properties);/* w ww .j a v a2s .co m*/ InetAddress[] inetAddresses = dns.getDnsResolver().resolve("myvirtualhost"); assertEquals(1, inetAddresses.length); assertEquals("127.0.0.1", inetAddresses[0].getHostAddress()); // Test one IP and two host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost1/,http://myvirtualhost2/"); properties.put(DNS.REMOTE_IP.getName(), "127.0.0.1"); dns = new DNS(); dns.init(driver, properties); inetAddresses = dns.getDnsResolver().resolve("myvirtualhost1"); assertEquals(1, inetAddresses.length); assertEquals("127.0.0.1", inetAddresses[0].getHostAddress()); inetAddresses = dns.getDnsResolver().resolve("myvirtualhost2"); assertEquals(1, inetAddresses.length); assertEquals("127.0.0.1", inetAddresses[0].getHostAddress()); // Test two IP and one host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost/"); properties.put(DNS.REMOTE_IP.getName(), "127.0.0.1,127.0.0.0"); dns = new DNS(); dns.init(driver, properties); inetAddresses = dns.getDnsResolver().resolve("myvirtualhost"); assertEquals(2, inetAddresses.length); List<String> ips = toIPs(inetAddresses); assertTrue("IP 127.0.0.1 should be resolved", ips.contains("127.0.0.1")); assertTrue("IP 127.0.0.0 should be resolved", ips.contains("127.0.0.0")); // Test two IP and two host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost1/,http://myvirtualhost2/"); properties.put(DNS.REMOTE_IP.getName(), "127.0.0.1,127.0.0.0"); dns = new DNS(); dns.init(driver, properties); inetAddresses = dns.getDnsResolver().resolve("myvirtualhost1"); assertEquals(2, inetAddresses.length); assertTrue("IP 127.0.0.1 should be resolved", ips.contains("127.0.0.1")); inetAddresses = dns.getDnsResolver().resolve("myvirtualhost2"); assertEquals(2, inetAddresses.length); assertTrue("IP 127.0.0.0 should be resolved", ips.contains("127.0.0.0")); // Test two IP and two host properties.put(Parameters.REMOTE_URL_BASE.getName(), "http://myvirtualhost1/,http://myvirtualhost2/"); properties.remove(DNS.REMOTE_IP.getName()); dns = new DNS(); dns.init(driver, properties); try { dns.getDnsResolver().resolve("myvirtualhost1"); fail("Should throw exception"); } catch (Exception e) { } }
From source file:org.apache.geode.distributed.internal.DistributionConfigImpl.java
public void close() { // Clear the extra stuff from System properties Properties props = System.getProperties(); props.remove(SECURITY_SYSTEM_PREFIX + SECURITY_PEER_AUTH_INIT); props.remove(SECURITY_SYSTEM_PREFIX + SECURITY_PEER_AUTHENTICATOR); Iterator iter = security.keySet().iterator(); while (iter.hasNext()) { props.remove(SECURITY_SYSTEM_PREFIX + (String) iter.next()); }//from w w w .ja v a 2 s. c o m System.setProperties(props); }
From source file:com.jaspersoft.jasperserver.api.metadata.olap.service.impl.OlapConnectionServiceImpl.java
public OlapConnection getOlapConnection(ExecutionContext context, OlapClientConnection conn) { Util.PropertyList propList = getOlapConnectProperties(context, conn); Properties props = new Properties(); String driverClass = null;// ww w. ja v a 2 s. c o m String urlPrefix = null; for (Pair<String, String> pair : propList) { if (pair.getKey().equals(OLAP4J_DRIVER)) { driverClass = pair.getValue(); } else if (pair.getKey().equals(OLAP4J_URL_PREFIX)) { urlPrefix = pair.getValue(); } else { props.put(pair.getKey(), pair.getValue()); } } //OLAP4J cache configuration if (getOLAP4J_CACHE() != null && getOLAP4J_CACHE().length() > 0) { props.put("Cache", getOLAP4J_CACHE()); props.put("Cache.Name", getOLAP4J_CACHE_NAME()); props.put("Cache.Mode", getOLAP4J_CACHE_MODE()); props.put("Cache.Timeout", getOLAP4J_CACHE_TIMEOUT()); props.put("Cache.Size", getOLAP4J_CACHE_SIZE()); } if (log.isDebugEnabled()) { StringBuilder sb = new StringBuilder(); sb.append("OlapConnectionProperties Full Set: "); for (Pair<String, String> pair : propList) { sb.append("key='" + pair.getKey() + "', val='" + pair.getValue() + "', "); } sb.append("\nOlapConnectionProperties Driver Set: "); for (Object key : props.keySet()) { sb.append("key='" + key + "', val='" + props.get(key) + "', "); } sb.append("\nDriver Class='" + (driverClass == null ? "NULL" : driverClass) + "'"); sb.append("\n urlPrefix='" + (urlPrefix == null ? "NULL" : urlPrefix) + "'"); log.debug(sb.toString()); } // load driver and Connection java.sql.Connection rConnection = null; try { jdbcDriverService.register(driverClass); rConnection = java.sql.DriverManager.getConnection(urlPrefix, props); } catch (MondrianException e) { String dataSource = (String) props.get(OLAP_CONNECTION_JNDI_DATA_SOURCE); if (ExceptionUtils.indexOfThrowable(e, NoInitialContextException.class) > 0 && dataSource != null) { Map<String, String> jdbcProperties = jndiFallbackResolver.getJdbcPropertiesMap(dataSource); try { // Remove JNDI reference. props.remove(OLAP_CONNECTION_JNDI_DATA_SOURCE); // Add JDBC url, username and password. props.put(OLAP_CONNECTION_JDBC, jdbcProperties.get(JndiFallbackResolver.JDBC_URL)); props.put(OLAP_CONNECTION_JDBC_USER, jdbcProperties.get(JndiFallbackResolver.JDBC_USERNAME)); props.put(OLAP_CONNECTION_JDBC_PASSWORD, jdbcProperties.get(JndiFallbackResolver.JDBC_PASSWORD)); rConnection = java.sql.DriverManager.getConnection(urlPrefix, props); } catch (Throwable t) { throw new JSException("Error getting connection from jndi fallback properties.", t); } } else { throw e; } } catch (Throwable t) { throw new JSException("error loading olap4j driver and getting Connection '" + driverClass + "'", t); } ((OlapConnection) rConnection).setLocale(LocaleContextHolder.getLocale()); return (OlapConnection) rConnection; }