Example usage for org.apache.commons.configuration Configuration getBoolean

List of usage examples for org.apache.commons.configuration Configuration getBoolean

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getBoolean.

Prototype

boolean getBoolean(String key);

Source Link

Document

Get a boolean associated with the given configuration key.

Usage

From source file:org.mobicents.servlet.restcomm.sms.SmsService.java

public SmsService(final ActorSystem system, final Configuration configuration, final SipFactory factory,
        final DaoManager storage, final ServletContext servletContext) {
    super();/*from  www . java 2 s .  c  o m*/
    this.system = system;
    this.configuration = configuration;
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.servletConfig = (ServletConfig) configuration.getProperty(ServletConfig.class.getName());
    this.sipFactory = factory;
    this.storage = storage;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    // final Configuration runtime = configuration.subset("runtime-settings");
    // TODO this.useTo = runtime.getBoolean("use-to");
    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);
}

From source file:org.mobicents.servlet.restcomm.telephony.CallManager.java

public CallManager(final Configuration configuration, final ServletContext context, final ActorSystem system,
        final MediaServerControllerFactory msControllerFactory, final ActorRef conferences,
        final ActorRef bridges, final ActorRef sms, final SipFactory factory, final DaoManager storage) {
    super();//from   w  w  w .  j  av a  2 s.  c o m
    this.system = system;
    this.configuration = configuration;
    this.context = context;
    this.msControllerFactory = msControllerFactory;
    this.conferences = conferences;
    this.bridges = bridges;
    this.sms = sms;
    this.sipFactory = factory;
    this.storage = storage;
    final Configuration runtime = configuration.subset("runtime-settings");
    final Configuration outboundProxyConfig = runtime.subset("outbound-proxy");
    SipURI outboundIntf = outboundInterface("udp");
    if (outboundIntf != null) {
        myHostIp = ((SipURI) outboundIntf).getHost().toString();
    } else {
        String errMsg = "SipURI outboundIntf is null";
        sendNotification(errMsg, 14001, "error", false);

        if (context == null)
            errMsg = "SipServlet context is null";
        sendNotification(errMsg, 14002, "error", false);
    }
    Configuration mediaConf = configuration.subset("media-server-manager");
    mediaExternalIp = mediaConf.getString("mgcp-server.external-address");
    proxyIp = runtime.subset("telestax-proxy").getString("uri").replaceAll("http://", "").replaceAll(":2080",
            "");

    if (mediaExternalIp == null || mediaExternalIp.isEmpty())
        mediaExternalIp = myHostIp;

    if (proxyIp == null || proxyIp.isEmpty())
        proxyIp = myHostIp;

    this.useTo = runtime.getBoolean("use-to");
    this.authenticateUsers = runtime.getBoolean("authenticate");

    this.primaryProxyUri = outboundProxyConfig.getString("outbound-proxy-uri");
    this.primaryProxyUsername = outboundProxyConfig.getString("outbound-proxy-user");
    this.primaryProxyPassword = outboundProxyConfig.getString("outbound-proxy-password");

    this.fallBackProxyUri = outboundProxyConfig.getString("fallback-outbound-proxy-uri");
    this.fallBackProxyUsername = outboundProxyConfig.getString("fallback-outbound-proxy-user");
    this.fallBackProxyPassword = outboundProxyConfig.getString("fallback-outbound-proxy-password");

    this.activeProxy = primaryProxyUri;
    this.activeProxyUsername = primaryProxyUsername;
    this.activeProxyPassword = primaryProxyPassword;

    numberOfFailedCalls = new AtomicInteger();
    numberOfFailedCalls.set(0);
    useFallbackProxy = new AtomicBoolean();
    useFallbackProxy.set(false);

    allowFallback = outboundProxyConfig.getBoolean("allow-fallback", false);

    maxNumberOfFailedCalls = outboundProxyConfig.getInt("max-failed-calls", 20);

    allowFallbackToPrimary = outboundProxyConfig.getBoolean("allow-fallback-to-primary", false);

    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);

    //Monitoring Service
    this.monitoring = (ActorRef) context.getAttribute(MonitoringService.class.getName());
}

From source file:org.mobicents.servlet.restcomm.telephony.ua.UserAgentManager.java

public UserAgentManager(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();/*from   w  w  w  . ja v a 2  s .co  m*/
    // this.configuration = configuration;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.factory = factory;
    this.storage = storage;
    pingInterval = runtime.getInt("ping-interval", 60);
    getContext().setReceiveTimeout(Duration.create(pingInterval, TimeUnit.SECONDS));
    logger.info("About to run firstTimeCleanup()");
    firstTimeCleanup();
}

