List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:com.jff.searchapicluster.server.mina.Server.java
public static void main(String[] args) throws Throwable { org.apache.commons.configuration.Configuration config = new PropertiesConfiguration("settings.txt"); int serverPort = config.getInt("listenPort"); NioSocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("com/jff/searchapicluster/core/mina/codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory())); acceptor.getFilterChain().addLast("logger", new LoggingFilter()); acceptor.setHandler(new ServerSessionHandler()); acceptor.bind(new InetSocketAddress(serverPort)); System.out.println("Listening on port " + serverPort); System.out.println("Please enter filename"); // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { String filepath = br.readLine(); filepath = "/Users/admin/repos/study_repos/kurs_sp/search_api_cluster/SearchApiClusterServer/task.json"; File file = new File(filepath); Logger.d(LOG_TAG, file.getAbsolutePath()); if (file.exists() && file.isFile()) { Gson gson = new Gson(); SearchTask taskMessage = gson.fromJson(new FileReader(file), SearchTask.class); ServerManager serverManager = ServerManager.getInstance(); Logger.d(LOG_TAG, taskMessage.toString()); serverManager.startProcessTask(taskMessage); } else {//w ww. j a va2s .c o m Logger.d(LOG_TAG, filepath + "not found"); } } }
From source file:com.discursive.jccook.configuration.AdditionalXmlConfigurationExample.java
public static void main(String[] args) throws Exception { AdditionalXmlConfigurationExample example = new AdditionalXmlConfigurationExample(); ConfigurationFactory factory = new ConfigurationFactory(); URL configURL = example.getClass().getResource("additional-xml-configuration.xml"); factory.setConfigurationURL(configURL); Configuration config = factory.getConfiguration(); List startCriteria = config.getList("start-criteria.criteria"); System.out.println("Start Criteria: " + startCriteria); int horsepower = config.getInt("horsepower"); System.out.println("Horsepower: " + horsepower); }
From source file:com.discursive.jccook.configuration.ConfigurationExample.java
public static void main(String[] args) throws Exception { ConfigurationExample example = new ConfigurationExample(); ConfigurationFactory factory = new ConfigurationFactory(); URL configURL = example.getClass().getResource("configuration.xml"); factory.setConfigurationURL(configURL); Configuration config = factory.getConfiguration(); System.out.println("Timeout: " + config.getFloat("timeout")); System.out.println("Region: " + config.getString("region")); System.out.println("Name: " + config.getString("name")); System.out.println("Speed: " + config.getInt("speed")); }
From source file:com.discursive.jccook.configuration.XmlConfigurationExample.java
public static void main(String[] args) throws Exception { String resource = "com/discursive/jccook/configuration/global.xml"; Configuration config = new XMLConfiguration(resource); /* /*from ww w.j ava2 s. com*/ * ======================================================================== * * Copyright 2005 Tim O'Brien. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ======================================================================== */ List startCriteria = config.getList("start-criteria.criteria"); int horsepower = config.getInt("horsepower"); }
From source file:com.manydesigns.elements.configuration.CommonsConfigurationFunctions.java
public static int getInt(Configuration configuration, String key) { return configuration.getInt(key); }
From source file:edu.usc.pgroup.floe.coordinator.CoordinatorService.java
/** * starts the server.//w ww . j ava 2 s. c om */ private static void startThriftServer() { //Start the server LOGGER.info("Starting thrift server."); try { Configuration config = FloeConfig.getConfig(); //Transport int port = config.getInt(ConfigProperties.COORDINATOR_PORT); LOGGER.info("Listening on port: " + port); TNonblockingServerTransport serverSocket = new TNonblockingServerSocket(port); //Processor TProcessor processor = new TCoordinator.Processor(new CoordinatorHandler()); //Arguments THsHaServer.Args args = new THsHaServer.Args(serverSocket); args.workerThreads(config.getInt(ConfigProperties.COORDINATOR_SERVICE_THREAD_COUNT)); args.processor(processor); //Server TServer server = new THsHaServer(args); //Serve server.serve(); } catch (Exception e) { LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); } }
From source file:com.cisco.oss.foundation.monitoring.Utility.java
static String getServiceURL(Configuration configuration, MonitoringMXBean exposedObject) { if (exposedObject == null) { return null; }//from ww w. j a va 2s. com String serviceURL = "service:jmx:rmi://" + IpUtils.getIpAddress() + ":" + configuration.getInt(FoundationMonitoringConstants.EXPORTED_PORT) + "/jndi/rmi://" + IpUtils.getIpAddress() + ":" + configuration.getInt(FoundationMonitoringConstants.MX_PORT) + "/jmxrmi/" + ComponentInfo.INSTANCE.getName(); if ((ComponentInfo.INSTANCE.getInstance() != null) && (!ComponentInfo.INSTANCE.getInstance().trim().equals(""))) { serviceURL = serviceURL + ComponentInfo.INSTANCE.getInstance(); } return serviceURL; }
From source file:com.trivago.mail.pigeon.queue.ConnectionPool.java
public static Connection getConnection() { if (connection == null) { ConnectionFactory factory = new ConnectionFactory(); Configuration configuration = settings.getConfiguration(); factory.setUsername(configuration.getString("rabbit.username")); factory.setPassword(configuration.getString("rabbit.password")); factory.setVirtualHost(configuration.getString("rabbit.vhost")); factory.setHost(configuration.getString("rabbit.hostname")); factory.setPort(configuration.getInt("rabbit.port")); try {/*from www . j a v a 2 s. co m*/ connection = factory.newConnection(); } catch (IOException e) { log.error(e); throw new RuntimeException(e); } } return connection; }
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. *//* w w w.ja va2 s .c o m*/ 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.springrts.springls.CmdLineArgs.java
private static Options createOptions() { Configuration defaults = ServerConfiguration.getDefaults(); Options options = new Options(); Option help = new Option(null, "help", false, "Print this help message."); options.addOption(help);//from w ww . j ava2 s .c o m Option port = new Option("p", "port", true, String.format("The main (TCP) port number to host on [1, 65535]." + " The default is %d.", defaults.getInt(ServerConfiguration.PORT))); // possible types: // * File.class // * Number.class // * Class.class // * Object.class // * Url.class port.setType(Number.class); port.setArgName("port-number"); options.addOption(port); Option statistics = new Option(null, "statistics", false, "Whether to create and save statistics to disc on predefined" + " intervals."); options.addOption(statistics); Option natPort = new Option("n", "nat-port", true, String.format( "The (UDP) port number to host the NAT traversal techniques" + " help service on [1, 65535], which lets clients detect their" + " source port, for example when using \"hole punching\"." + " The default is %d.", defaults.getInt(ServerConfiguration.NAT_PORT))); port.setType(Number.class); natPort.setArgName("NAT-port-number"); options.addOption(natPort); Option logMain = new Option(null, "log-main", false, String.format("Whether to log all conversations from channel #main to \"%s\"", Channel.createDefaultActivityLogFilePath("main").getPath())); options.addOption(logMain); Option lanAdmin = new Option(null, "lan-admin", true, String.format( "The LAN mode admin account. Use this account to administer" + " your LAN server. The default is \"%s\", with password \"%s\".", defaults.getString(ServerConfiguration.LAN_ADMIN_USERNAME), defaults.getString(ServerConfiguration.LAN_ADMIN_PASSWORD))); lanAdmin.setArgName("username"); options.addOption(lanAdmin); Option loadArgs = new Option(null, "load-args", true, "Will read command-line arguments from the specified file." + " You can freely combine actual command-line arguments with" + " the ones from the file. If duplicate args are specified," + " the last one will prevail."); loadArgs.setArgName("filename"); port.setType(File.class); options.addOption(loadArgs); Option springVersion = new Option(null, "spring-version", true, "Will set the latest Spring version to this string." + " The default is \"*\". This is used to tell clients which" + " version is the latest one, so that they know when to" + " update."); springVersion.setArgName("version"); options.addOption(springVersion); Option useStorageDb = new Option(null, "database", false, "Use a DB for user accounts and ban entries." + " This disables \"LAN mode\"."); options.addOption(useStorageDb); Option useStorageFile = new Option(null, "file-storage", false, "Use the (deprecated) accounts.txt for user accounts." + " This disables \"LAN mode\"."); options.addOption(useStorageFile); OptionGroup storageOG = new OptionGroup(); storageOG.addOption(useStorageDb); storageOG.addOption(useStorageFile); options.addOptionGroup(storageOG); return options; }