• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CloudantClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.cloudant.client.api.CloudantClient的典型用法代码示例。如果您正苦于以下问题:Java CloudantClient类的具体用法?Java CloudantClient怎么用?Java CloudantClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CloudantClient类属于com.cloudant.client.api包,在下文中一共展示了CloudantClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHelper

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public static Application.Helper getHelper() throws Exception {
    if(systemProperties.containsKey("PROP_FILE")) {
        properties.load(new FileInputStream(systemProperties.get("PROP_FILE")));
    }

    CloudantClient cloudantClient = ClientBuilder
            .url(new URL(getProperty("cloudant.url")))
            .username(getProperty("cloudant.username"))
            .password(getProperty("cloudant.password"))
            .build();
    WolframRepository wolframRepository = new WolframRepository(getProperty("wolfram.apiKey"));
    return new Application.Helper(
            cloudantClient,
            wolframRepository,
            getProperty("cloudant.chatDB"),
            getProperty("cloudant.feedbackDB"),
            getProperty("cloudant.explorerDB"),
            getProperty("tmdb.apiKey")
    );
}
 
开发者ID:dbpedia,项目名称:chatbot,代码行数:21,代码来源:TestUtility.java


示例2: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Profile("kubernetes")
@Bean
/*
 * Load the CloudantClient from the Kubernetes Secrets file.
 * This method is only loaded when the kubernetes profile is activated
 */
public CloudantClient client() throws IOException {

	String secrets = readKubeSecretsFiles();
	String secretsJson = StringUtils.newStringUtf8(Base64.decodeBase64(secrets));
	ObjectMapper mapper = new ObjectMapper();
	Map<String, Object> map = new HashMap<String, Object>();

	// convert JSON string to Map
	map = mapper.readValue(secretsJson, new TypeReference<Map<String, String>>(){});

	String username = (String) map.get("username");
	String password = (String) map.get("password");
	String url = "http://" + map.get("username") + ".cloudant.com";

	return ClientBuilder.url(new URL(url))
			.username(username)
			.password(password)
			.build();
}
 
开发者ID:IBM,项目名称:spring-boot-continuous-delivery,代码行数:26,代码来源:Application.java


示例3: Helper

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Autowired
public Helper(final CloudantClient cloudantClient,
              WolframRepository wolframRepository,
              @Value("${cloudant.chatDB}") String chatDBName,
              @Value("${cloudant.feedbackDB}") String feedbackDBName,
              @Value("${cloudant.explorerDB}") String explorerDBName,
              @Value("${tmdb.apiKey}") String tmdbApiKey) {
    try {
        chatDB = cloudantClient.database(chatDBName, true);
        feedbackDB = cloudantClient.database(feedbackDBName, true);
        explorerDB = cloudantClient.database(explorerDBName, true);
    }
    catch(Exception e) {
        logger.info("ERROR HERE");
        e.printStackTrace();
    }
    finally {
        this.tmdbApiKey = tmdbApiKey;
        this.wolframRepository = wolframRepository;

        riveScriptBot = new RiveScriptBot();
        eliza = new ElizaMain();
        eliza.readScript(true, "src/main/resources/eliza/script");

        sparql = new SPARQL(explorerDB);
        languageTool = new JLanguageTool(new AmericanEnglish());
        for (Rule rule : languageTool.getAllActiveRules()) {
            if (rule instanceof SpellingCheckRule) {
                List<String> wordsToIgnore = Arrays.asList("nlp");
                ((SpellingCheckRule) rule).addIgnoreTokens(wordsToIgnore);
            }
        }
    }
}
 
开发者ID:dbpedia,项目名称:chatbot,代码行数:35,代码来源:Application.java


示例4: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client() {
	ClientBuilder builder = ClientBuilder
		.url(config.getUrl())
		.username(config.getUsername())
		.password(config.getPassword());
	return builder.build();
}
 
开发者ID:IBM,项目名称:greeting-cloudant-spring,代码行数:9,代码来源:CloudantConfiguration.java


