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

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

Introduction

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

Prototype

Object getProperty(String key);

Source Link

Document

Gets a property from the configuration.

Usage

From source file:org.lable.oss.dynamicconfig.core.commonsconfiguration.ConcurrentConfigurationTest.java

@Test
public void testMethodWrappers() {
    CombinedConfiguration mockConfiguration = mock(CombinedConfiguration.class);
    Configuration concurrentConfiguration = new ConcurrentConfiguration(mockConfiguration, null);

    concurrentConfiguration.subset("subset");
    concurrentConfiguration.isEmpty();/*from   w  ww. ja  v  a2s.c om*/
    concurrentConfiguration.containsKey("key");
    concurrentConfiguration.getProperty("getprop");
    concurrentConfiguration.getKeys("getkeys");
    concurrentConfiguration.getKeys();
    concurrentConfiguration.getProperties("getprops");
    concurrentConfiguration.getBoolean("getboolean1");
    concurrentConfiguration.getBoolean("getboolean2", true);
    concurrentConfiguration.getBoolean("getboolean3", Boolean.FALSE);
    concurrentConfiguration.getByte("getbyte1");
    concurrentConfiguration.getByte("getbyte2", (byte) 0);
    concurrentConfiguration.getByte("getbyte3", Byte.valueOf((byte) 0));
    concurrentConfiguration.getDouble("getdouble1");
    concurrentConfiguration.getDouble("getdouble2", 0.2);
    concurrentConfiguration.getDouble("getdouble3", Double.valueOf(0.2));
    concurrentConfiguration.getFloat("getfloat1");
    concurrentConfiguration.getFloat("getfloat2", 0f);
    concurrentConfiguration.getFloat("getfloat3", Float.valueOf(0f));
    concurrentConfiguration.getInt("getint1");
    concurrentConfiguration.getInt("getint2", 0);
    concurrentConfiguration.getInteger("getint3", 0);
    concurrentConfiguration.getLong("getlong1");
    concurrentConfiguration.getLong("getlong2", 0L);
    concurrentConfiguration.getLong("getlong3", Long.valueOf(0L));
    concurrentConfiguration.getShort("getshort1");
    concurrentConfiguration.getShort("getshort2", (short) 0);
    concurrentConfiguration.getShort("getshort3", Short.valueOf((short) 0));
    concurrentConfiguration.getBigDecimal("getbigd1");
    concurrentConfiguration.getBigDecimal("getbigd2", BigDecimal.valueOf(0.4));
    concurrentConfiguration.getBigInteger("getbigi1");
    concurrentConfiguration.getBigInteger("getbigi2", BigInteger.valueOf(2L));
    concurrentConfiguration.getString("getstring1");
    concurrentConfiguration.getString("getstring2", "def");
    concurrentConfiguration.getStringArray("stringarray");
    concurrentConfiguration.getList("getlist1");
    concurrentConfiguration.getList("getlist2", Arrays.asList("a", "b"));

    verify(mockConfiguration, times(1)).subset("subset");
    verify(mockConfiguration, times(1)).isEmpty();
    verify(mockConfiguration, times(1)).containsKey("key");
    verify(mockConfiguration, times(1)).getProperty("getprop");
    verify(mockConfiguration, times(1)).getKeys("getkeys");
    verify(mockConfiguration, times(1)).getKeys();
    verify(mockConfiguration, times(1)).getProperties("getprops");
    verify(mockConfiguration, times(1)).getBoolean("getboolean1");
    verify(mockConfiguration, times(1)).getBoolean("getboolean2", true);
    verify(mockConfiguration, times(1)).getBoolean("getboolean3", Boolean.FALSE);
    verify(mockConfiguration, times(1)).getByte("getbyte1");
    verify(mockConfiguration, times(1)).getByte("getbyte2", (byte) 0);
    verify(mockConfiguration, times(1)).getByte("getbyte3", Byte.valueOf((byte) 0));
    verify(mockConfiguration, times(1)).getDouble("getdouble1");
    verify(mockConfiguration, times(1)).getDouble("getdouble2", 0.2);
    verify(mockConfiguration, times(1)).getDouble("getdouble3", Double.valueOf(0.2));
    verify(mockConfiguration, times(1)).getFloat("getfloat1");
    verify(mockConfiguration, times(1)).getFloat("getfloat2", 0f);
    verify(mockConfiguration, times(1)).getFloat("getfloat3", Float.valueOf(0f));
    verify(mockConfiguration, times(1)).getInt("getint1");
    verify(mockConfiguration, times(1)).getInt("getint2", 0);
    verify(mockConfiguration, times(1)).getInteger("getint3", Integer.valueOf(0));
    verify(mockConfiguration, times(1)).getLong("getlong1");
    verify(mockConfiguration, times(1)).getLong("getlong2", 0L);
    verify(mockConfiguration, times(1)).getLong("getlong3", Long.valueOf(0L));
    verify(mockConfiguration, times(1)).getShort("getshort1");
    verify(mockConfiguration, times(1)).getShort("getshort2", (short) 0);
    verify(mockConfiguration, times(1)).getShort("getshort3", Short.valueOf((short) 0));
    verify(mockConfiguration, times(1)).getBigDecimal("getbigd1");
    verify(mockConfiguration, times(1)).getBigDecimal("getbigd2", BigDecimal.valueOf(0.4));
    verify(mockConfiguration, times(1)).getBigInteger("getbigi1");
    verify(mockConfiguration, times(1)).getBigInteger("getbigi2", BigInteger.valueOf(2L));
    verify(mockConfiguration, times(1)).getString("getstring1");
    verify(mockConfiguration, times(1)).getString("getstring2", "def");
    verify(mockConfiguration, times(1)).getStringArray("stringarray");
    verify(mockConfiguration, times(1)).getList("getlist1");
    verify(mockConfiguration, times(1)).getList("getlist2", Arrays.asList("a", "b"));
}

