use of net.spy.memcached.ConnectionFactoryBuilder.Protocol in project qi4j-sdk by Qi4j.
the class MemcachePoolMixin method activateService.
@Override
public void activateService() throws Exception {
if (configuration != null) {
MemcacheConfiguration config = configuration.get();
expiration = (config.expiration().get() == null) ? 3600 : config.expiration().get();
String addresses = (config.addresses().get() == null) ? "localhost:11211" : config.addresses().get();
Protocol protocol = (config.protocol().get() == null) ? Protocol.TEXT : Protocol.valueOf(config.protocol().get().toUpperCase());
String username = config.username().get();
String password = config.password().get();
String authMech = config.authMechanism().get() == null ? "PLAIN" : config.authMechanism().get();
ConnectionFactoryBuilder builder = new ConnectionFactoryBuilder();
builder.setProtocol(protocol);
if (username != null && !username.isEmpty()) {
builder.setAuthDescriptor(new AuthDescriptor(new String[] { authMech }, new PlainCallbackHandler(username, password)));
}
client = new MemcachedClient(builder.build(), AddrUtil.getAddresses(addresses));
}
}
Aggregations