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

Java StdCouchDbInstance类代码示例

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

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



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

示例1: beforeClass

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws MalformedURLException {
    HttpClient httpClient = new StdHttpClient.Builder()
            .url("http://192.168.99.100:5984/")
            .username("mapUser")
            .password("myCouchDBSecret")
            .build();

    dbi = new StdCouchDbInstance(httpClient);
    CouchDbConnector dbc = dbi.createConnector(CouchInjector.DB_NAME, false);

    repo = new MapRepository();
    repo.db = dbc;
    repo.postConstruct();
    debugWriter = repo.sites.mapper.writerWithDefaultPrettyPrinter();
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:17,代码来源:TestLiveMapPlacement.java


示例2: initConnection

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
private CouchDbConnector initConnection(String dbName, String userName, String password, String host, int port, boolean enableSSL, int timeout)
  {
Builder builder = new StdHttpClient.Builder()
.host(host)
.port(port)
.connectionTimeout(timeout)
.socketTimeout(timeout)
.enableSSL(enableSSL); 

      
      if(userName != null && !userName.isEmpty() && password != null && !password.isEmpty())
          builder.username(userName).password(password);
      
      dbInstance = new StdCouchDbInstance(builder.build());
      if (!dbInstance.checkIfDbExists(dbName))
      	dbInstance.createDatabase(dbName);
      CouchDbConnector couchDB = dbInstance.createConnector(dbName, true);   
      return couchDB;


  }
 
开发者ID:cfibmers,项目名称:open-Autoscaler,代码行数:22,代码来源:CouchDbConnectionManager.java


示例3: connect

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


示例4: connector

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


示例5: CouchDbLiteStoreAdapter

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
public CouchDbLiteStoreAdapter(Context context) {
	if (couchDbServer == null) {
		String filesDir = context.getFilesDir().getAbsolutePath();
		try {
			couchDbServer = new CBLServer(filesDir);
			couchDbClient = new CBLiteHttpClient(couchDbServer);
			couchDb = new StdCouchDbInstance(couchDbClient);
			db = couchDbServer.getDatabaseNamed(TOUCH_DB_NAME, true);
			
			allReports = new AllReportsByTimestampDesc(db, DESIGN_DOC_NAME);
			pendingSyncReports = new PendingSyncReports(db, DESIGN_DOC_NAME);
			uploadedReports = new UploadedReports(db, DESIGN_DOC_NAME);
		} catch (IOException e) {
			Log.e("UnicefGisStore", "Error starting TDServer", e);
		}
	}
}
 
开发者ID:UNICEF-Youth-Section,项目名称:unicef_gis_mobile,代码行数:18,代码来源:CouchDbLiteStoreAdapter.java


示例6: testAttachments

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
public void testAttachments() throws IOException {

        HttpClient httpClient = new CBLiteHttpClient(manager);
        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);

        CouchDbConnector dbConnector = dbInstance.createConnector(DEFAULT_TEST_DB, true);

        TestObject test = new TestObject(1, false, "ektorp");

        //create a document
        dbConnector.create(test);

        //attach file to it
        byte[] attach1 = "This is the body of attach1".getBytes();
        ByteArrayInputStream b = new ByteArrayInputStream(attach1);
        AttachmentInputStream a = new AttachmentInputStream("attach", b, "text/plain");
        dbConnector.createAttachment(test.getId(), test.getRevision(), a);

        AttachmentInputStream readAttachment = dbConnector.getAttachment(test.getId(), "attach");
        Assert.assertEquals("text/plain", readAttachment.getContentType());
        Assert.assertEquals("attach", readAttachment.getId());

        BufferedReader br = new BufferedReader(new InputStreamReader(readAttachment));
        Assert.assertEquals("This is the body of attach1", br.readLine());
    }
 
开发者ID:couchbaselabs,项目名称:couchbase-lite-android-ektorp,代码行数:26,代码来源:Attachments.java


示例7: before

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@Before
public void before() throws Exception {
    loadConfiguration();

    if (isConfigured()) {
        final int timeout = 8 * 1000; // 8 seconds should be more than
                                      // enough
        httpClient = new StdHttpClient.Builder().socketTimeout(timeout).host(getHostname()).build();

        // set up a simple database
        couchDbInstance = new StdCouchDbInstance(httpClient);

        final String databaseName = getDatabaseName();
        if (couchDbInstance.getAllDatabases().contains(databaseName)) {
            throw new IllegalStateException("Couch DB instance already has a database called " + databaseName);
        }
        connector = couchDbInstance.createConnector(databaseName, true);

        final String[] columnNames = new String[] { "name", "gender", "age" };
        final ColumnType[] columnTypes = new ColumnType[] { ColumnType.STRING, ColumnType.CHAR,
                ColumnType.INTEGER };
        predefinedTableDef = new SimpleTableDef(databaseName, columnNames, columnTypes);
    }

}
 