From source file:org.lable.oss.dynamicconfig.Precomputed.java

Precomputed(Configuration configuration, Precomputer<T> precomputer, boolean updateOnChange,
        String... monitoredKeys) {

    this.configuration = configuration;
    this.precomputer = precomputer;
    this.updateOnChange = updateOnChange;
    this.monitoredKeys = new HashMap<>();

    for (String monitoredKey : monitoredKeys) {
        if (monitoredKey == null)
            throw new IllegalArgumentException("Monitored keys cannot be null.");
        this.monitoredKeys.put(monitoredKey, configuration.getProperty(monitoredKey));
    }//ww  w.  j a va  2s . c  o m

    updateValue();
}

From source file:org.loggo.server.KafkaConsumer.java

private static Properties asProperties(Configuration conf) {
    Properties result = new Properties();
    @SuppressWarnings("rawtypes")
    Iterator keys = conf.getKeys();
    while (keys.hasNext()) {
        String key = keys.next().toString();
        result.setProperty(key, conf.getProperty(key).toString());
    }//from   w  w w . j  ava  2  s  .  c  om
    return result;
}

From source file:org.mobicents.servlet.restcomm.sms.smpp.SmppService.java

public SmppService(final ActorSystem system, final Configuration configuration, final SipFactory factory,
        final DaoManager storage, final ServletContext servletContext, final ActorRef smppMessageHandler) {

    super();//from   w  ww  .j a v a 2s  .  c om
    this.system = system;
    this.smppMessageHandler = smppMessageHandler;
    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;

    Configuration config = this.configuration.subset("smpp");
    smppActivated = config.getString("[@activateSmppConnection]");

    //get smpp address map from restcomm.xml file
    this.smppSourceAddressMap = config.getString("connections.connection[@sourceAddressMap]");
    this.smppDestinationAddressMap = config.getString("connections.connection[@destinationAddressMap]");
    this.smppTonNpiValue = config.getString("connections.connection[@tonNpiValue]");

    this.initializeSmppConnections();
}

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   ww w.java  2  s  . com
    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.neo4j.server.configuration.validation.WebadminConfigurationRule.java

private String validateConfigurationContainsKey(Configuration configuration, String key)
        throws RuleFailedException {
    if (!configuration.containsKey(key)) {
        throw new RuleFailedException(
                "Webadmin configuration not found. Check that the neo4j-server.properties file contains the [%s] property.",
                key);/*from   ww  w  .ja  v  a 2  s  . c om*/
    }

    return (String) configuration.getProperty(key);
}

From source file:org.neo4j.server.NeoServerWithEmbeddedWebServer.java

@Override
public void start() {
    // Start at the bottom of the stack and work upwards to the Web
    // container/*from   w w  w . ja  va 2  s.co m*/
    startupHealthCheck();

    initWebServer();

    StringLogger logger = startDatabase();

    if (logger != null) {
        logger.logMessage("--- SERVER STARTUP START ---");

        Configuration configuration = configurator.configuration();
        logger.logMessage("Server configuration:");
        for (Object key : IteratorUtil.asIterable(configuration.getKeys())) {
            if (key instanceof String)
                logger.logMessage("  " + key + " = " + configuration.getProperty((String) key));
        }
    }

    startExtensionInitialization();

    startModules(logger);

    startWebServer(logger);

    if (logger != null)
        logger.logMessage("--- SERVER STARTUP END ---", true);
}

From source file:org.overlord.dtgov.ui.server.services.WorkflowQueryService.java

@Override
public Set<String> getWorkflowTypes() throws DtgovUiException {
    Configuration dtgov_ui_conf = config.getConfiguration();
    SrampAtomApiClient client = _srampClientAccessor.getClient();
    Set<String> workflows = new HashSet<String>();
    try {//from   www  .  ja  va  2s .c  o  m
        QueryResultSet results = client.buildQuery(SRAMP_WORKFLOW_QUERY)
                .parameter((String) dtgov_ui_conf.getProperty(WORKFLOW_ARTIFACT_GROUP_KEY))
                .parameter((String) dtgov_ui_conf.getProperty(WORKFLOW_ARTIFACT_NAME_KEY))
                .parameter((String) dtgov_ui_conf.getProperty(WORKFLOW_ARTIFACT_VERSION_KEY)).query();
        Iterator<ArtifactSummary> results_iterator = results.iterator();
        while (results_iterator.hasNext()) {
            ArtifactSummary artifact = results_iterator.next();
            String name = artifact.getName().substring(0, artifact.getName().lastIndexOf("."));
            workflows.add(name);
        }
    } catch (SrampClientException e) {
        throw new DtgovUiException(e.getMessage());
    } catch (SrampAtomException e) {
        throw new DtgovUiException(e.getMessage());
    }
    return workflows;
}

From source file:org.overlord.sramp.ui.server.api.SrampAtomApiClient.java

/**
 * Private singleton constructor.//from  w  w  w.ja  v a2  s  . c o  m
 * @param config 
 */
private SrampAtomApiClient(Configuration config) {
    super((String) config.getProperty("s-ramp.atom-api.endpoint"));
}

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

public SmsService(final Configuration configuration, final SipFactory factory, final DaoManager storage,
        final ServletContext servletContext) {
    super();//from   w  ww .j a v  a  2 s  . com
    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"));
    }
}