client = new StdHttpClient.Builder() .host(host) .port(port) .maxConnections(maxConnections) .connectionTimeout(connectionTimeout) .socketTimeout(socketTimeout) .username(username) .password(password) .cleanupIdleConnections(cleanupIdleConnections) .useExpectContinue(useExpectContinue) .enableSSL(enableSSL) .relaxedSSLSettings(relaxedSSLSettings) .sslSocketFactory(sslSocketFactory) .caching(caching) .maxCacheEntries(maxCacheEntries) .maxObjectSizeBytes(maxObjectSizeBytes) .url(url) .build();
String password, SimpleTableDef[] tableDefs) { final Builder httpClientBuilder = new Builder(); httpClientBuilder.host(hostname); if (port != null) { httpClientBuilder.port(port); httpClientBuilder.username(username); httpClientBuilder.password(password); httpClientBuilder.connectionTimeout(20000); httpClientBuilder.socketTimeout(20000);
final HttpClient httpClient = new StdHttpClient.Builder() .url("http://" + params.getServer() + ":" + params.getPort()) .build();
final HttpClient httpClient = new StdHttpClient.Builder() .url("http://" + params.getServer() + ":" + params.getPort()) .build();
String password, SimpleTableDef[] tableDefs) { final Builder httpClientBuilder = new Builder(); httpClientBuilder.host(hostname); if (port != null) { httpClientBuilder.port(port); httpClientBuilder.username(username); httpClientBuilder.password(password); httpClientBuilder.connectionTimeout(20000); httpClientBuilder.socketTimeout(20000);
/** * Will set host, port and possible enables SSL based on the properties if the supplied URL. * This method overrides the properties: host, port and enableSSL. * @param url * @return */ public Builder url(URL url){ this.host = url.getHost(); this.port = url.getPort(); if (url.getUserInfo() != null) { String[] userInfoParts = url.getUserInfo().split(":"); if (userInfoParts.length == 2) { this.username = userInfoParts[0]; this.password = userInfoParts[1]; } } enableSSL("https".equals(url.getProtocol())); if (this.port == -1) { if (this.enableSSL) { this.port = 443; } else { this.port = 80; } } return this; }
@Override public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) throws UnsupportedDataContextPropertiesException, ConnectionException { final StdHttpClient.Builder httpClientBuilder = new StdHttpClient.Builder(); final String url = properties.getUrl(); if (url != null && !url.isEmpty()) { try { httpClientBuilder.url(url); } catch (MalformedURLException e) { throw new IllegalArgumentException(url, e); } } else { httpClientBuilder.host(properties.getHostname()); httpClientBuilder.port(getInt(properties.getPort(), CouchDbDataContext.DEFAULT_PORT)); httpClientBuilder.enableSSL(getBoolean(properties.toMap().get("ssl"), false)); } httpClientBuilder.username(properties.getUsername()); httpClientBuilder.password(properties.getPassword()); final HttpClient httpClient = httpClientBuilder.build(); final SimpleTableDef[] tableDefs = properties.getTableDefs(); if (tableDefs != null && tableDefs.length > 0) { return new CouchDbDataContext(httpClient, tableDefs); } final String databaseNames = properties.getDatabaseName(); if (databaseNames != null && !databaseNames.isEmpty()) { return new CouchDbDataContext(new StdCouchDbInstance(httpClient), databaseNames.split(",")); } return new CouchDbDataContext(httpClient); }
Builder httpClientBuilder = new Builder(); httpClientBuilder.host(hostname); if (port != null) { httpClientBuilder.port(port); httpClientBuilder.username(username); httpClientBuilder.password(password); httpClientBuilder.connectionTimeout(20000); httpClientBuilder.socketTimeout(20000);
@Override public void connect() throws IOException { StdHttpClient.Builder builder = new StdHttpClient.Builder(); if (dbUrl != null) { try { builder.url(dbUrl); } catch (MalformedURLException e) { throw new IllegalArgumentException(e.getMessage()); } } if (userName != null) { builder.username(userName); } if (password != null) { builder.password(password); } HttpClient httpClient = builder.build(); couchInstance = new StdCouchDbInstance(httpClient); dbConnector = couchInstance.createConnector(dbName, false); }
public CouchDBDataStore(final String url, final String dbName) { try { httpClient = new StdHttpClient.Builder().url(url).build(); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } stdCouchDbInstance = new StdCouchDbInstance(httpClient); db = new StdCouchDbConnector(dbName, stdCouchDbInstance); db.createDatabaseIfNotExists(); designDocument = new DesignDocument("_design/channels"); addView(designDocument, Views.CHANNEL); addView(designDocument, Views.UAID); addView(designDocument, Views.TOKEN); addView(designDocument, Views.UNACKS); addView(designDocument, Views.SERVER); if (!db.contains(designDocument.getId())) { db.create(designDocument); } }
@Override protected UsageAwareDatastoreConnection<CouchDbDataContext> createDatastoreConnection() { final StdHttpClient.Builder httpClient = new StdHttpClient.Builder(); httpClient.host(getHostname()); if (_port != null) { httpClient.port(_port); } if (_username != null) { httpClient.username(_username); } if (_password != null) { httpClient.password(_password); } httpClient.enableSSL(_sslEnabled); httpClient.connectionTimeout(HTTP_TIMEOUT); httpClient.socketTimeout(HTTP_TIMEOUT); final CouchDbDataContext dataContext; if (_tableDefs != null && _tableDefs.length > 0) { dataContext = new CouchDbDataContext(httpClient, _tableDefs); } else { dataContext = new CouchDbDataContext(httpClient); } return new UpdateableDatastoreConnectionImpl<>(dataContext, this); }
@Override protected UsageAwareDatastoreConnection<CouchDbDataContext> createDatastoreConnection() { final StdHttpClient.Builder httpClient = new StdHttpClient.Builder(); httpClient.host(getHostname()); if (_port != null) { httpClient.port(_port); } if (_username != null) { httpClient.username(_username); } if (_password != null) { httpClient.password(_password); } httpClient.enableSSL(_sslEnabled); httpClient.connectionTimeout(HTTP_TIMEOUT); httpClient.socketTimeout(HTTP_TIMEOUT); final CouchDbDataContext dataContext; if (_tableDefs != null && _tableDefs.length > 0) { dataContext = new CouchDbDataContext(httpClient, _tableDefs); } else { dataContext = new CouchDbDataContext(httpClient); } return new UpdateableDatastoreConnectionImpl<CouchDbDataContext>(dataContext, this); }
@Override public void connect() throws IOException { StdHttpClient.Builder builder = new StdHttpClient.Builder(); if (dbUrl != null) { try { builder.url(dbUrl); } catch (MalformedURLException e) { throw new IllegalArgumentException(e.getMessage()); } } if (userName != null) { builder.username(userName); } if (password != null) { builder.password(password); } HttpClient httpClient = builder.build(); couchInstance = new StdCouchDbInstance(httpClient); dbConnector = couchInstance.createConnector(dbName, false); }
public CouchDBDataStore(final String url, final String dbName) { try { httpClient = new StdHttpClient.Builder().url(url).build(); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } stdCouchDbInstance = new StdCouchDbInstance(httpClient); db = new StdCouchDbConnector(dbName, stdCouchDbInstance); db.createDatabaseIfNotExists(); designDocument = new DesignDocument("_design/channels"); addView(designDocument, Views.CHANNEL); addView(designDocument, Views.UAID); addView(designDocument, Views.TOKEN); addView(designDocument, Views.UNACKS); addView(designDocument, Views.SERVER); if (!db.contains(designDocument.getId())) { db.create(designDocument); } }
private static StdHttpClient.Builder couchDbHttpClient(CouchDbConfiguration configuration) { StdHttpClient.Builder httpBuilder = new StdHttpClient.Builder(); try { httpBuilder.url(configuration.getUrl()).caching(configuration.isCaching()) .enableSSL(configuration.isEnableSsl()).relaxedSSLSettings(configuration.isRelaxedSsl()); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } if(configuration.isUsernameSet()) { httpBuilder.username(configuration.getUsername()); } if(configuration.isPasswordSet()) { httpBuilder.password(configuration.getPassword()); } if(configuration.isSslServerSocketSet()) { httpBuilder.sslSocketFactory(configuration.getSslSocketFactory()); } return httpBuilder; }
private static StdHttpClient.Builder couchDbHttpClient(CouchDbConfiguration configuration) { StdHttpClient.Builder httpBuilder = new StdHttpClient.Builder(); try { httpBuilder.url(configuration.getUrl()).caching(configuration.isCaching()) .enableSSL(configuration.isEnableSsl()).relaxedSSLSettings(configuration.isRelaxedSsl()); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } if (configuration.isUsernameSet()) { httpBuilder.username(configuration.getUsername()); } if (configuration.isPasswordSet()) { httpBuilder.password(configuration.getPassword()); } if (configuration.isSslServerSocketSet()) { httpBuilder.sslSocketFactory(configuration.getSslSocketFactory()); } return httpBuilder; } }
public CouchDbDataContext(StdHttpClient.Builder httpClientBuilder, SimpleTableDef... tableDefs) { this(httpClientBuilder.build(), tableDefs); }
public CouchDbDataContext(StdHttpClient.Builder httpClientBuilder) { this(httpClientBuilder.build()); }
JSONObject serviceAttr = val.getJSONObject(0); JSONObject credentials = serviceAttr.getJSONObject("credentials"); httpClient = new StdHttpClient.Builder() .url(credentials.getString("url")) .build();
private static CouchDbConnector couchDbConnector(CouchDbConfiguration configuration, StdHttpClient.Builder httpBuilder) { CouchDbInstance dbInstance = new StdCouchDbInstance(httpBuilder.build()); return dbInstance.createConnector(configuration.getDatabaseName(), true); }