本文整理匯總了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);
}
示例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();
}
示例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);
}
示例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");
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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");
}
}
示例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");
}
}
示例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");
}