当前位置: 首页>>代码示例>>Java>>正文


Java StdHttpClient.Builder方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:CouchDbStore.java

示例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;
	
}
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:31,代码来源:CouchdbStoreService.java

示例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);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:12,代码来源:CouchDBTestHelper.java

示例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());
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:11,代码来源:CouchDBTestHelper.java

示例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;
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:33,代码来源:CouchDbConnectorFactory.java

示例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);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:35,代码来源:CouchDbDataContextFactory.java

示例7: CouchDbDataContext

import org.ektorp.http.StdHttpClient; //导入方法依赖的package包/类
public CouchDbDataContext(StdHttpClient.Builder httpClientBuilder, SimpleTableDef... tableDefs) {
    this(httpClientBuilder.build(), tableDefs);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:4,代码来源:CouchDbDataContext.java


注:本文中的org.ektorp.http.StdHttpClient.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。