本文整理汇总了Java中org.ektorp.http.StdHttpClient.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java StdHttpClient.Builder方法的具体用法?Java StdHttpClient.Builder怎么用?Java StdHttpClient.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ektorp.http.StdHttpClient
的用法示例。
在下文中一共展示了StdHttpClient.Builder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
@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);
}
示例2: initConnection
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
private CouchDbConnector initConnection() throws MalformedURLException, ProxyInitilizedFailedException {
String username = ConfigManager.get("couchdbUsername");
String password = ConfigManager.get("couchdbPassword");
String host = ConfigManager.get("couchdbHost");
int port = ConfigManager.getInt("couchdbPort");
int timeout = ConfigManager.getInt("couchdbTimeout");
boolean enableSSL = ConfigManager.getBoolean("couchdbEnableSSL", false);
String dbName = ConfigManager.get("couchdbDBName");
Builder builder = new StdHttpClient.Builder();
builder = builder
.host(host)
.port(port)
.connectionTimeout(timeout)
.enableSSL(enableSSL);
if (username != null && !username.isEmpty() && password != null && !password.isEmpty() ) {
builder = builder.username(username).password(password);
}
CouchDbInstance dbInstance = new StdCouchDbInstance(builder.build());
if (!dbInstance.checkIfDbExists(dbName))
dbInstance.createDatabase(dbName);
CouchDbConnector couchDB = dbInstance.createConnector(dbName, true);
return couchDB;
}
示例3: setup
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
static void setup()
{
StdHttpClient.Builder builder = new StdHttpClient.Builder();
HttpClient httpClient = builder.build();
StdCouchDbInstance instance = new StdCouchDbInstance(httpClient);
DbPath dbPath = new DbPath(TEST_DB);
if (instance.checkIfDbExists((dbPath))) {
instance.deleteDatabase(dbPath.getPath());
}
connector = instance.createConnector(TEST_DB, true);
}
示例4: teardown
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
static void teardown()
{
StdHttpClient.Builder builder = new StdHttpClient.Builder();
HttpClient httpClient = builder.build();
StdCouchDbInstance instance = new StdCouchDbInstance(httpClient);
DbPath dbPath = new DbPath(TEST_DB);
if (instance.checkIfDbExists((dbPath))) {
instance.deleteDatabase(dbPath.getPath());
}
}
示例5: createConnector
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
public CouchDbConnector createConnector(String couchUrl, String dbName,
int maxConnections, String username, String password) {
HttpClient httpClient;
try {
StdHttpClient.Builder builder = new StdHttpClient.Builder().url(
couchUrl).maxConnections(maxConnections);
if (username != null) {
builder.username(username);
}
if (password != null) {
builder.password(password);
}
httpClient = builder.build();
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
StdCouchDbConnector connector = new StdCouchDbConnector(dbName,
dbInstance) {
final StreamingJsonSerializer customSerializer = new StreamingJsonSerializer(
mapper);
@Override
protected String serializeToJson(Object o) {
return customSerializer.toJson(o);
}
};
return connector;
}
示例6: create
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
@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);
}
示例7: CouchDbDataContext
import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
public CouchDbDataContext(StdHttpClient.Builder httpClientBuilder, SimpleTableDef... tableDefs) {
this(httpClientBuilder.build(), tableDefs);
}