protected void testConnect(HttpClient client) { try { RestTemplate rt = new RestTemplate(client); rt.head("/", new StdResponseHandler<Void>()); } catch (Exception e) { throw new BeanCreationException(String.format("Cannot connect to CouchDb@%s:%s", host, port), e); } }
public StdCouchDbInstance(HttpClient client, ObjectMapperFactory of) { Assert.notNull(client, "HttpClient may not be null"); Assert.notNull(of, "ObjectMapperFactory may not be null"); this.client = client; this.restTemplate = new RestTemplate(client); this.objectMapper = of.createObjectMapper(); this.objectMapperFactory = of; }
private void removeDatabase() { HttpClient connection = couchDbConnector.getConnection(); RestTemplate restTemplate = new RestTemplate(connection); restTemplate.delete(couchDbConnector.path()); couchDbConnector.createDatabaseIfNotExists(); }
private void removeDatabase() { HttpClient connection = couchDbConnector.getConnection(); RestTemplate restTemplate = new RestTemplate(connection); restTemplate.delete(couchDbConnector.path()); couchDbConnector.createDatabaseIfNotExists(); }
public StdCouchDbConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om) { Assert.hasText(databaseName, "DatabaseName may not be null or empty"); Assert.notNull(dbi, "CouchDbInstance may not be null"); Assert.notNull(om, "ObjectMapperFactory may not be null"); DbPath dbp = DbPath.fromString(databaseName); dbName = dbp.getDbName(); this.dbURI = URI.prototype(dbp.getPath()); this.dbInstance = dbi; this.objectMapper = om.createObjectMapper(this); this.jsonSerializer = new StreamingJsonSerializer(objectMapper); this.restTemplate = new RestTemplate(dbi.getConnection()); this.revisionHandler = new RevisionResponseHandler(objectMapper); this.docIdResponseHandler = new DocIdResponseHandler(objectMapper); this.queryExecutor = new DefaultQueryExecutor(this.restTemplate); collectionBulkExecutor = new BulkOperationCollectionBulkExecutor(dbURI, restTemplate, objectMapper) { @Override protected JsonSerializer getJsonSerializer() { return jsonSerializer; } }; localBulkBuffer = new DefaultLocalBulkBuffer() { @Override protected BulkExecutor getBulkExecutor() { return collectionBulkExecutor; } }; inputStreamBulkExecutor = new InputStreamWrapperBulkExecutor(dbURI, restTemplate, objectMapper); }