开发者ID:apache,项目名称:metamodel,代码行数:26,代码来源:CouchDbDataContextTest.java


示例8: beforeClass

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws MalformedURLException {
    roomOwner = "testOwner";
    HttpClient httpClient = new StdHttpClient.Builder()
            .url("http://127.0.0.1:5984/")
            .build();
    dbi = new StdCouchDbInstance(httpClient);
    CouchDbConnector dbc = dbi.createConnector(CouchInjector.DB_NAME, false);

    repo = new MapRepository();
    repo.db = dbc;
    repo.postConstruct();
    debugWriter = repo.sites.mapper.writerWithDefaultPrettyPrinter();
    swapRoomsAccessPolicy = new AccessCertainResourcesPolicy(Collections.singleton(SiteSwapPermission.class));
}
 
开发者ID:gameontext,项目名称:gameon-map,代码行数:16,代码来源:TestLiveRoomSwap.java


示例9: initConnection

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


示例10: setup

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


示例11: teardown

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


示例12: init

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


示例13: getDB

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
public UpdateableDataContext getDB(String user, String password) throws Exception {
	HttpClient httpClient = new StdHttpClient.Builder().host(getHostname()).password(password).username(user).maxConnections(4).build();
	StdCouchDbInstance couchDbInstance = new StdCouchDbInstance(httpClient);
	
	UpdateableDataContext dataContext = new CouchDbDataContext(couchDbInstance);
	return dataContext;
}
 
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:8,代码来源:CouchConnectionProperties.java


示例14: create

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@Override
public CouchDbInstance create(CloudantServiceInfo serviceInfo,
        ServiceConnectorConfig serviceConnectorConfig) {
    HttpClient httpClient;
    try {
        httpClient = new StdHttpClient.Builder()
                .url(serviceInfo.getUrl())
                .build();
        return new StdCouchDbInstance(httpClient);
    } catch (MalformedURLException e) {
        LOG.logp(Level.WARNING, CloudantInstanceCreator.class.getName(), "create", "Error parsing URL", e);
        return null;
    }
}
 
开发者ID:IBM-Cloud,项目名称:bluemix-cloud-connectors,代码行数:15,代码来源:CloudantInstanceCreator.java


示例15: init

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@PostConstruct
private void init() {
    HttpClient httpClient;
    httpClient = new StdHttpClient.Builder()
            .host("127.0.0.1")
            .port(5984)
            .username("admin")
            .password("password")
            .build();
    CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
    couchDBConnector = dbInstance.createConnector("relax-dms", false);

    restTemplate = new RestTemplate(httpClient);
}
 
开发者ID:martin-kanis,项目名称:relax-dms,代码行数:15,代码来源:DBConnectorFactory.java


示例16: configure

import org.ektorp.impl.StdCouchDbInstance; //导入依赖的package包/类
@Override
protected void configure() {
	try {
		CouchDbInstance couchDbInstance = new StdCouchDbInstance(new StdHttpClient.Builder()
				.url(couchDbConfig.getUrl())
				.username(couchDbConfig.getAdmin().getUsername())
				.password(couchDbConfig.getAdmin().getPassword())
				.maxConnections(couchDbConfig.getMaxConnections())
				.build());
		DbConnectorFactory connectorFactory = new DbConnectorFactory(couchDbInstance, couchDbConfig.getDbPrefix());

		CouchDbConnector dataSourceConnector = connectorFactory.createConnector(OdsRegistrationRepository.DATABASE_NAME, true);
		bind(CouchDbConnector.class).annotatedWith(Names.named(OdsRegistrationRepository.DATABASE_NAME)).toInstance(dataSourceConnector);

		CouchDbConnector clientConnector = connectorFactory.createConnector(ClientRepository.DATABASE_NAME, true);
		bind(CouchDbConnector.class).annotatedWith(Names.named(ClientRepository.DATABASE_NAME)).toInstance(clientConnector);

		CouchDbConnector eplAdapterConnector = connectorFactory.createConnector(EplAdapterRepository.DATABASE_NAME, true);
		bind(CouchDbConnector.class).annotatedWith(Names.named(EplAdapterRepository.DATABASE_NAME)).toInstance(eplAdapterConnector);
		
		CouchDbConnector userConnector = connectorFactory.createConnector(UserRepository.DATABASE_NAME, true);
		bind(CouchDbConnector.class).annotatedWith(Names.named(UserRepository.DATABASE_NAME)).toInstance(userConnector);

	} catch (MalformedURLException mue) {
		throw new RuntimeException(mue);
	}
}
 
开发者ID:jvalue,项目名称:cep-service,代码行数:28,代码来源:DbModule.java


示例17: createConnector

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


示例18: doTest

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


示例19: initialize

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


示例20: setProperties

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DateFormatProvider类代码示例发布时间:2022-05-21
下一篇:
Java SubsystemMarshallingContext类代码示例发布时间: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