You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/reactiverepository.adoc
+9-29Lines changed: 9 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -11,25 +11,17 @@ So make sure you’ve got a sound understanding of the basic concepts explained
11
11
[[couchbase.reactiverepository.libraries]]
12
12
== Reactive Composition Libraries
13
13
14
-
Couchbase Java SDK 2.x has taken a reactive programming approach since its inception using an early reactive extension to JVM, https://github.com/ReactiveX/RxJava/tree/1.x/[RxJava1].
15
-
It provides RxJava1 observable sequence API to compose asynchronous database operations.
14
+
The Couchbase Java SDK 3.x moved from RxJava to Reactor, so it blends in very nicely with the reactive spring ecosystem.
16
15
17
16
Reactive Couchbase repositories provide project Reactor wrapper types and can be used by simply extending from one of the library-specific repository interfaces:
18
17
19
-
* ReactiveCrudRepository
20
-
21
-
* ReactiveSortingRepository
22
-
23
-
Spring-data-couchbase converts RxJava 1 observables to reactor types by using reactive-streams adapters from https://github.com/ReactiveX/[RxJavaReactiveStreams]
24
-
for convenience since these conversions can easily clutter application code.
25
-
This transformation happens on same thread.
26
-
It also provides direct access to RxJava1 observable sequence API from SDK through RxJavaCouchbaseOperations methods.
18
+
* ReactiveCrudRepository
19
+
* ReactiveSortingRepository
27
20
28
21
[[couchbase.reactiverepository.usage]]
29
22
== Usage
30
23
31
-
To access domain entities stored in a Couchbase bucket you can leverage our sophisticated repository support that eases implementing those quite significantly.
32
-
To do so, simply create an interface for your repository:
24
+
Let's create a simple entity to start with:
33
25
34
26
.Sample Person entity
35
27
====
@@ -48,7 +40,7 @@ public class Person {
48
40
----
49
41
====
50
42
51
-
We have a quite simple domain object here.
43
+
A corresponding repository implementation may look like this:
52
44
53
45
.Basic repository interface to persist Person entities
54
46
====
@@ -71,28 +63,16 @@ For JavaConfig use the `@EnableReactiveCouchbaseRepositories` annotation.
71
63
The annotation carries the very same attributes like the namespace element.
72
64
If no base package is configured the infrastructure will scan the package of the annotated configuration class.
73
65
66
+
Also note that if you are using it in a spring boot setup you likely can omit the annotation since it is autoconfigured for you.
67
+
74
68
.JavaConfig for repositories
75
69
====
76
70
[source,java]
77
71
----
78
72
@Configuration
79
73
@EnableReactiveCouchbaseRepositories
80
-
class ApplicationConfig extends AbstractReactiveCouchbaseConfiguration {
81
-
82
-
@Override
83
-
protected List<String> getBootstrapHosts() {
84
-
return Collections.singletonList("127.0.0.1");
85
-
}
86
-
87
-
@Override
88
-
protected String getBucketName() {
89
-
return "default";
90
-
}
91
-
92
-
@Override
93
-
protected String getPassword() {
94
-
return "";
95
-
}
74
+
class ApplicationConfig extends AbstractCouchbaseConfiguration {
0 commit comments