formatting work
This commit is contained in:
@@ -3,7 +3,7 @@ package com.baeldung.couchbase.async;
|
||||
public interface CouchbaseEntity {
|
||||
|
||||
String getId();
|
||||
|
||||
|
||||
void setId(String id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,26 +8,27 @@ public class Person implements CouchbaseEntity {
|
||||
private String type;
|
||||
private String name;
|
||||
private String homeTown;
|
||||
|
||||
Person() {}
|
||||
|
||||
|
||||
Person() {
|
||||
}
|
||||
|
||||
public Person(Builder b) {
|
||||
this.id = b.id;
|
||||
this.type = b.type;
|
||||
this.name = b.name;
|
||||
this.homeTown = b.homeTown;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -39,19 +40,19 @@ public class Person implements CouchbaseEntity {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getHomeTown() {
|
||||
return homeTown;
|
||||
}
|
||||
|
||||
|
||||
public void setHomeTown(String homeTown) {
|
||||
this.homeTown = homeTown;
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String type;
|
||||
@@ -61,16 +62,16 @@ public class Person implements CouchbaseEntity {
|
||||
public static Builder newInstance() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
public Person build() {
|
||||
return new Person(this);
|
||||
}
|
||||
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
|
||||
+1
-3
@@ -13,9 +13,7 @@ import com.baeldung.couchbase.async.service.BucketService;
|
||||
public class PersonCrudService extends AbstractCrudService<Person> {
|
||||
|
||||
@Autowired
|
||||
public PersonCrudService(
|
||||
@Qualifier("TutorialBucketService") BucketService bucketService,
|
||||
PersonDocumentConverter converter) {
|
||||
public PersonCrudService(@Qualifier("TutorialBucketService") BucketService bucketService, PersonDocumentConverter converter) {
|
||||
super(bucketService, converter);
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -11,10 +11,7 @@ public class PersonDocumentConverter implements JsonDocumentConverter<Person> {
|
||||
|
||||
@Override
|
||||
public JsonDocument toDocument(Person p) {
|
||||
JsonObject content = JsonObject.empty()
|
||||
.put("type", "Person")
|
||||
.put("name", p.getName())
|
||||
.put("homeTown", p.getHomeTown());
|
||||
JsonObject content = JsonObject.empty().put("type", "Person").put("name", p.getName()).put("homeTown", p.getHomeTown());
|
||||
return JsonDocument.create(p.getId(), content);
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -10,19 +10,18 @@ public class RegistrationService {
|
||||
|
||||
@Autowired
|
||||
private PersonCrudService crud;
|
||||
|
||||
|
||||
public void registerNewPerson(String name, String homeTown) {
|
||||
Person person = new Person();
|
||||
person.setName(name);
|
||||
person.setHomeTown(homeTown);
|
||||
crud.create(person);
|
||||
}
|
||||
|
||||
|
||||
public Person findRegistrant(String id) {
|
||||
try{
|
||||
try {
|
||||
return crud.read(id);
|
||||
}
|
||||
catch(CouchbaseException e) {
|
||||
} catch (CouchbaseException e) {
|
||||
return crud.readFromReplica(id);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,9 +11,9 @@ public abstract class AbstractBucketService implements BucketService {
|
||||
protected void openBucket() {
|
||||
bucket = clusterService.openBucket(getBucketName(), getBucketPassword());
|
||||
}
|
||||
|
||||
|
||||
protected abstract String getBucketName();
|
||||
|
||||
|
||||
protected abstract String getBucketPassword();
|
||||
|
||||
public AbstractBucketService(ClusterService clusterService) {
|
||||
@@ -24,4 +24,4 @@ public abstract class AbstractBucketService implements BucketService {
|
||||
public Bucket getBucket() {
|
||||
return bucket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-50
@@ -40,7 +40,7 @@ public abstract class AbstractCrudService<T extends CouchbaseEntity> implements
|
||||
|
||||
@Override
|
||||
public void create(T t) {
|
||||
if(t.getId() == null) {
|
||||
if (t.getId() == null) {
|
||||
t.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
JsonDocument doc = converter.toDocument(t);
|
||||
@@ -73,18 +73,15 @@ public abstract class AbstractCrudService<T extends CouchbaseEntity> implements
|
||||
@Override
|
||||
public List<T> readBulk(Iterable<String> ids) {
|
||||
final AsyncBucket asyncBucket = bucket.async();
|
||||
Observable<JsonDocument> asyncOperation = Observable
|
||||
.from(ids)
|
||||
.flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
public Observable<JsonDocument> call(String key) {
|
||||
return asyncBucket.get(key);
|
||||
}
|
||||
});
|
||||
Observable<JsonDocument> asyncOperation = Observable.from(ids).flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
public Observable<JsonDocument> call(String key) {
|
||||
return asyncBucket.get(key);
|
||||
}
|
||||
});
|
||||
|
||||
final List<T> items = new ArrayList<T>();
|
||||
try {
|
||||
asyncOperation.toBlocking()
|
||||
.forEach(new Action1<JsonDocument>() {
|
||||
asyncOperation.toBlocking().forEach(new Action1<JsonDocument>() {
|
||||
public void call(JsonDocument doc) {
|
||||
T item = converter.fromDocument(doc);
|
||||
items.add(item);
|
||||
@@ -100,72 +97,42 @@ public abstract class AbstractCrudService<T extends CouchbaseEntity> implements
|
||||
@Override
|
||||
public void createBulk(Iterable<T> items) {
|
||||
final AsyncBucket asyncBucket = bucket.async();
|
||||
Observable
|
||||
.from(items)
|
||||
.flatMap(new Func1<T, Observable<JsonDocument>>() {
|
||||
Observable.from(items).flatMap(new Func1<T, Observable<JsonDocument>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Observable<JsonDocument> call(final T t) {
|
||||
if(t.getId() == null) {
|
||||
if (t.getId() == null) {
|
||||
t.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
JsonDocument doc = converter.toDocument(t);
|
||||
return asyncBucket.insert(doc)
|
||||
.retryWhen(RetryBuilder
|
||||
.anyOf(BackpressureException.class)
|
||||
.delay(Delay.exponential(TimeUnit.MILLISECONDS, 100))
|
||||
.max(10)
|
||||
.build());
|
||||
return asyncBucket.insert(doc).retryWhen(RetryBuilder.anyOf(BackpressureException.class).delay(Delay.exponential(TimeUnit.MILLISECONDS, 100)).max(10).build());
|
||||
}
|
||||
})
|
||||
.last()
|
||||
.toBlocking()
|
||||
.single();
|
||||
}).last().toBlocking().single();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBulk(Iterable<T> items) {
|
||||
final AsyncBucket asyncBucket = bucket.async();
|
||||
Observable
|
||||
.from(items)
|
||||
.flatMap(new Func1<T, Observable<JsonDocument>>() {
|
||||
Observable.from(items).flatMap(new Func1<T, Observable<JsonDocument>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Observable<JsonDocument> call(final T t) {
|
||||
JsonDocument doc = converter.toDocument(t);
|
||||
return asyncBucket.upsert(doc)
|
||||
.retryWhen(RetryBuilder
|
||||
.anyOf(BackpressureException.class)
|
||||
.delay(Delay.exponential(TimeUnit.MILLISECONDS, 100))
|
||||
.max(10)
|
||||
.build());
|
||||
return asyncBucket.upsert(doc).retryWhen(RetryBuilder.anyOf(BackpressureException.class).delay(Delay.exponential(TimeUnit.MILLISECONDS, 100)).max(10).build());
|
||||
}
|
||||
})
|
||||
.last()
|
||||
.toBlocking()
|
||||
.single();
|
||||
}).last().toBlocking().single();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBulk(Iterable<String> ids) {
|
||||
final AsyncBucket asyncBucket = bucket.async();
|
||||
Observable
|
||||
.from(ids)
|
||||
.flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
Observable.from(ids).flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Observable<JsonDocument> call(String key) {
|
||||
return asyncBucket.remove(key)
|
||||
.retryWhen(RetryBuilder
|
||||
.anyOf(BackpressureException.class)
|
||||
.delay(Delay.exponential(TimeUnit.MILLISECONDS, 100))
|
||||
.max(10)
|
||||
.build());
|
||||
return asyncBucket.remove(key).retryWhen(RetryBuilder.anyOf(BackpressureException.class).delay(Delay.exponential(TimeUnit.MILLISECONDS, 100)).max(10).build());
|
||||
}
|
||||
})
|
||||
.last()
|
||||
.toBlocking()
|
||||
.single();
|
||||
}).last().toBlocking().single();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ package com.baeldung.couchbase.async.service;
|
||||
import com.couchbase.client.java.Bucket;
|
||||
|
||||
public interface ClusterService {
|
||||
|
||||
|
||||
Bucket openBucket(String name, String password);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
private Cluster cluster;
|
||||
private Map<String, Bucket> buckets = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.create();
|
||||
@@ -27,7 +27,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
@Override
|
||||
synchronized public Bucket openBucket(String name, String password) {
|
||||
if(!buckets.containsKey(name)) {
|
||||
if (!buckets.containsKey(name)) {
|
||||
Bucket bucket = cluster.openBucket(name, password);
|
||||
buckets.put(name, bucket);
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ import com.couchbase.client.java.document.JsonDocument;
|
||||
public interface JsonDocumentConverter<T> {
|
||||
|
||||
JsonDocument toDocument(T t);
|
||||
|
||||
|
||||
T fromDocument(JsonDocument doc);
|
||||
}
|
||||
|
||||
@@ -14,40 +14,32 @@ import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
|
||||
public class CodeSnippets {
|
||||
|
||||
|
||||
static Cluster loadClusterWithDefaultEnvironment() {
|
||||
return CouchbaseCluster.create("localhost");
|
||||
}
|
||||
|
||||
static Cluster loadClusterWithCustomEnvironment() {
|
||||
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
|
||||
.connectTimeout(10000)
|
||||
.kvTimeout(3000)
|
||||
.build();
|
||||
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().connectTimeout(10000).kvTimeout(3000).build();
|
||||
return CouchbaseCluster.create(env, "localhost");
|
||||
}
|
||||
|
||||
|
||||
static Bucket loadDefaultBucketWithBlankPassword(Cluster cluster) {
|
||||
return cluster.openBucket();
|
||||
}
|
||||
|
||||
|
||||
static Bucket loadBaeldungBucket(Cluster cluster) {
|
||||
return cluster.openBucket("baeldung", "");
|
||||
}
|
||||
|
||||
static JsonDocument insertExample(Bucket bucket) {
|
||||
JsonObject content = JsonObject.empty()
|
||||
.put("name", "John Doe")
|
||||
.put("type", "Person")
|
||||
.put("email", "john.doe@mydomain.com")
|
||||
.put("homeTown", "Chicago")
|
||||
;
|
||||
JsonObject content = JsonObject.empty().put("name", "John Doe").put("type", "Person").put("email", "john.doe@mydomain.com").put("homeTown", "Chicago");
|
||||
String id = UUID.randomUUID().toString();
|
||||
JsonDocument document = JsonDocument.create(id, content);
|
||||
JsonDocument inserted = bucket.insert(document);
|
||||
return inserted;
|
||||
}
|
||||
|
||||
|
||||
static JsonDocument retrieveAndUpsertExample(Bucket bucket, String id) {
|
||||
JsonDocument document = bucket.get(id);
|
||||
JsonObject content = document.content();
|
||||
@@ -55,7 +47,7 @@ public class CodeSnippets {
|
||||
JsonDocument upserted = bucket.upsert(document);
|
||||
return upserted;
|
||||
}
|
||||
|
||||
|
||||
static JsonDocument replaceExample(Bucket bucket, String id) {
|
||||
JsonDocument document = bucket.get(id);
|
||||
JsonObject content = document.content();
|
||||
@@ -63,30 +55,29 @@ public class CodeSnippets {
|
||||
JsonDocument replaced = bucket.replace(document);
|
||||
return replaced;
|
||||
}
|
||||
|
||||
|
||||
static JsonDocument removeExample(Bucket bucket, String id) {
|
||||
JsonDocument removed = bucket.remove(id);
|
||||
return removed;
|
||||
}
|
||||
|
||||
|
||||
static JsonDocument getFirstFromReplicaExample(Bucket bucket, String id) {
|
||||
try{
|
||||
try {
|
||||
return bucket.get(id);
|
||||
}
|
||||
catch(CouchbaseException e) {
|
||||
} catch (CouchbaseException e) {
|
||||
List<JsonDocument> list = bucket.getFromReplica(id, ReplicaMode.FIRST);
|
||||
if(!list.isEmpty()) {
|
||||
if (!list.isEmpty()) {
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static JsonDocument getLatestReplicaVersion(Bucket bucket, String id) {
|
||||
long maxCasValue = -1;
|
||||
JsonDocument latest = null;
|
||||
for(JsonDocument replica : bucket.getFromReplica(id, ReplicaMode.ALL)) {
|
||||
if(replica.cas() > maxCasValue) {
|
||||
for (JsonDocument replica : bucket.getFromReplica(id, ReplicaMode.ALL)) {
|
||||
if (replica.cas() > maxCasValue) {
|
||||
latest = replica;
|
||||
maxCasValue = replica.cas();
|
||||
}
|
||||
|
||||
@@ -6,24 +6,25 @@ public class Person {
|
||||
private String type;
|
||||
private String name;
|
||||
private String homeTown;
|
||||
|
||||
Person() {}
|
||||
|
||||
|
||||
Person() {
|
||||
}
|
||||
|
||||
public Person(Builder b) {
|
||||
this.id = b.id;
|
||||
this.type = b.type;
|
||||
this.name = b.name;
|
||||
this.homeTown = b.homeTown;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -35,19 +36,19 @@ public class Person {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getHomeTown() {
|
||||
return homeTown;
|
||||
}
|
||||
|
||||
|
||||
public void setHomeTown(String homeTown) {
|
||||
this.homeTown = homeTown;
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String type;
|
||||
@@ -57,16 +58,16 @@ public class Person {
|
||||
public static Builder newInstance() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
public Person build() {
|
||||
return new Person(this);
|
||||
}
|
||||
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
|
||||
+5
-5
@@ -16,15 +16,15 @@ import com.couchbase.client.java.document.JsonDocument;
|
||||
|
||||
@Service
|
||||
public class PersonCrudService implements CrudService<Person> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TutorialBucketService bucketService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private PersonDocumentConverter converter;
|
||||
|
||||
|
||||
private Bucket bucket;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
bucket = bucketService.getBucket();
|
||||
@@ -32,7 +32,7 @@ public class PersonCrudService implements CrudService<Person> {
|
||||
|
||||
@Override
|
||||
public void create(Person person) {
|
||||
if(person.getId() == null) {
|
||||
if (person.getId() == null) {
|
||||
person.setId(UUID.randomUUID().toString());
|
||||
}
|
||||
JsonDocument document = converter.toDocument(person);
|
||||
|
||||
+1
-4
@@ -11,10 +11,7 @@ public class PersonDocumentConverter implements JsonDocumentConverter<Person> {
|
||||
|
||||
@Override
|
||||
public JsonDocument toDocument(Person p) {
|
||||
JsonObject content = JsonObject.empty()
|
||||
.put("type", "Person")
|
||||
.put("name", p.getName())
|
||||
.put("homeTown", p.getHomeTown());
|
||||
JsonObject content = JsonObject.empty().put("type", "Person").put("name", p.getName()).put("homeTown", p.getHomeTown());
|
||||
return JsonDocument.create(p.getId(), content);
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -10,19 +10,18 @@ public class RegistrationService {
|
||||
|
||||
@Autowired
|
||||
private PersonCrudService crud;
|
||||
|
||||
|
||||
public void registerNewPerson(String name, String homeTown) {
|
||||
Person person = new Person();
|
||||
person.setName(name);
|
||||
person.setHomeTown(homeTown);
|
||||
crud.create(person);
|
||||
}
|
||||
|
||||
|
||||
public Person findRegistrant(String id) {
|
||||
try{
|
||||
try {
|
||||
return crud.read(id);
|
||||
}
|
||||
catch(CouchbaseException e) {
|
||||
} catch (CouchbaseException e) {
|
||||
return crud.readFromReplica(id);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@ import com.couchbase.client.java.Bucket;
|
||||
public interface BucketService {
|
||||
|
||||
Bucket getBucket();
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,11 +7,11 @@ import com.couchbase.client.java.Bucket;
|
||||
import com.couchbase.client.java.document.JsonDocument;
|
||||
|
||||
public interface ClusterService {
|
||||
|
||||
|
||||
Bucket openBucket(String name, String password);
|
||||
|
||||
|
||||
List<JsonDocument> getDocuments(Bucket bucket, Iterable<String> keys);
|
||||
|
||||
|
||||
List<JsonDocument> getDocumentsAsync(AsyncBucket bucket, Iterable<String> keys);
|
||||
|
||||
}
|
||||
|
||||
+10
-13
@@ -29,7 +29,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
private Cluster cluster;
|
||||
private Map<String, Bucket> buckets = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.create();
|
||||
@@ -38,7 +38,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
@Override
|
||||
synchronized public Bucket openBucket(String name, String password) {
|
||||
if(!buckets.containsKey(name)) {
|
||||
if (!buckets.containsKey(name)) {
|
||||
Bucket bucket = cluster.openBucket(name, password);
|
||||
buckets.put(name, bucket);
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
@Override
|
||||
public List<JsonDocument> getDocuments(Bucket bucket, Iterable<String> keys) {
|
||||
List<JsonDocument> docs = new ArrayList<>();
|
||||
for(String key : keys) {
|
||||
for (String key : keys) {
|
||||
JsonDocument doc = bucket.get(key);
|
||||
if(doc != null) {
|
||||
if (doc != null) {
|
||||
docs.add(doc);
|
||||
}
|
||||
}
|
||||
@@ -59,18 +59,15 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
@Override
|
||||
public List<JsonDocument> getDocumentsAsync(final AsyncBucket asyncBucket, Iterable<String> keys) {
|
||||
Observable<JsonDocument> asyncBulkGet = Observable
|
||||
.from(keys)
|
||||
.flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
public Observable<JsonDocument> call(String key) {
|
||||
return asyncBucket.get(key);
|
||||
}
|
||||
});
|
||||
Observable<JsonDocument> asyncBulkGet = Observable.from(keys).flatMap(new Func1<String, Observable<JsonDocument>>() {
|
||||
public Observable<JsonDocument> call(String key) {
|
||||
return asyncBucket.get(key);
|
||||
}
|
||||
});
|
||||
|
||||
final List<JsonDocument> docs = new ArrayList<>();
|
||||
try {
|
||||
asyncBulkGet.toBlocking()
|
||||
.forEach(new Action1<JsonDocument>() {
|
||||
asyncBulkGet.toBlocking().forEach(new Action1<JsonDocument>() {
|
||||
public void call(JsonDocument doc) {
|
||||
docs.add(doc);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.baeldung.couchbase.spring.service;
|
||||
public interface CrudService<T> {
|
||||
|
||||
void create(T t);
|
||||
|
||||
|
||||
T read(String id);
|
||||
|
||||
|
||||
T readFromReplica(String id);
|
||||
|
||||
|
||||
void update(T t);
|
||||
|
||||
|
||||
void delete(String id);
|
||||
|
||||
|
||||
boolean exists(String id);
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,6 +5,6 @@ import com.couchbase.client.java.document.JsonDocument;
|
||||
public interface JsonDocumentConverter<T> {
|
||||
|
||||
JsonDocument toDocument(T t);
|
||||
|
||||
|
||||
T fromDocument(JsonDocument doc);
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,15 +14,15 @@ public class TutorialBucketService implements BucketService {
|
||||
|
||||
@Autowired
|
||||
private ClusterService couchbase;
|
||||
|
||||
|
||||
private Bucket bucket;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
bucket = couchbase.openBucket("baeldung-tutorial", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Bucket getBucket() {
|
||||
return bucket;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user