use of java.net.URI in project camel by apache.
the class CouchbaseEndpoint method createClient.
private CouchbaseClient createClient() throws IOException, URISyntaxException {
List<URI> hosts = Arrays.asList(makeBootstrapURI());
CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
if (opTimeOut != DEFAULT_OP_TIMEOUT) {
cfb.setOpTimeout(opTimeOut);
}
if (timeoutExceptionThreshold != DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD) {
cfb.setTimeoutExceptionThreshold(timeoutExceptionThreshold);
}
if (readBufferSize != DEFAULT_READ_BUFFER_SIZE) {
cfb.setReadBufferSize(readBufferSize);
}
if (shouldOptimize) {
cfb.setShouldOptimize(true);
}
if (maxReconnectDelay != DEFAULT_MAX_RECONNECT_DELAY) {
cfb.setMaxReconnectDelay(maxReconnectDelay);
}
if (opQueueMaxBlockTime != DEFAULT_OP_QUEUE_MAX_BLOCK_TIME) {
cfb.setOpQueueMaxBlockTime(opQueueMaxBlockTime);
}
if (obsPollInterval != DEFAULT_OBS_POLL_INTERVAL) {
cfb.setObsPollInterval(obsPollInterval);
}
if (obsTimeout != DEFAULT_OBS_TIMEOUT) {
cfb.setObsTimeout(obsTimeout);
}
return new CouchbaseClient(cfb.buildCouchbaseConnection(hosts, bucket, username, password));
}
use of java.net.URI in project camel by apache.
the class CouchbaseComponentTest method testCouchbaseDuplicateAdditionalHosts.
@Test
public void testCouchbaseDuplicateAdditionalHosts() throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put("additionalHosts", "127.0.0.1,localhost, localhost");
String uri = "couchbase:http://localhost/bucket?param=true";
String remaining = "http://localhost/bucket?param=true";
CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
URI[] endpointArray = endpoint.makeBootstrapURI();
assertEquals(2, endpointArray.length);
assertEquals(new URI("http://localhost:8091/pools"), endpointArray[0]);
assertEquals(new URI("http://127.0.0.1:8091/pools"), endpointArray[1]);
}
use of java.net.URI in project camel by apache.
the class CouchbaseComponentTest method testCouchbaseAdditionalHostsWithSpaces.
@Test
public void testCouchbaseAdditionalHostsWithSpaces() throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put("additionalHosts", " 127.0.0.1, example.com, another-host ");
String uri = "couchbase:http://localhost/bucket?param=true";
String remaining = "http://localhost/bucket?param=true";
CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
// System.out.print(endpoint.makeBootstrapURI()[0].toString() + " " +
// endpoint.makeBootstrapURI().length + " ");
URI[] endpointArray = endpoint.makeBootstrapURI();
assertEquals(new URI("http://localhost:8091/pools"), endpointArray[0]);
assertEquals(new URI("http://127.0.0.1:8091/pools"), endpointArray[1]);
assertEquals(new URI("http://example.com:8091/pools"), endpointArray[2]);
assertEquals(new URI("http://another-host:8091/pools"), endpointArray[3]);
assertEquals(4, endpointArray.length);
}
use of java.net.URI in project camel by apache.
the class SftpComponent method buildFileEndpoint.
@Override
protected GenericFileEndpoint<ChannelSftp.LsEntry> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// get the base uri part before the options as they can be non URI valid such as the expression using $ chars
// and the URI constructor will regard $ as an illegal character and we dont want to enforce end users to
// to escape the $ for the expression (file language)
String baseUri = uri;
if (uri.indexOf("?") != -1) {
baseUri = uri.substring(0, uri.indexOf("?"));
}
// lets make sure we create a new configuration as each endpoint can
// customize its own version
SftpConfiguration config = new SftpConfiguration(new URI(baseUri));
FtpUtils.ensureRelativeFtpDirectory(this, config);
return new SftpEndpoint(uri, this, config);
}
use of java.net.URI in project camel by apache.
the class FtpComponent method buildFileEndpoint.
@Override
protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
String baseUri = getBaseUri(uri);
// lets make sure we create a new configuration as each endpoint can customize its own version
// must pass on baseUri to the configuration (see above)
FtpConfiguration config = new FtpConfiguration(new URI(baseUri));
FtpUtils.ensureRelativeFtpDirectory(this, config);
FtpEndpoint<FTPFile> answer = new FtpEndpoint<FTPFile>(uri, this, config);
extractAndSetFtpClientConfigParameters(parameters, answer);
extractAndSetFtpClientParameters(parameters, answer);
return answer;
}
Aggregations