当前位置: 首页>>代码示例>>Java>>正文


Java AbstractConfiguration.getString方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.AbstractConfiguration.getString方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractConfiguration.getString方法的具体用法?Java AbstractConfiguration.getString怎么用?Java AbstractConfiguration.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.AbstractConfiguration的用法示例。


在下文中一共展示了AbstractConfiguration.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("master_slave")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceMasterSlave = RedisClient.create(lettuceURI);
    this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
    this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:20,代码来源:RedisSyncMasterSlaveStorageImpl.java

示例2: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
protected void init(AbstractConfiguration config) {
    BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");
    APPLICATION_TOPIC = config.getString("communicator.application.topic");

    logger.trace("Initializing Kafka producer ...");

    // producer config
    Properties props = new Properties();
    props.put("bootstrap.servers", config.getString("bootstrap.servers"));
    props.put("acks", config.getString("acks"));
    props.put("key.serializer", StringSerializer.class.getName());
    props.put("value.serializer", InternalMessageSerializer.class.getName());

    // producer
    this.producer = new KafkaProducer<>(props);

    // consumer executor
    this.executor = Executors.newSingleThreadExecutor();
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:20,代码来源:KafkaCommunicator.java

示例3: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSingleServer()
            .setAddress(address.get(0))
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RedisSyncSingleStorage.java

示例4: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config, String serverId) {
    try {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setUsername(config.getString("rabbitmq.userName", ConnectionFactory.DEFAULT_USER));
        cf.setPassword(config.getString("rabbitmq.password", ConnectionFactory.DEFAULT_PASS));
        cf.setVirtualHost(config.getString("rabbitmq.virtualHost", ConnectionFactory.DEFAULT_VHOST));
        cf.setAutomaticRecoveryEnabled(true);
        cf.setExceptionHandler(new RabbitMQExceptionHandler());
        this.conn = cf.newConnection(Address.parseAddresses(config.getString("rabbitmq.addresses")));
        this.channel = conn.createChannel();

        logger.trace("Initializing RabbitMQ broker resources ...");

        BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");

        logger.trace("Initializing RabbitMQ application resources ...");

        APPLICATION_TOPIC = config.getString("communicator.application.topic");
        this.channel.exchangeDeclare(APPLICATION_TOPIC, "topic", true);

    } catch (IOException | TimeoutException e) {
        logger.error("Failed to connect to RabbitMQ servers", e);
        throw new IllegalStateException("Init RabbitMQ communicator failed");
    }
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RabbitMQHttpCommunicator.java

示例5: resolve

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
/**
 * Attempts to acquire the Vault URL from Archaius.
 *
 * @return Vault URL
 */
@Nullable
@Override
public  String resolve() {
    final AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();
    final String envUrl = configuration.getString(CERBERUS_ADDR_ENV_PROPERTY);
    final String sysUrl = configuration.getString(CERBERUS_ADDR_SYS_PROPERTY);

    if (StringUtils.isNotBlank(envUrl) && HttpUrl.parse(envUrl) != null) {
        return envUrl;
    } else if (StringUtils.isNotBlank(sysUrl) && HttpUrl.parse(sysUrl) != null) {
        return sysUrl;
    }

    logger.warn("Unable to resolve the Cerberus URL.");

    return null;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-archaius-client,代码行数:23,代码来源:ArchaiusCerberusUrlResolver.java

示例6: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:19,代码来源:RedisSyncSingleStorageImpl.java

示例7: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("sentinel")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
    String masterId = config.getString("redis.master");

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
    this.lettuceSentinel = RedisClient.create(lettuceURI);
    this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
    this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:21,代码来源:RedisSyncSentinelStorageImpl.java

示例8: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("master_slave")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceMasterSlave = RedisClient.create(lettuceURI);
    this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
    this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    String masterNode = address.get(0);
    String[] slaveNodes = address.subList(1, address.size()).toArray(new String[address.size() - 1]);
    Config redissonConfig = new Config();
    redissonConfig.useMasterSlaveServers()
            .setMasterAddress(masterNode)
            .setLoadBalancer(new RoundRobinLoadBalancer())
            .addSlaveAddress(slaveNodes)
            .setReadMode(ReadMode.MASTER)
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncMasterSlaveStorage.java

示例9: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("cluster")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with cluster redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceCluster = RedisClusterClient.create(lettuceURI);
    this.lettuceCluster.setOptions(new ClusterClientOptions.Builder()
            .refreshClusterView(true)
            .refreshPeriod(1, TimeUnit.MINUTES)
            .build());
    this.lettuceClusterConn = this.lettuceCluster.connect();
    this.lettuceClusterConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useClusterServers()
            .setScanInterval(60000)
            .addNodeAddress(address.toArray(new String[address.size()]))
            .setReadMode(ReadMode.MASTER)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncClusterStorage.java

示例10: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("sentinel")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
    String masterId = config.getString("redis.master");

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
    this.lettuceSentinel = RedisClient.create(lettuceURI);
    this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
    this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSentinelServers()
            .setMasterName(masterId)
            .addSentinelAddress(address.toArray(new String[address.size()]))
            .setReadMode(ReadMode.MASTER)
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:31,代码来源:RedisSyncSentinelStorage.java

示例11: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    this.allowDollar = config.getBoolean("allowDollar", true);
    this.deniedTopic = config.getString("deniedTopic", null);
    mongoStorage = new MongoStorage();
    mongoStorage.init(config);

}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:9,代码来源:PowerAuthenticator.java

示例12: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    this.influxDB = InfluxDBFactory.connect(config.getString("influxdb.url"), config.getString("influxdb.username"), config.getString("influxdb.password"));
    this.influxDB.createDatabase(config.getString("influxdb.dbname"));
    this.influxDB.enableBatch(config.getInt("influxdb.actions"), config.getInt("influxdb.durations"), TimeUnit.MILLISECONDS);
    this.dbName = config.getString("influxdb.dbname");
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:8,代码来源:InfluxDBMetricsService.java

示例13: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config, ApplicationListenerFactory factory) {
    try {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setUsername(config.getString("rabbitmq.userName", ConnectionFactory.DEFAULT_USER));
        cf.setPassword(config.getString("rabbitmq.password", ConnectionFactory.DEFAULT_PASS));
        cf.setVirtualHost(config.getString("rabbitmq.virtualHost", ConnectionFactory.DEFAULT_VHOST));
        cf.setAutomaticRecoveryEnabled(true);
        cf.setExceptionHandler(new RabbitMQExceptionHandler());
        this.conn = cf.newConnection(Address.parseAddresses(config.getString("rabbitmq.addresses")));
        this.channel = conn.createChannel();

        logger.trace("Initializing RabbitMQ application resources ...");

        APPLICATION_TOPIC = config.getString("communicator.application.topic");
        this.channel.exchangeDeclare(APPLICATION_TOPIC, "topic", true);

        logger.trace("Initializing RabbitMQ application consumer's workers ...");

        Channel consumerChan = this.conn.createChannel();
        consumerChan.queueDeclare(config.getString("rabbitmq.app.queueName"), true, false, true, null);
        consumerChan.queueBind(config.getString("rabbitmq.app.queueName"), APPLICATION_TOPIC, config.getString("rabbitmq.app.routingKey"));
        consumerChan.basicConsume(config.getString("rabbitmq.app.queueName"), true, new RabbitMQApplicationConsumer(consumerChan, factory.newListener()));

    } catch (IOException | TimeoutException e) {
        logger.error("Failed to connect to RabbitMQ servers", e);
        throw new IllegalStateException("Init RabbitMQ communicator failed");
    }
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:30,代码来源:RabbitMQApplicationCommunicator.java

示例14: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config, String brokerId, BrokerListenerFactory factory) {
    try {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setUsername(config.getString("rabbitmq.userName", ConnectionFactory.DEFAULT_USER));
        cf.setPassword(config.getString("rabbitmq.password", ConnectionFactory.DEFAULT_PASS));
        cf.setVirtualHost(config.getString("rabbitmq.virtualHost", ConnectionFactory.DEFAULT_VHOST));
        cf.setAutomaticRecoveryEnabled(true);
        cf.setExceptionHandler(new RabbitMQExceptionHandler());
        this.conn = cf.newConnection(Address.parseAddresses(config.getString("rabbitmq.addresses")));
        this.channel = conn.createChannel();

        logger.trace("Initializing RabbitMQ broker resources ...");

        BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");

        logger.trace("Initializing RabbitMQ application resources ...");

        APPLICATION_TOPIC = config.getString("communicator.application.topic");
        this.channel.exchangeDeclare(APPLICATION_TOPIC, "topic", true);

        logger.trace("Initializing RabbitMQ broker consumer's workers ...");

        Channel consumerChan = this.conn.createChannel();
        consumerChan.exchangeDeclare(BROKER_TOPIC_PREFIX + "." + brokerId, "topic");
        String queueName = consumerChan.queueDeclare().getQueue();
        consumerChan.queueBind(queueName, BROKER_TOPIC_PREFIX + "." + brokerId, "#");
        consumerChan.basicConsume(queueName, true, new RabbitMQBrokerConsumer(consumerChan, factory.newListener()));

    } catch (IOException | TimeoutException e) {
        logger.error("Failed to connect to RabbitMQ servers", e);
        throw new IllegalStateException("Init RabbitMQ communicator failed");
    }
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:35,代码来源:RabbitMQBrokerCommunicator.java

示例15: init

import org.apache.commons.configuration.AbstractConfiguration; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config, String serverId) {
    this.hazelcast = Hazelcast.newHazelcastInstance();

    logger.trace("Initializing Hazelcast broker resources ...");

    BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");
    APPLICATION_TOPIC = config.getString("communicator.application.topic");
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:10,代码来源:HazelcastHttpCommunicator.java


注:本文中的org.apache.commons.configuration.AbstractConfiguration.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。