示例5: createClient

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
private static CloudantClient createClient() {
	
	String url;

	if (System.getenv("VCAP_SERVICES") != null) {
		// When running in Bluemix, the VCAP_SERVICES env var will have the credentials for all bound/connected services
		// Parse the VCAP JSON structure looking for cloudant.
		JsonObject cloudantCredentials = VCAPHelper.getCloudCredentials("cloudant");
		if(cloudantCredentials == null){
			System.out.println("No cloudant database service bound to this application");
			return null;
		}
		url = cloudantCredentials.get("url").getAsString();
	} else {
		System.out.println("Running locally. Looking for credentials in cloudant.properties");
		url = VCAPHelper.getLocalProperties("cloudant.properties").getProperty("cloudant_url");
		if(url == null || url.length()==0){
			System.out.println("To use a database, set the Cloudant url in src/main/resources/cloudant.properties");
			return null;
		}
	}

	try {
		System.out.println("Connecting to Cloudant");
		CloudantClient client = ClientBuilder.url(new URL(url)).build();
		return client;
	} catch (Exception e) {
		System.out.println("Unable to connect to database");
		//e.printStackTrace();
		return null;
	}
}
 
开发者ID:IBM-Cloud,项目名称:get-started-java,代码行数:33,代码来源:CloudantVisitorStore.java


示例6: clientBeanCreation

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Test
public void clientBeanCreation() {
    when(mockBuilder.build()).thenReturn(mockClient);
    
    this.context.register(MockClientBuilderConfig.class);
    EnvironmentTestUtils.addEnvironment(this.context, "cloudant.url=http://cloudant.com");
    this.context.refresh();
    CloudantClient client = this.context.getBean(CloudantClient.class);
    assertEquals(mockClient, client);
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:11,代码来源:EnableCloudantTest.java


示例7: clientBeanCreation

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Test
public void clientBeanCreation() {
    when(mockBuilder.build()).thenReturn(mockClient);
    
    this.context.register(MockClientBuilderConfig.class, CloudantAutoConfiguration.class);
    this.context.refresh();
    CloudantClient client = this.context.getBean(CloudantClient.class);
    assertEquals(mockClient, client);
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:10,代码来源:AutoConfigurationTest.java


示例8: connect

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
/**
 * Create the connection to the Cloudant database that we'll use for this
 * service.
 */
private void connect() {
	CloudantClient cloudant = new CloudantClient(
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_ACCOUNT),
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_USERNAME),
			AppPropertiesReader.getStringProperty(Constants.CLOUDANT_PASSWORD));
	db = cloudant.database(AppPropertiesReader.getStringProperty(Constants.CLOUDANT_DB_NAME), true);
	
}
 
开发者ID:IBM-MIL,项目名称:IBM-Ready-App-for-Telecommunications,代码行数:13,代码来源:CloudantService.java


示例9: CloudantConnector

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantConnector(ICloudantSettings cs){
    cloudantSettings = cs;
    ConnectOptions connectOptions = new ConnectOptions()
            .setConnectionTimeout(cloudantSettings.getConnectionTimeout())
            .setMaxConnections(cloudantSettings.getMaxConnections());
    cloudantClient = new CloudantClient(cloudantSettings.getUrl(),cloudantSettings.getUsername(),cloudantSettings.getPassword(), connectOptions);
}
 
开发者ID:SeniorAdvisor,项目名称:spring-data-cloudant,代码行数:8,代码来源:CloudantConnector.java


示例10: afterPropertiesSet

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    ConnectOptions connectionOptions = new ConnectOptions()
            .setConnectionTimeout(connectionTimeout)
            .setMaxConnections(maxConnections);
    cloudantClient = new CloudantClient(account,username,password,connectionOptions);
    gsonBuilder = new GsonBuilder().registerTypeHierarchyAdapter(BaseDocument.class,new UnmappedDataAdapter());
    cloudantClient.setGsonBuilder(gsonBuilder);
}
 
