List of usage examples for org.apache.commons.configuration Configuration getBoolean
Boolean getBoolean(String key, Boolean defaultValue);
From source file:com.litt.saap.core.web.listener.InitSystemListener.java
/** * ?./*from w ww.j a va 2 s. c om*/ */ public void contextInitialized(ServletContextEvent event) { super.contextInitialized(event); ServletContext application = event.getServletContext(); //HOME? Configuration config = ConfigManager.getInstance().getConfig(); if (config.isEmpty()) { logger.error("???"); throw new java.lang.RuntimeException("???"); } logger.info("?" + config.getString("system.version")); //homePath = props.getProperty("home.path"); String homePath = config.getString("home.path"); CoreConstants.IS_DEBUG = config.getBoolean("debug", false); SaapConstants.HOME_PATH = homePath; //???? logger.info("?" + homePath); File homeFile = new File(homePath); if (!homeFile.exists()) //??? { homeFile.mkdirs(); } //read license. // File licensePath = new File(homePath, "license"); // File licenseFile = new File(licensePath, "license.xml"); // File publicKeyFile = new File(licensePath, "license.key"); // try { // LicenseManager.reload(licenseFile.getPath(), publicKeyFile.getPath()); // } catch (LicenseException e) { // logger.error("Can't read license file.", e); // } String contextPath = application.getContextPath(); //???APPLICATION ISystemInfoService systemInfoService = BeanManager.getBean("systemInfoService", ISystemInfoService.class); SystemInfoVo systemInfoVo = systemInfoService.getSystemInfo(); systemInfoVo.setBaseUrl(config.getString("baseUrl") + contextPath); systemInfoVo.setHomePath(homePath); application.setAttribute(CoreConstants.APP_SYSTEMINFO, systemInfoVo); //servlet? }
From source file:com.appeligo.channelfeed.SendCaptions.java
@Override protected void openSources(Configuration provider) { int tunerCount = provider.getList("tuners.tuner[@deviceNumber]").size(); for (int j = 0; j < tunerCount; j++) { String deviceNumber = provider.getString("tuners.tuner(" + j + ")[@deviceNumber]"); String channel = provider.getString("tuners.tuner(" + j + ")[@channel]"); String callsign = provider.getString("tuners.tuner(" + j + ")[@callsign]"); boolean capturetv = provider.getBoolean("tuners.tuner(" + j + ")[@capturetv]", false); String framesize = provider.getString("tuners.tuner(" + j + ")[@framesize]"); int framerate = provider.getInt("tuners.tuner(" + j + ")[@framerate]", -1); boolean nocaptions = provider.getBoolean("tuners.tuner(" + j + ")[@nocaptions]", false); boolean xds = provider.getBoolean("tuners.tuner(" + j + ")[@xds]", false); boolean itv = provider.getBoolean("tuners.tuner(" + j + ")[@itv]", false); log.info("deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign + ", capturetv=" + capturetv + ", framesize=" + framesize + ", framerate=" + framerate + ", nocaptions=" + nocaptions + ", xds=" + xds + ", itv=" + itv); if (deviceNumber == null || channel == null || callsign == null) { log.error("Invalid configuration in: " + identifyMe()); log.error(" deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign); continue; }//from ww w . j ava 2 s. c om try { VideoDevice videoDevice = new VideoDevice(Integer.parseInt(deviceNumber), getFrequencyStandard()); videoDevice.setChannel(channel); if (capturetv) { TVThread tvThread = new TVThread( "Video record " + getLineupID() + ", channel " + channel + ", callsign " + callsign); tvThread.setEpgService(getEpgService()); tvThread.setLineupID(getLineupID()); tvThread.setCallsign(callsign); tvThread.setCcDocumentRoot(getCaptionDocumentRoot()); if (framesize != null && (framesize.trim().length() > 0)) { tvThread.setFrameSize(framesize); } if (framerate >= 0) { tvThread.setFrameRate(framerate); } tvThread.setVideoDevice(videoDevice); tvThread.start(); } if (!nocaptions) { VideoDeviceReaderThread captionThread = new VideoDeviceReaderThread( "Captions " + getLineupID() + ", channel " + channel + ", callsign " + callsign); Destinations destinations = setupDestinations(); destinations.setCallsign(callsign); destinations.setSendXDS(xds); destinations.setSendITV(itv); captionThread.setDestinations(destinations); captionThread.setVideoDevice(videoDevice); // important to set destination and it's callsign before video device...sorry captionThread.setEpgService(getEpgService()); destinations.connect(); captionThread.start(); } } catch (MalformedURLException e1) { log.error("Exception on a channel", e1); } catch (NumberFormatException e1) { log.error("Exception on a channel", e1); } catch (IOException e1) { log.error("Exception on a channel", e1); } catch (BadChannelException e1) { log.error("Exception on a channel", e1); } catch (Throwable e1) { log.error("Unexpected exception", e1); } } }
From source file:com.appeligo.channelfeed.CaptureApp.java
/** * @param args/* w ww .ja v a2 s.c o m*/ * @param defaultConfigFile * @throws ConfigurationException */ public CaptureApp(String[] args, String defaultConfigFile) { try { // Set up a simple configuration that logs on the console. PatternLayout pattern = new PatternLayout("%d{ISO8601} %-5p [%-c{1} - %t] - %m%n"); BasicConfigurator.configure(new ConsoleAppender(pattern)); configFile = defaultConfigFile; if (args.length > 0) { if (args.length == 2 && args[0].equals("-config")) { configFile = args[1]; } else { log.error("Usage: java " + getClass().getName() + " [-config <xmlfile>]"); throw new Error("Cannot continue"); } } config = new XMLConfiguration(configFile); configureLogging(config, pattern); String documentRoot = config.getString("documentRoot[@path]"); log.info("documentRoot = " + documentRoot); if (documentRoot == null) { log.error("Document root is not set (typically it is \"/var/flip.tv\")"); throw new Error("Cannot continue"); } else { documentRoot.trim(); if (!documentRoot.endsWith("/")) { documentRoot += "/"; } } captionDocumentRoot = documentRoot + "captiondb"; previewDocumentRoot = documentRoot + "previews"; String epgServer = config.getString("epgServer[@url]"); log.info("epgServer = " + epgServer); connectToEPG(epgServer); writing = config.getBoolean("writing", true); log.info("writing = " + writing); int destinationsCount = config.getList("destinations.destination[@url]").size(); destinationURLs = new String[destinationsCount]; destinationRaws = new boolean[destinationsCount]; for (int i = 0; i < destinationsCount; i++) { Configuration destination = config.subset("destinations.destination(" + i + ")"); destinationURLs[i] = destination.getString("[@url]"); destinationRaws[i] = destination.getBoolean("[@raw]", false); log.info("destination " + i + " = " + destinationURLs[i] + ", raw=" + destinationRaws[i]); } final String captionPort = config.getString("captionPort[@number]"); log.info("captionPort = " + captionPort); if (captionPort != null) { catchCaptions(captionPort); } int providerCount = config.getList("providers.provider.headend").size(); for (int i = 0; i < providerCount; i++) { Configuration provider = config.subset("providers.provider(" + i + ")"); headend = provider.getString("headend"); lineupDevice = provider.getString("lineupDevice"); frequencyStandard = FrequencyStandard.valueOf(provider.getString("frequencyStandard")); log.info(identifyMe()); if (headend == null || lineupDevice == null || frequencyStandard == null) { log.error("Invalid configuration in: " + identifyMe()); throw new Error("Cannot continue"); } openSources(provider); } } catch (ConfigurationException e) { log.error("Configuration error in file " + configFile, e); throw new Error("Cannot continue"); } catch (Throwable e) { log.error("Unexpected Exception", e); throw new Error("Cannot continue"); } }
From source file:com.caricah.iotracah.server.httpserver.netty.HttpServerImpl.java
/** * @param configuration Object carrying all configurable properties from file. * @throws UnRetriableException/*from www . j a v a 2s . c o m*/ * @link configure method supplies the configuration object carrying all the * properties parsed from the external properties file. */ public void configure(Configuration configuration) throws UnRetriableException { log.info(" configure : setting up our configurations."); int tcpPort = configuration.getInt(CONFIGURATION_SERVER_HTTP_TCP_PORT, CONFIGURATION_VALUE_DEFAULT_SERVER_HTTP_TCP_PORT); setTcpPort(tcpPort); int sslPort = configuration.getInt(CONFIGURATION_SERVER_HTTP_SSL_PORT, CONFIGURATION_VALUE_DEFAULT_SERVER_HTTP_SSL_PORT); setSslPort(sslPort); boolean sslEnabled = configuration.getBoolean(CONFIGURATION_SERVER_HTTP_SSL_IS_ENABLED, CONFIGURATION_VALUE_DEFAULT_SERVER_HTTP_SSL_IS_ENABLED); setSslEnabled(sslEnabled); if (isSslEnabled()) { setSslHandler(new SSLHandler(configuration)); } int connectionTimeout = configuration.getInt(CONFIGURATION_SERVER_HTTP_CONNECTION_TIMEOUT, CONFIGURATION_VALUE_DEFAULT_SERVER_HTTP_CONNECTION_TIMEOUT); setConnectionTimeout(connectionTimeout); }
From source file:es.udc.gii.common.eaf.algorithm.parallel.topology.migration.GridMigrationTopology.java
@Override protected void doConfigure(Configuration conf) { List listDimensions = conf.getList("Dimension[@count]"); this.nodesPerDimension = new int[listDimensions.size()]; this.dimIsPeriodic = new boolean[listDimensions.size()]; for (int i = 0; i < listDimensions.size(); i++) { nodesPerDimension[i] = conf.getInt("Dimension(" + i + ")[@count]"); dimIsPeriodic[i] = conf.getBoolean("Dimension(" + i + ")[@periodic]", false); }// www .j a v a2s . c om }
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 w w .ja v a2s .c o m*/ } 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:cross.io.InputDataFactory.java
@Override public void configure(final Configuration cfg) { if (cfg.containsKey("input.dataInfo")) { this.input = cfg.getStringArray("input.dataInfo"); }/*w w w .jav a 2 s . com*/ this.basedir = cfg.getString("input.basedir", ""); if (this.basedir.isEmpty() || this.basedir.equals(".")) { log.debug("Configuration has no value for input.basedir! {}", this.basedir); this.basedir = System.getProperty("user.dir"); } this.recurse = cfg.getBoolean("input.basedir.recurse", false); }
From source file:com.caricah.iotracah.server.mqttserver.netty.MqttServerImpl.java
/** * @param configuration Object carrying all configurable properties from file. * @throws UnRetriableException// w w w. j a va 2 s . c o m * @link configure method supplies the configuration object carrying all the * properties parsed from the external properties file. */ public void configure(Configuration configuration) throws UnRetriableException { log.info(" configure : setting up our configurations."); int tcpPort = configuration.getInt(CONFIGURATION_SERVER_MQTT_TCP_PORT, CONFIGURATION_VALUE_DEFAULT_SERVER_MQTT_TCP_PORT); setTcpPort(tcpPort); int sslPort = configuration.getInt(CONFIGURATION_SERVER_MQTT_SSL_PORT, CONFIGURATION_VALUE_DEFAULT_SERVER_MQTT_SSL_PORT); setSslPort(sslPort); boolean sslEnabled = configuration.getBoolean(CONFIGURATION_SERVER_MQTT_SSL_IS_ENABLED, CONFIGURATION_VALUE_DEFAULT_SERVER_MQTT_SSL_IS_ENABLED); setSslEnabled(sslEnabled); if (isSslEnabled()) { setSslHandler(new SSLHandler(configuration)); } int connectionTimeout = configuration.getInt(CONFIGURATION_SERVER_MQTT_CONNECTION_TIMEOUT, CONFIGURATION_VALUE_DEFAULT_SERVER_MQTT_CONNECTION_TIMEOUT); setConnectionTimeout(connectionTimeout); }
From source file:com.cisco.oss.foundation.message.RabbitMQMessageProducer.java
RabbitMQMessageProducer(String producerName) { super(producerName); Configuration subset = configuration.subset(producerName); queueName = subset.getString("queue.name"); if (StringUtils.isBlank(queueName)) { throw new QueueException( "Check Configuration - missing required queue name for producer: " + producerName); }/*from w w w . ja v a 2s . co m*/ //update expiration expiration = subset.getLong("queue.expiration", 1800000); groupId = subset.getString("queue.groupId", ""); isDurable = subset.getBoolean("queue.isDurable", true); isPersistent = subset.getBoolean("queue.isPersistent", true); try { Channel channel = RabbitMQMessagingFactory.getChannel(); channel.exchangeDeclare(queueName, "topic", isDurable, false, false, null); isInitialized.set(true); } catch (QueueException e) { LOGGER.debug("can't init producer as its underlying connection is not ready"); } catch (IOException e) { throw new QueueException("Can't create producer: " + e, e); } LOGGER.info("created rabbitmq producer: {} on exchange: {}", producerName, queueName); }
From source file:com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata.java
public IndexLoadingConfigMetadata(Configuration tableDataManagerConfig) { List<String> valueOfLoadingInvertedIndexConfig = tableDataManagerConfig .getList(KEY_OF_LOADING_INVERTED_INDEX, null); if ((valueOfLoadingInvertedIndexConfig != null) && (!valueOfLoadingInvertedIndexConfig.isEmpty())) { initLoadingInvertedIndexColumnSet(valueOfLoadingInvertedIndexConfig.toArray(new String[0])); }//from w ww.j a v a 2 s. com segmentVersionToLoad = tableDataManagerConfig.getString(KEY_OF_SEGMENT_FORMAT_VERSION, DEFAULT_SEGMENT_FORMAT); enableDefaultColumns = tableDataManagerConfig.getBoolean(KEY_OF_ENABLE_DEFAULT_COLUMNS, false); starTreeVersionToLoad = tableDataManagerConfig.getString(KEY_OF_STAR_TREE_FORMAT_VERSION, CommonConstants.Server.DEFAULT_STAR_TREE_FORMAT_VERSION); }