From source file:org.mot.common.tools.Collective2Connector.java

public Collective2Connector() {

    // First make sure to get the config directory
    String confDir = pf.getConfigDir();

    try {//from   w  ww.  j av a 2 s  .  c  o  m
        // Read in the properties
        Configuration props = new PropertiesConfiguration(confDir + "/collective2.properties");

        // Overwrite with configuration file settings
        baseUrl = props.getString("collective2connector.baseURL",
                "http://www.collective2.com/cgi-perl/signal.mpl?");
        pwd = props.getString("collective2connector.password");

        enabled = props.getBoolean("collective2connector.enabled");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.mot.core.MyOpenTraderCore.java

/**
 * This method creates the actual JMS message listener for all stock prices. 
 * //from   w  ww  .java2  s. c o  m
 * @param symbol - which symbol to listen for
 * @param type - type of the symbol (FX, STK etc)
 * @param currency - which currency is in use
 * @param genericProperties - generic properties
 */
private void startTickMessageListener(String symbol, String type, String currency,
        Configuration genericProperties) {

    AverageCalculationDAO acd = new AverageCalculationDAO();
    ActiveMQFactory amf = new ActiveMQFactory();
    logger.debug("Creating new tick message listener ...");
    TickMessageListener tml = new TickMessageListener();
    Destination ticks = amf.createDestination("tickPriceChannel");

    /*
     * The following section would automatically create a moving average algo with the best known combination
     */

    if (genericProperties.getBoolean("engine.startup.autoCreateBestCombination")) {
        Iterator<Entry<Integer, Integer>> lm = acd
                .getBestAverageCombination(symbol, "TICK",
                        genericProperties.getInt("engine.startup.autoCreateBestCombineation.top"))
                .entrySet().iterator();
        if (lm.hasNext()) {
            Map.Entry<Integer, Integer> lm2 = lm.next();
            String name = symbol + lm2.getKey() * 10 + "-" + lm2.getValue() * 10 + "-mvg";
            //loadAlgorithm(genericProperties.getString("engine.startup.autoCreateBestCombineation.class"), name, symbol, lm2.getKey()*10, lm2.getValue()*10, 10, true);

        }
    }

    if (type.equals("FX")) {
        // If type is FX also provide the currency
        amf.createMessageConsumer(ticks, tml, symbol, currency);
    } else {
        amf.createMessageConsumer(ticks, tml, symbol);
    }

}

From source file:org.rdswicthboard.utils.xml.split.Processor.java

public Processor(Configuration config) {
    // extract input file
    inputFile = config.getString(Properties.PROPERTY_INPUT_FILE);

    // extract output file
    outputPrefix = config.getString(Properties.PROPERTY_OUTPUT_PREFIX);

    // extract input encoding
    inputEncoding = config.getString(Properties.PROPERTY_INPUT_ENCODING);

    // extract output encoding
    outputEncoding = config.getString(Properties.PROPERTY_OUTPUT_ENCODING);

    // extract root node
    rootNode = config.getString(Properties.PROPERTY_ROOT_NODE);

    // ectract format output flag
    formatOutput = config.getBoolean(Properties.PROPERTY_FORMAT_OUTPUT);
}

From source file:org.restcomm.connect.http.CallsEndpoint.java

@PostConstruct
public void init() {
    configuration = (Configuration) context.getAttribute(Configuration.class.getName());
    Configuration amazonS3Configuration = configuration.subset("amazon-s3");
    configuration = configuration.subset("runtime-settings");
    callManager = (ActorRef) context.getAttribute("org.restcomm.connect.telephony.CallManager");
    daos = (DaoManager) context.getAttribute(DaoManager.class.getName());
    accountsDao = daos.getAccountsDao();
    recordingsDao = daos.getRecordingsDao();
    super.init(configuration);
    CallDetailRecordConverter converter = new CallDetailRecordConverter(configuration);
    listConverter = new CallDetailRecordListConverter(configuration);
    final RecordingConverter recordingConverter = new RecordingConverter(configuration);
    builder = new GsonBuilder();
    builder.registerTypeAdapter(CallDetailRecord.class, converter);
    builder.registerTypeAdapter(CallDetailRecordList.class, listConverter);
    builder.registerTypeAdapter(Recording.class, recordingConverter);
    builder.setPrettyPrinting();// ww  w  .  ja va2s .co  m
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(recordingConverter);
    xstream.registerConverter(new RecordingListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
    xstream.registerConverter(listConverter);

    instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId();

    normalizePhoneNumbers = configuration.getBoolean("normalize-numbers-for-outbound-calls");
    if (!amazonS3Configuration.isEmpty()) { // Do not fail with NPE is amazonS3Configuration is not present for older install
        boolean amazonS3Enabled = amazonS3Configuration.getBoolean("enabled");
        if (amazonS3Enabled) {
            securityLevel = RecordingSecurityLevel
                    .valueOf(amazonS3Configuration.getString("security-level", "secure").toUpperCase());
            recordingConverter.setSecurityLevel(securityLevel);
        }
    }
}

From source file:org.restcomm.connect.http.RecordingsEndpoint.java

@PostConstruct
public void init() {
    final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName());
    configuration = (Configuration) context.getAttribute(Configuration.class.getName());
    Configuration amazonS3Configuration = configuration.subset("amazon-s3");
    configuration = configuration.subset("runtime-settings");
    super.init(configuration);
    dao = storage.getRecordingsDao();/*w  w  w.j a  va 2  s. co  m*/
    final RecordingConverter converter = new RecordingConverter(configuration);
    listConverter = new RecordingListConverter(configuration);
    final GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Recording.class, converter);
    builder.registerTypeAdapter(RecordingList.class, listConverter);
    builder.setPrettyPrinting();
    gson = builder.create();
    xstream = new XStream();
    xstream.alias("RestcommResponse", RestCommResponse.class);
    xstream.registerConverter(converter);
    xstream.registerConverter(new RecordingListConverter(configuration));
    xstream.registerConverter(new RestCommResponseConverter(configuration));
    if (!amazonS3Configuration.isEmpty()) { // Do not fail with NPE is amazonS3Configuration is not present for older install
        boolean amazonS3Enabled = amazonS3Configuration.getBoolean("enabled");
        if (amazonS3Enabled) {
            final String accessKey = amazonS3Configuration.getString("access-key");
            final String securityKey = amazonS3Configuration.getString("security-key");
            final String bucketName = amazonS3Configuration.getString("bucket-name");
            final String bucketFolder = amazonS3Configuration.getString("folder");
            final boolean reducedRedundancy = amazonS3Configuration.getBoolean("reduced-redundancy");
            final int minutesToRetainPublicUrl = amazonS3Configuration.getInt("minutes-to-retain-public-url",
                    10);
            final boolean removeOriginalFile = amazonS3Configuration.getBoolean("remove-original-file");
            final String bucketRegion = amazonS3Configuration.getString("bucket-region");
            final boolean testing = amazonS3Configuration.getBoolean("testing", false);
            final String testingUrl = amazonS3Configuration.getString("testing-url", null);
            s3AccessTool = new S3AccessTool(accessKey, securityKey, bucketName, bucketFolder, reducedRedundancy,
                    minutesToRetainPublicUrl, removeOriginalFile, bucketRegion, testing, testingUrl);

            securityLevel = RecordingSecurityLevel
                    .valueOf(amazonS3Configuration.getString("security-level", "secure").toUpperCase());
            converter.setSecurityLevel(securityLevel);
        }
    }

    xstream.registerConverter(listConverter);

    instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId();
}

From source file:org.restcomm.connect.sms.SmsService.java

public SmsService(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();//www  .j  a  va2  s . co m
    this.system = context().system();
    this.configuration = configuration;
    final Configuration runtime = configuration.subset("runtime-settings");
    this.authenticateUsers = runtime.getBoolean("authenticate");
    this.servletConfig = (ServletConfig) configuration.getProperty(ServletConfig.class.getName());
    this.sipFactory = factory;
    this.storage = storage;
    this.servletContext = servletContext;
    monitoringService = (ActorRef) servletContext.getAttribute(MonitoringService.class.getName());
    // final Configuration runtime = configuration.subset("runtime-settings");
    // TODO this.useTo = runtime.getBoolean("use-to");
    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);

    extensions = ExtensionController.getInstance().getExtensions(ExtensionType.SmsService);
    if (logger.isInfoEnabled()) {
        logger.info("SmsService extensions: " + (extensions != null ? extensions.size() : "0"));
    }
}

