List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.soaplab.clients.BatchTestClient.java
/************************************************************************* * * Entry point...//from w w w . jav a 2s. co m * *************************************************************************/ public static void main(String[] args) { try { BaseCmdLine cmd = getCmdLine(args, BatchTestClient.class); // service location and protocol parameters ServiceLocator mainLocator = InputUtils.getServiceLocator(cmd); // file(s) with the testing data (a list of tested // services and their inputs) String[] batchFiles = null; String batchFile = cmd.getParam("-batchfile"); if (batchFile != null) { // take it from the command-line batchFiles = new String[] { batchFile }; } else { // take it from the client configuration file batchFiles = ClientConfig.get().getStringArray(ClientConfig.PROP_BATCH_TEST_FILE); } if (batchFiles == null || batchFiles.length == 0) { log.error("A file with a list of service to test must be given. " + "Use '-batchfile' or a property '" + ClientConfig.PROP_BATCH_TEST_FILE + "'."); System.exit(1); } // other arguments boolean tableReport = (cmd.hasOption("-table") || ClientConfig.isEnabled(ClientConfig.PROP_BATCH_REPORT_TABLE, false)); boolean keepResults = (cmd.hasOption("-keep") || ClientConfig.isEnabled(ClientConfig.PROP_BATCH_KEEP_RESULTS, false)); int maxThreads = -1; String strMaxThreads = cmd.getParam("-maxthreads"); if (strMaxThreads == null) maxThreads = ClientConfig.getInt(ClientConfig.PROP_BATCH_MAX_THREADS, 25); else maxThreads = getInt(strMaxThreads); if (maxThreads < 0) maxThreads = 0; boolean oneByOne = (maxThreads == 1); // get a list of available services // (for validation purposes later) Set<String> services = new HashSet<String>(); for (String name : new SoaplabBaseClient(mainLocator).getAvailableAnalyses()) { services.add(name); } // loop and do it... List<Properties> reports = Collections.synchronizedList(new ArrayList<Properties>()); List<Thread> threads = Collections.synchronizedList(new ArrayList<Thread>()); int countNotAvailable = 0; title("Progress"); for (String file : batchFiles) { log.info("Using batch file " + file); // treat each batch file as a property configuration // file - together with a usual Soaplab Client // configuration file; this allows handling // substitutions of referenced properties, etc. CompositeConfiguration cfg = new CompositeConfiguration(); cfg.addConfiguration(ClientConfig.get()); cfg.addConfiguration(Config.get()); try { cfg.addConfiguration(new PropertiesConfiguration(file)); } catch (ConfigurationException e) { log.error("Loading batch file from '" + file + "' failed: " + e.getMessage()); continue; } // for (Iterator it = cfg.getKeys(); it.hasNext();) { String propertyName = (String) it.next(); if (!propertyName.startsWith(PREFIX_SERVICE_TO_TEST)) continue; String serviceName = StringUtils.removeStart(propertyName, PREFIX_SERVICE_TO_TEST); if (!services.contains(serviceName)) { // log.warn (serviceName + " is not available for testing"); countNotAvailable += 1; continue; } String[] inputs = cfg.getStringArray(propertyName); for (String input : inputs) { MyLocator locator = new MyLocator(serviceName, mainLocator); locator.enableKeepResults(keepResults); locator.setInputLine(input); if (oneByOne) { // sequential invocation qmsg(String.format("%-50s", "Running " + serviceName + "... ")); Properties report = callService(locator, reports); qmsgln("finished: " + report.getProperty(REPORT_JOB_STATUS)); } else { // do it in parallel startService(threads, locator, reports); if (maxThreads > 0) { // limit the number of threads // (just wait for some to finish) while (threads.size() >= maxThreads) { try { Thread.sleep(1000); } catch (Exception e) { } } } } } } } if (!oneByOne) { // wait for all the threads to finish while (threads.size() > 0) { try { Thread.sleep(1000); } catch (Exception e) { } } } msgln(""); // report all tests if (tableReport) createTableReport(reports); // report results int countSuccessful = 0; int countErrors = 0; for (Properties report : reports) { if (report.containsKey(REPORT_ERROR_MESSAGE)) { report.remove(REPORT_STACK_TRACE); countErrors += 1; createErrorReport(report); } else { String status = report.getProperty(REPORT_JOB_STATUS); if (SoaplabConstants.JOB_COMPLETED.equals(status)) { countSuccessful += 1; } else { countErrors += 1; createErrorReport(report); } } } // make a summary title("Summary"); msgln("Successfully: " + countSuccessful); msgln("Erroneously: " + countErrors); msgln("Not available: " + countNotAvailable); exit(0); } catch (Throwable e) { processErrorAndExit(e); } }
From source file:org.geoserver.security.impl.GroupAdminProperty.java
public static void del(Properties props) { props.remove(INSTANCE.getKey()); }
From source file:Main.java
public static boolean removeProperty(String filePath, String fileName, String propertyName) { try {// w w w .jav a2 s .c om Properties p = loadPropertyInstance(filePath, fileName); p.remove(propertyName); String comment = propertyName; return storePropertyInstance(filePath, fileName, p, comment); } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:org.apache.openejb.resource.jdbc.DataSourceFactory.java
public static void trimNotSupportedDataSourceProperties(Properties properties) { properties.remove("LoginTimeout"); }
From source file:Main.java
public static Connection connectToDatabase(String propertiesFileName) throws Exception { Properties dbProps = new Properties(); Properties dumpProps = new Properties(); dbProps.load(new FileInputStream(propertiesFileName)); dumpProps.load(new FileInputStream(propertiesFileName)); System.out.println("Database Properties"); dumpProps.remove("password"); dumpProps.list(System.out);/*from w w w. j a va 2 s. co m*/ System.out.println("Loading Driver"); Class.forName(dbProps.getProperty("dbDriver")); System.out.println("Connecting to Database..."); Connection con = DriverManager.getConnection(dbProps.getProperty("dbURL"), dbProps); System.out.println("Connected"); return con; }
From source file:org.eclipse.scada.utils.osgi.jdbc.pool.PoolConnectionAccessor.java
private static long getLong(final Properties paramProperties, final String name, final long defaultValue) { final Object value = paramProperties.remove(name); if (value instanceof Number) { logger.debug("Parameter value is numeric - {} -> {}", name, value); return ((Number) value).longValue(); }//from w w w. ja va2 s .co m try { if (value != null) { logger.debug("Parameter value is string - {} -> {}", name, value); return Long.parseLong(value.toString()); } } catch (final Exception e) { } final Long result = Long.getLong(name, defaultValue); logger.debug("Parameter value via system property - {} -> {}", name, result); return result; }
From source file:org.eclipse.scada.utils.osgi.jdbc.pool.PoolConnectionAccessor.java
private static String getString(final Properties paramProperties, final String name, final String defaultValue) { final Object value = paramProperties.remove(name); if (value instanceof String) { logger.debug("Parameter value is string - {} -> {}", name, value); return (String) value; }/*w ww . ja v a 2s.co m*/ final String result = System.getProperty(name, defaultValue); logger.debug("Parameter value via system property - {} -> {}", name, result); return result; }
From source file:org.eclipse.scada.utils.osgi.jdbc.pool.PoolConnectionAccessor.java
private static Integer getInteger(final Properties paramProperties, final String name, final Integer defaultValue) { final Object value = paramProperties.remove(name); if (value instanceof Number) { logger.debug("Parameter value is numeric - {} -> {}", name, value); return ((Number) value).intValue(); }// w w w . j a va 2s. c om try { if (value != null) { logger.debug("Parameter value is string - {} -> {}", name, value); return Integer.parseInt(value.toString()); } } catch (final Exception e) { } final Integer result = Integer.getInteger(name, defaultValue); logger.debug("Parameter value via system property - {} -> {}", name, result); return result; }
From source file:org.eclipse.scada.utils.osgi.jdbc.pool.PoolConnectionAccessor.java
private static boolean getBoolean(final Properties paramProperties, final String name, final boolean defaultValue) { final Object value = paramProperties.remove(name); if (value instanceof Boolean) { logger.debug("Parameter value is boolean - {} -> {}", name, value); return (Boolean) value; }/*from w w w.j a v a 2s . c o m*/ if (value instanceof Number) { logger.debug("Parameter value is numeric - {} -> {}", name, value); return ((Number) value).intValue() != 0; } try { if (value != null) { logger.debug("Parameter value is string - %s -> %s", name, value); return Boolean.parseBoolean(value.toString()); } } catch (final Exception e) { } final boolean result = Boolean.parseBoolean(System.getProperty(name, "" + defaultValue)); logger.debug("Parameter value via system property - {} -> {}", name, result); return result; }
From source file:Main.java
/** * Returns a value associated wither with one or more system properties, or found in the props map * @param system_props//from w w w . jav a 2 s . c o m * @param props List of properties read from the configuration file * @param prop_name The name of the property, will be removed from props if found * @param default_value Used to return a default value if the properties or system properties didn't have the value * @return The value, or null if not found */ public static String getProperty(String[] system_props, Properties props, String prop_name, String default_value) { String retval = null; if (props != null && prop_name != null) { retval = props.getProperty(prop_name); props.remove(prop_name); } String tmp, prop; if (retval == null && system_props != null) { for (int i = 0; i < system_props.length; i++) { prop = system_props[i]; if (prop != null) { try { tmp = System.getProperty(prop); if (tmp != null) return tmp; } catch (SecurityException ex) { } } } } if (retval == null) return default_value; return retval; }