List of usage examples for org.apache.commons.configuration Configuration getStringArray
String[] getStringArray(String key);
From source file:net.przemkovv.sphinx.compiler.GXXCompiler.java
public GXXCompiler() throws InvalidCompilerException, CompilerNonAvailableException { tmp_dir_prefix = "gxx_"; try {/*from www.ja v a 2 s . c o m*/ Configuration config = new PropertiesConfiguration( "net/przemkovv/sphinx/compiler/gxx_compiler.properties"); String cmds[] = config.getStringArray("net.przemkovv.sphinx.compiler.gxx.cmd"); String prepare_envs[] = config.getStringArray("net.przemkovv.sphinx.compiler.gxx.prepare_env"); compiler_cmd = null; prepare_env_cmd = null; for (int i = 0; i < cmds.length; i++) { File temp_cmd = new File(cmds[i]); if (temp_cmd.exists() && temp_cmd.canExecute()) { compiler_cmd = temp_cmd; if (!prepare_envs[i].isEmpty()) { prepare_env_cmd = new File(prepare_envs[i]); } break; } } if (compiler_cmd == null) { throw new CompilerNonAvailableException("Compiler G++ is not available."); } CompilerInfo info = getCompilerInfo(); if (info != null) { logger.debug("Found g++ Compiler. Version: {}, Vendor: {}", info.version, info.vendor); } tmp_dir = System.getProperty("java.io.tmpdir"); logger.debug("Temporary directory: {}", tmp_dir); } catch (ConfigurationException ex) { throw new CompilerNonAvailableException("Couldn't find configuration for compiler compiler G++.", ex); } }
From source file:net.sf.webphotos.tools.Thumbnail.java
/** * Busca no arquivo de configurao, classe * {@link net.sf.webphotos.util.Config Config}, os tamnahos dos 4 thumbs e * seta esses valores nas variveis desta classe. Testa se o usurio setou * valores de marca d'gua e texto para o thumb4, caso afirmativo, busca os * valores necessrios no arquivo de configurao. *//*from w w w . ja v a2s . com*/ private static void inicializar() { // le as configuraes do usurio Configuration c = Util.getConfig(); // tamanhos de thumbnails t1 = c.getInt("thumbnail1"); t2 = c.getInt("thumbnail2"); t3 = c.getInt("thumbnail3"); t4 = c.getInt("thumbnail4"); // usuario setou marca d'agua para thumbnail 4 ? // TODO: melhorar teste para captao destes parametros try { marcadagua = c.getString("marcadagua"); mdPosicao = c.getInt("marcadagua.posicao"); mdMargem = c.getInt("marcadagua.margem"); mdTransparencia = c.getInt("marcadagua.transparencia"); } catch (Exception ex) { ex.printStackTrace(Util.err); } // usurio setou texto para o thumbnail 4 ? try { texto = c.getString("texto"); txPosicao = c.getInt("texto.posicao"); txMargem = c.getInt("texto.margem"); txTamanho = c.getInt("texto.tamanho"); txEstilo = c.getInt("texto.estilo"); txFamilia = c.getString("texto.familia"); String[] aux = c.getStringArray("texto.corFrente"); txCorFrente = new Color(Integer.parseInt(aux[0]), Integer.parseInt(aux[1]), Integer.parseInt(aux[2])); aux = c.getStringArray("texto.corFundo"); txCorFundo = new Color(Integer.parseInt(aux[0]), Integer.parseInt(aux[1]), Integer.parseInt(aux[2])); } catch (Exception ex) { ex.printStackTrace(Util.err); } }
From source file:com.nesscomputing.service.discovery.client.DiscoveryClientModule.java
@Provides @Singleton//from w ww . j av a 2s .c o m @Named(ZOOKEEPER_CONNECT_NAME) Map<Integer, InetSocketAddress> getZookeeperServers(final Config config, final DiscoveryClientConfig clientConfig) { Map<Integer, InetSocketAddress> results = Maps.newHashMap(); if (!clientConfig.isEnabled()) { LOG.warn("Service Discovery is administratively disabled."); } else { final Configuration zookeeperConfig = config.getConfiguration("ness.zookeeper"); // This can be explicitly given to support the "Three servers, one host" configuration. final String[] servers = zookeeperConfig.getStringArray("clientConnect"); if (ArrayUtils.isNotEmpty(servers)) { LOG.debug("Found explicit 'ness.zookeeper.clientConnect' string (%s)", StringUtils.join(servers, ",")); int serverId = 1; for (String server : servers) { final String parts[] = StringUtils.split(server, ":"); InetSocketAddress serverAddress = new InetSocketAddress(parts[0], Integer.parseInt(parts[1])); results.put(serverId++, serverAddress); } } else { LOG.debug("Building connectString from server configuration."); final int clientPort = zookeeperConfig.getInt("clientPort"); LOG.debug("ness.zookeeper.clientPort is %d", clientPort); for (final Iterator<?> it = zookeeperConfig.getKeys("server"); it.hasNext();) { final String key = it.next().toString(); final String[] keyElements = StringUtils.split(key, "."); final String value = zookeeperConfig.getString(key); final Integer serverId = Integer.parseInt(keyElements[keyElements.length - 1]); final String parts[] = StringUtils.split(value, ":"); InetSocketAddress serverAddress = new InetSocketAddress(parts[0], clientPort); results.put(serverId, serverAddress); LOG.debug("Server # %d : %s", serverId, serverAddress); } // If there are less than two servers, this is running in standalone mode. In that case, // use the clientAddress, because that is what the server will be using. if (results.size() < 2) { LOG.info("Found less than two servers, falling back to clientPortAddress/clientPort!"); final String clientAddress = zookeeperConfig.getString("clientPortAddress"); Preconditions.checkState(clientAddress != null, "Client address must not be null!"); final InetSocketAddress serverAddress = new InetSocketAddress(clientAddress, clientPort); LOG.debug("Server: %s", serverAddress); results = ImmutableMap.of(1, serverAddress); } } if (LOG.isDebugEnabled()) { for (Map.Entry<Integer, InetSocketAddress> entry : results.entrySet()) { LOG.debug("Server # %d : %s", entry.getKey(), entry.getValue()); } } } return results; }
From source file:com.appeligo.search.entity.Message.java
/** * Will definitely need some localization at some point. * @param type/* www. j a v a 2s.c o m*/ * @param context * @throws MessageContextException */ public void createContent(String type, Map<String, String> context) throws MessageContextException { Configuration config = ConfigUtils.getMessageConfig(); String subject = config.getString(type + ".subject", "No subject"); String[] bodyComponents = config.getStringArray(type + ".body"); StringBuilder sb = new StringBuilder(); for (String bodyComponent : bodyComponents) { if (sb.length() != 0) { sb.append(", "); } sb.append(bodyComponent); } String body = sb.toString(); String mimeType = config.getString(type + ".mimeType", "text/plain"); this.setMimeType(mimeType); subject = macroReplacement(subject, context); body = macroReplacement(body, context); if (log.isDebugEnabled()) { log.debug("Preparing message from: " + subject + ":" + body + ":" + mimeType); } this.setSubject(subject); this.setBody(body); this.setFrom(config.getString(type + ".from", this.getFrom())); }
From source file:cz.cas.lib.proarc.common.process.GenericExternalProcess.java
@Override public void run() { Configuration run = conf.subset("run"); String[] ifNotExists = run.getStringArray("if.notExists"); for (String ifNotExist : ifNotExists) { String path = interpolateParameters(ifNotExist, parameters.getMap()); File file = new File(path); if (file.exists()) { skippedProcess = true;/*from w w w . j av a2s . co m*/ break; } } if (!skippedProcess) { super.run(); } processResult = ProcessResult.getResultParameters(conf, parameters.getMap(), isSkippedProcess(), getExitCode(), getFullOutput()); }
From source file:de.nec.nle.siafu.model.DiscreteOverlay.java
/** * Create a discrete overlay using the thresholds int he configuration * object./*from w w w.j a v a 2 s.co m*/ * * @param name * the name of the overlay * @param is * the InputStream with the image that represents the values * @param simulationConfig * the configuration file where the threshold details are given */ public DiscreteOverlay(final String name, final InputStream is, final Configuration simulationConfig) { super(name, is); // A tree to sort the thresholds TreeMap<Integer, String> intervals = new TreeMap<Integer, String>(); // Find out how many thresholds we have String[] property; try { property = simulationConfig.getStringArray("overlays." + name + ".threshold[@tag]"); if (property.length == 0) throw new ConfigurationRuntimeException(); } catch (ConfigurationRuntimeException e) { throw new RuntimeException("You forgot the description of " + name + " in the config file"); } thresholds = new int[property.length]; tags = new String[property.length]; // Read the thresholds for (int i = 0; i < property.length; i++) { String tag = simulationConfig.getString("overlays." + name + ".threshold(" + i + ")[@tag]"); int pixelValue = simulationConfig.getInt("overlays." + name + ".threshold(" + i + ")[@pixelvalue]"); intervals.put(pixelValue, tag); } // Store the sorted thresholds int i = 0; for (int key : intervals.keySet()) { thresholds[i] = key; tags[i] = intervals.get(key); i++; } }
From source file:io.wcm.caravan.io.http.impl.CaravanHttpServiceConfig.java
/** * Checks if protocols are defined in the ribbon "listOfServers" properties, which is not supported by ribbon itself. * If this is the case, remove them and set our custom "http.protocol" property instead to the protocol, if * it is set to "auto".// w w w . j av a 2s. com */ private void applyRibbonHostsProcotol(String serviceId) { Configuration archaiusConfig = ArchaiusConfig.getConfiguration(); String[] listOfServers = archaiusConfig.getStringArray(serviceId + RIBBON_PARAM_LISTOFSERVERS); String protocolForAllServers = archaiusConfig.getString(serviceId + HTTP_PARAM_PROTOCOL); // get protocols defined in servers Set<String> protocolsFromListOfServers = Arrays.stream(listOfServers) .filter(server -> StringUtils.contains(server, "://")) .map(server -> StringUtils.substringBefore(server, "://")).collect(Collectors.toSet()); // skip further processing of no protocols defined if (protocolsFromListOfServers.isEmpty()) { return; } // ensure that only one protocol is defined. if not use the first one and write a warning to the log files. String protocol = new TreeSet<String>(protocolsFromListOfServers).iterator().next(); if (protocolsFromListOfServers.size() > 1) { log.warn("Different protocols are defined for property {}: {}. Only protocol '{}' is used.", RIBBON_HOSTS_PROPERTY, StringUtils.join(listOfServers, LIST_SEPARATOR), protocol); } // if http protocol is not set to "auto" write a warning as well, because protocol is defined in server list as well if (!(StringUtils.equals(protocolForAllServers, RequestUtil.PROTOCOL_AUTO) || StringUtils.equals(protocolForAllServers, protocol))) { log.warn( "Protocol '{}' is defined for property {}: {}, but an other protocol is defined in the server list: {}. Only protocol '{}' is used.", protocolForAllServers, PROTOCOL_PROPERTY, StringUtils.join(listOfServers, LIST_SEPARATOR), protocol); } // remove protocol from list of servers and store default protocol List<String> listOfServersWithoutProtocol = Arrays.stream(listOfServers) .map(server -> StringUtils.substringAfter(server, "://")).collect(Collectors.toList()); archaiusConfig.setProperty(serviceId + RIBBON_PARAM_LISTOFSERVERS, StringUtils.join(listOfServersWithoutProtocol, LIST_SEPARATOR)); archaiusConfig.setProperty(serviceId + HTTP_PARAM_PROTOCOL, protocol); }
From source file:cz.cas.lib.proarc.common.export.desa.DesaServices.java
private List<DesaConfiguration> readConfigurations(Configuration config) { ArrayList<DesaConfiguration> configs = new ArrayList<DesaConfiguration>(); for (String serviceId : config.getStringArray(PROPERTY_DESASERVICES)) { configs.add(readConfiguration(config, serviceId)); }/*from w w w . j ava2s . c om*/ return configs; }
From source file:cross.ObjectFactory.java
@Override public void configure(final Configuration cfg) { this.cfg = cfg; String[] contextLocations = null; if (this.cfg.containsKey(CONTEXT_LOCATION_KEY)) { log.debug("Using user-defined location: {}", (Object[]) this.cfg.getStringArray(CONTEXT_LOCATION_KEY)); contextLocations = cfg.getStringArray(CONTEXT_LOCATION_KEY); }/*from w w w.j a v a2s .c o m*/ if (contextLocations == null) { log.debug("No pipeline configuration found! Please define! Example: -c cfg/pipelines/chroma.mpl"); return; } log.debug("Using context locations: {}", Arrays.toString(contextLocations)); try { if (cfg.containsKey("maltcms.home")) { File f = new File(new File(cfg.getString("maltcms.home")), "cfg/pipelines/xml/workflowDefaults.xml"); if (f.exists()) { log.info("Using workflow defaults at: {}", f); cfg.setProperty("cross.applicationContext.workflowDefaults", cfg.getString("cross.applicationContext.workflowDefaults.file")); } } else { log.info("Using workflow defaults from classpath."); } String[] defaultLocations = cfg.getStringArray("cross.applicationContext.defaultLocations"); log.debug("Using default context locations: {}", Arrays.toString(defaultLocations)); LinkedList<String> applicationContextLocations = new LinkedList<>(Arrays.asList(defaultLocations)); applicationContextLocations.addAll(Arrays.asList(contextLocations)); context = new DefaultApplicationContextFactory(applicationContextLocations, this.cfg) .createApplicationContext(); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:dk.itst.oiosaml.sp.develmode.DevelModeImpl.java
private Map<String, String[]> getAttributes(String user, Configuration conf) { String prefix = "oiosaml-sp.develmode." + user + "."; Map<String, String[]> attributes = new HashMap<String, String[]>(); Iterator<?> i = conf.getKeys(); while (i.hasNext()) { String key = (String) i.next(); if (key.startsWith(prefix)) { String attr = key.substring(prefix.length()); String[] value = conf.getStringArray(key); attributes.put(attr, value); }/* w w w .jav a 2 s . c o m*/ } return attributes; }