List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key, String defaultValue);
From source file:com.microrisc.simply.network.udp.UDPNetworkLayerFactory.java
/** * @return type of UDP network layer /*from w w w. jav a2s.c om*/ */ private NetworkLayerType getNetworkLayerType(Configuration configuration) throws Exception { String networkLayerTypeStr = configuration.getString("networkLayer.type", ""); if (networkLayerTypeStr.equals("")) { throw new Exception("Network layer type not specified"); } // only for "udp" layer type if (!networkLayerTypeStr.equals("udp")) { throw new SimplyException("Network layer must be of 'udp' type."); } String remoteAddress = configuration.getString("networkLayer.type.udp.remoteaddress", ""); int remotePort = configuration.getInt("networkLayer.type.udp.remoteport", -1); if (remoteAddress.equals("")) { if (remotePort == -1) { return NetworkLayerType.CLIENT_MULTI; } } else { if (remotePort != -1) { return NetworkLayerType.CLIENT_SINGLE; } } throw new Exception("Must be specified both remote address and remote port, or" + "neither of the both"); }
From source file:com.zyeeda.framework.template.internal.FreemarkerTemplateServiceProvider.java
private void init(org.apache.commons.configuration.Configuration config) throws Exception { String repoRoot = config.getString(TEMPLATE_REPOSITORY_ROOT, DEFAULT_TEMPLATE_REPOSITORY_ROOT); logger.debug("template repository root = {}", repoRoot); this.repoRoot = new File(this.configSvc.getApplicationRoot(), repoRoot); if (!this.repoRoot.exists()) { throw new FileNotFoundException(this.repoRoot.toString()); }/*from w w w. j av a2 s . co m*/ this.dateFormat = config.getString(DATE_FORMAT, DEFAULT_DATE_FORMAT); this.timeFormat = config.getString(TIME_FORMAT, DEFAULT_TIME_FORMAT); this.datetimeFormat = config.getString(DATETIME_FORMAT, DEFAULT_DATETIME_FORMAT); logger.debug("template root = {}", this.repoRoot); logger.debug("date format = {}", this.dateFormat); logger.debug("time format = {}", this.timeFormat); logger.debug("datetime format = {}", this.dateFormat); }
From source file:com.knowbout.nlp.keywords.KeywordExtracter.java
/** * Attempts to clobber trailing punctuation, explicitley leaves the possessive ' * character in place if found.//www.j av a2 s . c om * * @param dirtyToken * @return */ private String cleanToken(String dirtyToken) { Configuration config = Config.getConfiguration(); String regex = config.getString("preprocessingRegex", null); if (regex != null) { if (log.isDebugEnabled()) { log.debug("preprocessing keyword " + dirtyToken + " with regex " + regex + " to get " + dirtyToken.replaceAll(regex, "")); } dirtyToken = dirtyToken.replaceAll(regex, ""); } int l = dirtyToken.length(); if (l > 1 && !Character.isLetterOrDigit(dirtyToken.charAt(l - 1))) { // But don't clobber the possessive suffix of a '. if (!dirtyToken.endsWith("'")) dirtyToken = dirtyToken.substring(0, l - 1); } return dirtyToken; // Which should now be a clean token... }
From source file:com.linkedin.pinot.minion.MinionStarter.java
public MinionStarter(String zkAddress, String helixClusterName, Configuration config) throws Exception { _helixClusterName = helixClusterName; _config = config;//from w ww . j av a2s .c om _instanceId = config.getString(CommonConstants.Helix.Instance.INSTANCE_ID_KEY, CommonConstants.Minion.INSTANCE_PREFIX + NetUtil.getHostAddress() + "_" + CommonConstants.Minion.DEFAULT_HELIX_PORT); _helixManager = new ZKHelixManager(_helixClusterName, _instanceId, InstanceType.PARTICIPANT, zkAddress); _taskExecutorRegistry = new TaskExecutorRegistry(); }
From source file:com.salesmanager.core.util.FileUtil.java
public static String getOrderDownloadFileUrl(Order order, Customer customer) throws Exception { Configuration conf = PropertiesUtil.getConfiguration(); MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); MerchantStore store = mservice.getMerchantStore(order.getMerchantId()); // ***build fileid*** StringBuffer urlconstruct = new StringBuffer(); StringBuffer downloadurl = new StringBuffer(); Calendar endDate = Calendar.getInstance(); endDate.add(Calendar.DATE, conf.getInt("core.product.file.downloadmaxdays", 2)); // add 2 days Date denddate = endDate.getTime(); String sedate = DateUtil.formatDate(denddate); // order id and, expiration date and language urlconstruct.append(order.getOrderId()).append("|").append("|").append(sedate); String lang = conf.getString("core.system.defaultlanguage", "en"); if (customer != null) { lang = customer.getCustomerLang(); }/*from w w w . ja va2 s . c o m*/ String file = EncryptionUtil.encrypt(EncryptionUtil.generatekey(SecurityConstants.idConstant), urlconstruct.toString()); downloadurl.append(ReferenceUtil.buildCheckoutUri(store)) .append(conf.getString("core.salesmanager.core.viewFilesAction")).append("?fileId=").append(file) .append("&lang=").append(lang); return downloadurl.toString(); }
From source file:com.linkedin.pinot.server.starter.helix.HelixServerStarter.java
private void setupHelixSystemProperties(Configuration conf) { System.setProperty("helixmanager.flappingTimeWindow", conf.getString(CommonConstants.Server.CONFIG_OF_HELIX_FLAPPING_TIMEWINDOW_MS, CommonConstants.Server.DEFAULT_HELIX_FLAPPING_TIMEWINDOW_MS)); }
From source file:com.appeligo.search.messenger.Messenger.java
public Messenger() { Configuration config = ConfigUtils.getMessageConfig(); mailHost = config.getString("smtpServer", "localhost"); password = config.getString("smtpSenderPassword", null); smtpUser = config.getString("smtpUser", null); debug = config.getBoolean("debugMailSender", true); port = config.getInt("smtpPort", 25); maxAttempts = config.getInt("maxMessageAttempts", 2); deleteMessagesOlderThanDays = config.getInt("deleteMessagesOlderThanDays", 7); }
From source file:com.github.nethad.clustermeister.provisioning.local.AddNodesCommand.java
@Override public void execute(CommandLineArguments arguments) { logger.info("AddNodesCommand local execute."); if (isArgumentsCountFalse(arguments)) { return;// w ww. j a v a2s . c om } Scanner scanner = arguments.asScanner(); int numberOfNodes = scanner.nextInt(); int numberOfCpusPerNode = scanner.nextInt(); final Configuration configuration = getNodeManager().getConfiguration(); Collection<File> artifactsToPreload = DependencyConfigurationUtil.getConfiguredDependencies(configuration); String jvmOptions = configuration.getString(ConfigurationKeys.JVM_OPTIONS_NODE, ConfigurationKeys.DEFAULT_JVM_OPTIONS_NODE); String nodeLogLevel = configuration.getString(ConfigurationKeys.LOGGING_NODE_LEVEL, ConfigurationKeys.DEFAULT_LOGGING_NODE_LEVEL); boolean nodeRemoteLogging = configuration.getBoolean(ConfigurationKeys.LOGGING_NODE_REMOTE, ConfigurationKeys.DEFAULT_LOGGING_NODE_REMOTE); int nodeRemoteLoggingPort = configuration.getInt(ConfigurationKeys.LOGGING_NODE_REMOTE_PORT, ConfigurationKeys.DEFAULT_LOGGING_NODE_REMOTE_PORT); final LocalNodeConfiguration nodeConfiguration = LocalNodeConfiguration.configurationFor(artifactsToPreload, jvmOptions, nodeLogLevel, nodeRemoteLogging, nodeRemoteLoggingPort, numberOfCpusPerNode); for (int i = 0; i < numberOfNodes; i++) { getNodeManager().addNode(nodeConfiguration); } }
From source file:com.splout.db.engine.RedisManager.java
@Override public void init(File dbFile, Configuration config, List<String> initStatements) throws EngineException { File dbFolder = dbFile.getParentFile(); String redisExecutable = config.getString(REDIS_EXECUTABLE_CONF, null); if (redisExecutable == null) { throw new EngineException( "A Redis executable path should be specified in configuration '" + REDIS_EXECUTABLE_CONF + "'", null);/*from w w w . j a v a 2 s . c o m*/ } if (!new File(redisExecutable).exists()) { throw new EngineException("The specified Redis executable doesn't exist: " + redisExecutable, null); } int basePort = config.getInt(BASE_PORT_CONF, DEFAULT_BASE_PORT); logger.info("Redis executable -> " + redisExecutable + "; base port -> " + basePort); File thisServer = new File(dbFolder, "redis-server"); File thisDataFile = new File(dbFolder, "dump.rdb"); File actualDataFile = dbFile; try { Runtime.getRuntime().exec( new String[] { "ln", "-s", actualDataFile.getAbsolutePath(), thisDataFile.getAbsolutePath() }) .waitFor(); FileUtils.copyFile(new File(redisExecutable), thisServer); thisServer.setExecutable(true); PortLock portLock = PortUtils.getNextAvailablePort(basePort); try { logger.info("Using port from port lock: " + portLock.getPort()); redisServer = new RedisServer(thisServer, portLock.getPort()); redisServer.start(); jedis = new Jedis("localhost", portLock.getPort()); } finally { portLock.release(); } } catch (InterruptedException e) { throw new EngineException(e); } catch (IOException e) { throw new EngineException(e); } }
From source file:edu.berkeley.sparrow.daemon.nodemonitor.NodeMonitor.java
public void initialize(Configuration conf, int nodeMonitorInternalPort) throws UnknownHostException { String mode = conf.getString(SparrowConf.DEPLYOMENT_MODE, "unspecified"); if (mode.equals("standalone")) { state = new StandaloneNodeMonitorState(); } else if (mode.equals("configbased")) { state = new ConfigNodeMonitorState(); } else {//from ww w.java 2s. c o m throw new RuntimeException("Unsupported deployment mode: " + mode); } try { state.initialize(conf); } catch (IOException e) { LOG.fatal("Error initializing node monitor state.", e); } int mem = Resources.getSystemMemoryMb(conf); LOG.info("Using memory allocation: " + mem); ipAddress = Network.getIPAddress(conf); int cores = Resources.getSystemCPUCount(conf); LOG.info("Using core allocation: " + cores); String task_scheduler_type = conf.getString(SparrowConf.NM_TASK_SCHEDULER_TYPE, "fifo"); if (task_scheduler_type.equals("round_robin")) { scheduler = new RoundRobinTaskScheduler(cores); } else if (task_scheduler_type.equals("fifo")) { scheduler = new FifoTaskScheduler(cores); } else if (task_scheduler_type.equals("priority")) { scheduler = new PriorityTaskScheduler(cores); } else { throw new RuntimeException("Unsupported task scheduler type: " + mode); } scheduler.initialize(conf, nodeMonitorInternalPort); taskLauncherService = new TaskLauncherService(); taskLauncherService.initialize(conf, scheduler, nodeMonitorInternalPort); }