开发者ID:SeniorAdvisor,项目名称:spring-data-cloudant,代码行数:10,代码来源:CloudantFactoryBean.java


示例11: CloudantLocationStore

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantLocationStore(){
	CloudantClient cloudant = createClient();
	if(cloudant!=null){
	 db = cloudant.database(databaseName, true);
	}
}
 
开发者ID:IBM,项目名称:liberty-outage-reporter,代码行数:7,代码来源:CloudantLocationStore.java


示例12: hrsDb

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database hrsDb(CloudantClient cloudant) {
	return cloudant.database("hrs", true);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:CouchDbConfig.java


示例13: database

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database database(CloudantClient client) {
	Database db = client.database(config.getDb(), true);
	return db;
}
 
开发者ID:IBM,项目名称:greeting-cloudant-spring,代码行数:6,代码来源:CloudantConfiguration.java


示例14: CloudantVisitorStore

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantVisitorStore(){
	CloudantClient cloudant = createClient();
	if(cloudant!=null){
	 db = cloudant.database(databaseName, true);
	}
}
 
开发者ID:IBM-Cloud,项目名称:get-started-java,代码行数:7,代码来源:CloudantVisitorStore.java


示例15: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client(ClientBuilder builder) {
    return builder.build();
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:5,代码来源:CloudantConfiguration.java


示例16: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client() {
    return mockClient;
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:5,代码来源:EnableCloudantTest.java


示例17: client

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public CloudantClient client(ClientBuilder builder) {
    return builder.build();
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:6,代码来源:CloudantAutoConfiguration.java


示例18: database

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(name = "cloudant.db")
public Database database(CloudantClient client) {
    Database db = client.database(config.getDb(), true);
    return db;
}
 
开发者ID:cloudant-labs,项目名称:cloudant-spring,代码行数:7,代码来源:CloudantAutoConfiguration.java


示例19: account

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database account(CloudantClient cloudant) throws MalformedURLException {
	return cloudant.database("account", true);
}
 
开发者ID:IBM,项目名称:spring-boot-continuous-delivery,代码行数:5,代码来源:Application.java


示例20: prepare

import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
/**
 * Connect to Cloundant NoSQL DB based on the authentication credentials provided as
 * user inputs in the DMDeviceSample.properties file. 
 * 
 **/
@Override
public void prepare(String propertiesFile) {

	/**
	 * Load device properties file
	 */
	Properties props = new Properties();
	try {
		props.load(DeviceInitiatedHandlerSample.class.getResourceAsStream(propertiesFile));
	} catch (IOException e1) {
		System.err.println("Not able to read the properties file, exiting..");
		System.exit(-1);
	}
	
	/**
	 * Read individual parameter values from device properties file
	 */
		
	String username = trimedValue(props.getProperty("User-Name"));
	String password = trimedValue(props.getProperty("Password"));
	
	currentFirmwareVersion = (props.getProperty("DeviceInfo.fwVersion"));

	StringBuilder sb = new StringBuilder();
	sb.append("https://")
	.append(username)
	.append(":")
	.append(password)
	.append("@")
	.append(username)
	.append(".cloudant.com");
		
	System.out.println(sb);
	
	CloudantClient client = new CloudantClient(sb.toString(), username, password);
		
	System.out.println("Connected to Cloudant");
	System.out.println("Server Version: " + client.serverVersion());

	/**
	 * Pass the name of the Cloudant NoSQL Database to 'firmwareDB'
	 * To create the Cloudant NoSQL Database 'firmware_repository', replace 'false' with 'true'
	 */
	
	firmwareDB = client.database("firmware_repository", false);
	
	// Create update task
	updateTask = new DebianFirmwareUpdate(false);
	
	Thread t = new Thread(this);
	t.start();
}
 
开发者ID:ibm-watson-iot,项目名称:iot-device-samples,代码行数:58,代码来源:DeviceInitiatedHandlerSample.java



注:本文中的com.cloudant.client.api.CloudantClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileSystem类代码示例发布时间:2022-05-21
下一篇:
Java Duration类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap