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


Java StdCouchDbConnector类代码示例

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


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

示例1: connector

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Bean
public StdCouchDbConnector connector() throws Exception {

    String url = "http://localhost:5984/";
    String databaseName = "ektorp-integration-tests";

    Properties properties = new Properties();
    properties.setProperty("autoUpdateViewOnChange", "true");

    HttpClientFactoryBean factory = new HttpClientFactoryBean();
    factory.setUrl(url);
    factory.setProperties(properties);
    factory.afterPropertiesSet();
    HttpClient client = factory.getObject();

    CouchDbInstance dbInstance = new StdCouchDbInstance(client);
    return new StdCouchDbConnector(databaseName, dbInstance);
}
 
开发者ID:rwitzel,项目名称:CouchRepository,代码行数:19,代码来源:EktorpTestConfiguration.java

示例2: init

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
/**
 * Inits the.
 */

@PostConstruct
public void init() {

  LOGGER.trace("Initializing version: " + WifKeys.WIF_KEY_VERSION);
  // TODO do it more elegant,enable the rewriting of reviews, only for
  // development
  System.setProperty("org.ektorp.support.AutoUpdateViewOnChange", "true");
  repoURL = couchDBConfig.getRepoURL();
  wifDB = couchDBConfig.getWifDB();
  loginRequired = couchDBConfig.isLoginRequired();
  LOGGER.info("Using CouchDB URL {}, with What If database: {} ", repoURL,
      wifDB);
  try {
    if (loginRequired) {

      LOGGER.info("using the login name {} ", couchDBConfig.getLogin());
      httpClient = new StdHttpClient.Builder().url(repoURL)
          .username(couchDBConfig.getLogin())
          .password(couchDBConfig.getPassword()).build();
    } else {
      LOGGER.info("authentication not required, not using credentials");
      httpClient = new StdHttpClient.Builder().url(repoURL).build();
    }
  } catch (MalformedURLException e) {
    LOGGER.error(
        "MalformedURLException: Using CouchDB URL {} , with What If database: {} "
            + repoURL, wifDB);
  }

  CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
  // TODO There should be one for each repository
  db = new StdCouchDbConnector(wifDB, dbInstance);

}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:39,代码来源:CouchDBManager.java

示例3: createConnector

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的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

示例4: doTest

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Test
public void doTest() {
	Item item = new Item();
	item.setItemField("test" + System.currentTimeMillis());

	CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
	db = new StdCouchDbConnector("mydatabase", dbInstance);
	db.createDatabaseIfNotExists();
	db.create(item);
	Assert.assertEquals(item.getItemField(), db.get(Item.class, item.getId()).getItemField());
}
 
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:Larissa,代码行数:12,代码来源:ITCouchDB.java

示例5: initialize

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
/**
 * Initialize the data store by reading the credentials, setting the client's properties up and
 * reading the mapping file. Initialize is called when then the call to
 * {@link org.apache.gora.store.DataStoreFactory#createDataStore} is made.
 *
 * @param keyClass
 * @param persistentClass
 * @param properties
 */
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) {
  LOG.debug("Initializing CouchDB store");
  super.initialize(keyClass, persistentClass, properties);

  final CouchDBParameters params = CouchDBParameters.load(properties);

  try {
    final String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE);
    final HttpClient httpClient = new StdHttpClient.Builder()
        .url("http://" + params.getServer() + ":" + params.getPort())
        .build();

    dbInstance = new StdCouchDbInstance(httpClient);

    final CouchDBMappingBuilder<K, T> builder = new CouchDBMappingBuilder<>(this);
    LOG.debug("Initializing CouchDB store with mapping {}.", new Object[] { mappingFile });
    builder.readMapping(mappingFile);
    mapping = builder.build();

    final ObjectMapperFactory myObjectMapperFactory = new CouchDBObjectMapperFactory();
    myObjectMapperFactory.createObjectMapper().addMixInAnnotations(persistentClass, CouchDbDocument.class);

    db = new StdCouchDbConnector(mapping.getDatabaseName(), dbInstance, myObjectMapperFactory);
    db.createDatabaseIfNotExists();

  } catch (IOException e) {
    LOG.error("Error while initializing CouchDB store: {}", new Object[] { e.getMessage() });
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:41,代码来源:CouchDBStore.java

示例6: setProperties

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
public void setProperties(String propertiesFile) throws IOException, CouchDbJobStoreException {
    Properties properties = new Properties();
    properties.load(ClassLoader.class.getResourceAsStream(propertiesFile));

    HttpClientFactoryBean httpClientFactoryBean = new HttpClientFactoryBean();
    httpClientFactoryBean.setProperties(extractHttpClientProperties(properties));
    httpClientFactoryBean.setCaching(false);
    try {
        httpClientFactoryBean.afterPropertiesSet();

        String dbNameGeneratorClass = properties.getProperty("db.nameGenerator");
        String dbName = properties.getProperty("db.name");

        DatabaseNameProvider dbNameGenerator;
        if (dbNameGeneratorClass == null || dbNameGeneratorClass.equals("")) {
            dbNameGenerator = new DefaultDatabaseNameProvider(dbName);
        } else {
            Class<?> aClass = Class.forName(dbNameGeneratorClass);
            dbNameGenerator = (DatabaseNameProvider) aClass.newInstance();
        }

        String databaseName = dbNameGenerator.getDatabaseName();
        if (databaseName == null || databaseName.equals("")) {
            databaseName = "scheduler";
        }
        CouchDbConnector connector = new StdCouchDbConnector(databaseName, new StdCouchDbInstance(httpClientFactoryBean.getObject()));
        this.jobStore = new CouchDbJobStore(connector);
        this.triggerStore = new CouchDbTriggerStore(connector);
        this.calendarStore = new CouchDbCalendarStore(connector);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new CouchDbJobStoreException(e);
    }
}
 
开发者ID:motech,项目名称:quartz-couchdb-store,代码行数:35,代码来源:CouchDbStore.java

示例7: couchDbConnector

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Bean
public CouchDbConnector couchDbConnector(CouchDbInstance couchDbInstance) {
    CouchDbConnector connector = new StdCouchDbConnector("status", couchDbInstance);
    connector.createDatabaseIfNotExists();
    return connector;
}
 
开发者ID:IBM-Cloud,项目名称:bluemix-cloud-connectors,代码行数:7,代码来源:App.java

示例8: statusRepository

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Produces
public StatusRepository statusRepository() {
    CouchDbInstance db = cloud.getServiceConnector("connectors-sample", CouchDbInstance.class, null /* default config */);
    return new StatusRepository(new StdCouchDbConnector("status", db));
}
 
开发者ID:IBM-Cloud,项目名称:bluemix-cloud-connectors,代码行数:6,代码来源:CloudantBean.java

示例9: dbConnector

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Bean
public CouchDbConnector dbConnector() throws MalformedURLException {
    CouchDbConnector db = new StdCouchDbConnector("midgard", dbInstance());
    db.createDatabaseIfNotExists();
    return db;
}
 
开发者ID:ViteFalcon,项目名称:midgard,代码行数:7,代码来源:DatabaseConfiguration.java

示例10: expose

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
@Produces
public CouchDbConnector expose() {
    CouchDbConnector db = new StdCouchDbConnector("playerdb", dbi);
    db.createDatabaseIfNotExists();
    return db;
}
 
开发者ID:gameontext,项目名称:gameon-player,代码行数:7,代码来源:CouchInjector.java

示例11: setupCouchDb

import org.ektorp.impl.StdCouchDbConnector; //导入依赖的package包/类
/**
 * This function setups up the CouchDB connection, creates the database and associated views.
 * @param server The server to connect to.
 * @param dbName The name of the database.
 * @return The connection.
 * @throws MalformedURLException If the server string cannot be understood.
 */
public static CouchDbConnector setupCouchDb(String server, String dbName) throws MalformedURLException {
	HttpClient httpClient = new StdHttpClient.Builder().url(server).build();

	CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
	StdCouchDbConnector db = new StdCouchDbConnector(dbName, dbInstance);
	db.createDatabaseIfNotExists();
	LOG.info("Connected to CouchDB. Relax.");

	try {
		db.getDesignDocInfo("pepperscore");
	} catch (DocumentNotFoundException e) {
		Map<String, Object> doc = new HashMap<String, Object>();
		doc.put("language", "javascript");

		Map<String, Object> views = new HashMap<String, Object>();
		doc.put("views", views);

		HashMap<String, String> bysessionidView = new HashMap<String, String>();
		bysessionidView.put("map",
				"function(doc) {\n" +
						"  emit(doc.sessionId, doc);\n" +
						"}");
		views.put("bysessionid", bysessionidView);

		HashMap<String, String> inprogressroundView = new HashMap<String, String>();
		inprogressroundView.put("map",
				"function(doc) {\n" +
						"  if (doc.round) {\n" +
						"    if ((doc.round.start) && (!doc.round.end)) {\n" +
						"      emit(doc.sessionId, doc.round.start);\n" +
						"    }\n" +
						"  }" +
						"\n}");
		views.put("inprogressround", inprogressroundView);

		db.create("_design/pepperscore", doc);
	}

	return db;
}
 
开发者ID:SiphonSquirrel,项目名称:jepperscore,代码行数:48,代码来源:CouchDbUtils.java


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