From source file:org.restcomm.connect.telephony.CallManager.java

public CallManager(final Configuration configuration, final ServletContext context,
        final MediaServerControllerFactory msControllerFactory, final ActorRef conferences,
        final ActorRef bridges, final ActorRef sms, final SipFactory factory, final DaoManager storage) {
    super();/*from   w ww. j av  a  2s  .c  o  m*/
    this.system = context().system();
    this.configuration = configuration;
    this.context = context;
    this.msControllerFactory = msControllerFactory;
    this.conferences = conferences;
    this.bridges = bridges;
    this.sms = sms;
    this.sipFactory = factory;
    this.storage = storage;
    final Configuration runtime = configuration.subset("runtime-settings");
    final Configuration outboundProxyConfig = runtime.subset("outbound-proxy");
    SipURI outboundIntf = outboundInterface("udp");
    if (outboundIntf != null) {
        myHostIp = ((SipURI) outboundIntf).getHost().toString();
    } else {
        String errMsg = "SipURI outboundIntf is null";
        sendNotification(errMsg, 14001, "error", false);

        if (context == null)
            errMsg = "SipServlet context is null";
        sendNotification(errMsg, 14002, "error", false);
    }
    Configuration mediaConf = configuration.subset("media-server-manager");
    mediaExternalIp = mediaConf.getString("mgcp-server.external-address");
    proxyIp = runtime.subset("telestax-proxy").getString("uri").replaceAll("http://", "").replaceAll(":2080",
            "");

    if (mediaExternalIp == null || mediaExternalIp.isEmpty())
        mediaExternalIp = myHostIp;

    if (proxyIp == null || proxyIp.isEmpty())
        proxyIp = myHostIp;

    this.useTo = runtime.getBoolean("use-to");
    this.authenticateUsers = runtime.getBoolean("authenticate");

    this.primaryProxyUri = outboundProxyConfig.getString("outbound-proxy-uri");
    this.primaryProxyUsername = outboundProxyConfig.getString("outbound-proxy-user");
    this.primaryProxyPassword = outboundProxyConfig.getString("outbound-proxy-password");

    this.fallBackProxyUri = outboundProxyConfig.getString("fallback-outbound-proxy-uri");
    this.fallBackProxyUsername = outboundProxyConfig.getString("fallback-outbound-proxy-user");
    this.fallBackProxyPassword = outboundProxyConfig.getString("fallback-outbound-proxy-password");

    this.activeProxy = primaryProxyUri;
    this.activeProxyUsername = primaryProxyUsername;
    this.activeProxyPassword = primaryProxyPassword;

    numberOfFailedCalls = new AtomicInteger();
    numberOfFailedCalls.set(0);
    useFallbackProxy = new AtomicBoolean();
    useFallbackProxy.set(false);

    allowFallback = outboundProxyConfig.getBoolean("allow-fallback", false);

    maxNumberOfFailedCalls = outboundProxyConfig.getInt("max-failed-calls", 20);

    allowFallbackToPrimary = outboundProxyConfig.getBoolean("allow-fallback-to-primary", false);

    patchForNatB2BUASessions = runtime.getBoolean("patch-for-nat-b2bua-sessions", true);

    //Monitoring Service
    this.monitoring = (ActorRef) context.getAttribute(MonitoringService.class.getName());

    extensions = ExtensionController.getInstance().getExtensions(ExtensionType.CallManager);
    if (logger.isInfoEnabled()) {
        logger.info("CallManager extensions: " + (extensions != null ? extensions.size() : "0"));
    }
    if (!runtime.subset("ims-authentication").isEmpty()) {
        final Configuration imsAuthentication = runtime.subset("ims-authentication");
        this.actAsImsUa = imsAuthentication.getBoolean("act-as-ims-ua");
        if (actAsImsUa) {
            this.imsProxyAddress = imsAuthentication.getString("proxy-address");
            this.imsProxyPort = imsAuthentication.getInt("proxy-port");
            if (imsProxyPort == 0) {
                imsProxyPort = DEFAUL_IMS_PROXY_PORT;
            }
            this.imsDomain = imsAuthentication.getString("domain");
            this.imsAccount = imsAuthentication.getString("account");
            if (actAsImsUa && (imsProxyAddress == null || imsProxyAddress.isEmpty() || imsDomain == null
                    || imsDomain.isEmpty())) {
                logger.warning("ims proxy-address or domain is not configured");
            }
            this.actAsImsUa = actAsImsUa && imsProxyAddress != null && !imsProxyAddress.isEmpty()
                    && imsDomain != null && !imsDomain.isEmpty();
        }
    }
    firstTimeCleanup();
}