本文整理汇总了Java中com.cloudant.client.api.CloudantClient类的典型用法代码示例。如果您正苦于以下问题:Java CloudantClient类的具体用法?Java CloudantClient怎么用?Java CloudantClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudantClient类属于com.cloudant.client.api包,在下文中一共展示了CloudantClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
);
}
示例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();
}
示例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);
}
}
}
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: CloudantLocationStore
import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantLocationStore(){
CloudantClient cloudant = createClient();
if(cloudant!=null){
db = cloudant.database(databaseName, true);
}
}
示例12: hrsDb
import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database hrsDb(CloudantClient cloudant) {
return cloudant.database("hrs", true);
}
示例13: database
import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public Database database(CloudantClient client) {
Database db = client.database(config.getDb(), true);
return db;
}
示例14: CloudantVisitorStore
import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
public CloudantVisitorStore(){
CloudantClient cloudant = createClient();
if(cloudant!=null){
db = cloudant.database(databaseName, true);
}
}
示例15: client
import com.cloudant.client.api.CloudantClient; //导入依赖的package包/类
@Bean
public CloudantClient client(ClientBuilder builder) {
return builder.build();
}