Compare commits
207 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ced6fa7d9 | ||
|
|
f9405ed2fd | ||
|
|
14c874e701 | ||
|
|
7273fe410d | ||
|
|
23a54e3a5e | ||
|
|
10bec0fa36 | ||
|
|
39803621b1 | ||
|
|
154f691fbd | ||
|
|
770c28835f | ||
|
|
5fb1cabfbb | ||
|
|
f6a23b5e3d | ||
|
|
fc271a37f8 | ||
|
|
6ef697f6b7 | ||
|
|
17e958e696 | ||
|
|
8318a78fd0 | ||
|
|
89a4b08b36 | ||
|
|
52730a5f90 | ||
|
|
bf3d118dbd | ||
|
|
72d0e69b3b | ||
|
|
fc3930663a | ||
|
|
9c17ee09bb | ||
|
|
be84b18376 | ||
|
|
d7ac0c8260 | ||
|
|
40a50e02e5 | ||
|
|
c93db7b42b | ||
|
|
99091ad42c | ||
|
|
7d1cfd84ad | ||
|
|
158abf9d74 | ||
|
|
d90653d7f6 | ||
|
|
29571159fd | ||
|
|
47f1b53ca0 | ||
|
|
c10d92a0c3 | ||
|
|
1f18220dfa | ||
|
|
a4a2d6e29c | ||
|
|
786fbba428 | ||
|
|
8743270035 | ||
|
|
73d9b2e585 | ||
|
|
092c7e7260 | ||
|
|
8b3761656f | ||
|
|
c89f707966 | ||
|
|
b1764160c5 | ||
|
|
7e1e33d51f | ||
|
|
2a81418738 | ||
|
|
f72a961bb4 | ||
|
|
e398bf8a24 | ||
|
|
7787a5cf0e | ||
|
|
0786969ef2 | ||
|
|
98040ad44e | ||
|
|
ad4ab65a9f | ||
|
|
e05113ea27 | ||
|
|
c78898edf7 | ||
|
|
9f6be1f471 | ||
|
|
f8a48637ec | ||
|
|
df73c567ce | ||
|
|
47ce8258b0 | ||
|
|
e523d9a1cb | ||
|
|
d65632c097 | ||
|
|
29bf4f72f3 | ||
|
|
ee79b9939b | ||
|
|
156ec5b441 | ||
|
|
931028b43e | ||
|
|
687c4d35ed | ||
|
|
71ac036dc3 | ||
|
|
da3ab42f10 | ||
|
|
537fc1caad | ||
|
|
0ec0eaf937 | ||
|
|
1babda2e69 | ||
|
|
e319ea82d0 | ||
|
|
63c8f63acf | ||
|
|
4f7d3131c5 | ||
|
|
6a8609c7f8 | ||
|
|
d9477501ae | ||
|
|
be46540959 | ||
|
|
773f20f861 | ||
|
|
171386baaf | ||
|
|
aa2716c2c0 | ||
|
|
1904a809a4 | ||
|
|
f8dddc366b | ||
|
|
f7bc5228ec | ||
|
|
4782900da5 | ||
|
|
c011ff81b9 | ||
|
|
cb768ce953 | ||
|
|
5d08c040b9 | ||
|
|
7a0f38d10e | ||
|
|
1e9ab02e3f | ||
|
|
5e378bd21b | ||
|
|
a2e5009f42 | ||
|
|
44cc0dad94 | ||
|
|
68de8e57be | ||
|
|
fde59411da | ||
|
|
7d48dd0ce4 | ||
|
|
699a7a00f5 | ||
|
|
16d55c8973 | ||
|
|
be0b9415b4 | ||
|
|
93df58a8d5 | ||
|
|
999e24902c | ||
|
|
d19208abec | ||
|
|
8f54676b97 | ||
|
|
61bbc9ab7f | ||
|
|
9e802a59c7 | ||
|
|
38e1e632a7 | ||
|
|
89cf78cc4a | ||
|
|
cecd47d679 | ||
|
|
ed35e577af | ||
|
|
f54cf40eda | ||
|
|
5314e6f8bb | ||
|
|
b7b2709177 | ||
|
|
34c47e84c0 | ||
|
|
f7d91184a0 | ||
|
|
eeddc860f7 | ||
|
|
bcefdd209b | ||
|
|
3f1fea2d19 | ||
|
|
665322a69a | ||
|
|
3e59bc3b38 | ||
|
|
1752931dde | ||
|
|
4b9bae1656 | ||
|
|
74c08fa8aa | ||
|
|
628aad8f64 | ||
|
|
39c8672e6d | ||
|
|
620991ddee | ||
|
|
ba8f28f623 | ||
|
|
6389055d3a | ||
|
|
4465ed9819 | ||
|
|
8dc97e5d01 | ||
|
|
a037c50961 | ||
|
|
28d5f02e15 | ||
|
|
e65a353fc4 | ||
|
|
42400e7836 | ||
|
|
cdd7a2008b | ||
|
|
c2b80fddd8 | ||
|
|
8eaa8119e6 | ||
|
|
5fccadd41e | ||
|
|
5d0ab340e3 | ||
|
|
5d7e9199de | ||
|
|
5e2c65a650 | ||
|
|
1f5553d2d8 | ||
|
|
40d5ab050f | ||
|
|
1629ba11b2 | ||
|
|
6e94f138d5 | ||
|
|
1b7273db42 | ||
|
|
8857903831 | ||
|
|
69cacb5fe3 | ||
|
|
ba4b958114 | ||
|
|
6d971ef2c8 | ||
|
|
03ff37db92 | ||
|
|
428126ef75 | ||
|
|
aee242c52a | ||
|
|
1299f78e80 | ||
|
|
fc3d13d5bc | ||
|
|
6d2f7b0c9e | ||
|
|
84128cab28 | ||
|
|
8f2d2784f8 | ||
|
|
37ee677a67 | ||
|
|
1729744a9e | ||
|
|
b59903c890 | ||
|
|
5063e68562 | ||
|
|
3cbb572c7c | ||
|
|
bb4f11a239 | ||
|
|
8a1750691b | ||
|
|
5cffaf9d73 | ||
|
|
a9e50b28df | ||
|
|
24512639fb | ||
|
|
1355d043b6 | ||
|
|
c7600ef9ed | ||
|
|
a4cb0d6432 | ||
|
|
437368bedb | ||
|
|
4057b193d6 | ||
|
|
89b1b5c7f6 | ||
|
|
60d3438277 | ||
|
|
a578a10b5b | ||
|
|
5cf24af00b | ||
|
|
6c0e455146 | ||
|
|
932a946868 | ||
|
|
99a1cfbff9 | ||
|
|
d7bbdde1e7 | ||
|
|
7dba98dce8 | ||
|
|
c1ae30bd82 | ||
|
|
6aa5aea424 | ||
|
|
bc1b00813c | ||
|
|
d1ad3ab301 | ||
|
|
923134bbdc | ||
|
|
e211f69df5 | ||
|
|
fc35d706a0 | ||
|
|
82894e6aff | ||
|
|
7356f157bb | ||
|
|
783fc6268a | ||
|
|
360b17f299 | ||
|
|
2cfcdaff7c | ||
|
|
9d9cf46e47 | ||
|
|
98661cf9a2 | ||
|
|
cc50cd5e3a | ||
|
|
d8399d2d23 | ||
|
|
f2134fb2f8 | ||
|
|
ec3ccc004e | ||
|
|
6cb246c18a | ||
|
|
e73cea0ecf | ||
|
|
c69e185a2a | ||
|
|
5789f59222 | ||
|
|
5178eeb340 | ||
|
|
bc5e7fa4a2 | ||
|
|
c28ace6d40 | ||
|
|
de4fae37e1 | ||
|
|
2f1aff3ec3 | ||
|
|
6970f934bd | ||
|
|
6b5168e102 | ||
|
|
4420edb4dc | ||
|
|
c2fae95fee |
40
.travis.yml
40
.travis.yml
@@ -1,40 +0,0 @@
|
|||||||
language: java
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- mkdir -p downloads
|
|
||||||
- mkdir -p var/db var/log
|
|
||||||
- if [[ ! -d downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION} ]] ; then cd downloads && wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && tar xzf mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}.tgz && cd ..; fi
|
|
||||||
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --version
|
|
||||||
- downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongod --dbpath var/db --replSet rs0 --fork --logpath var/log/mongod.log
|
|
||||||
- sleep 10
|
|
||||||
- |-
|
|
||||||
downloads/mongodb-linux-x86_64-ubuntu1604-${MONGO_VERSION}/bin/mongo --eval "rs.initiate({_id: 'rs0', members:[{_id: 0, host: '127.0.0.1:27017'}]});"
|
|
||||||
sleep 15
|
|
||||||
|
|
||||||
jdk:
|
|
||||||
- openjdk13
|
|
||||||
- openjdk-ea
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- jdk: openjdk-ea
|
|
||||||
|
|
||||||
env:
|
|
||||||
matrix:
|
|
||||||
- MONGO_VERSION=4.2.0
|
|
||||||
- MONGO_VERSION=4.0.14
|
|
||||||
- MONGO_VERSION=3.6.16
|
|
||||||
global:
|
|
||||||
- PROFILE=ci
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.m2
|
|
||||||
- downloads
|
|
||||||
|
|
||||||
install: true
|
|
||||||
|
|
||||||
script:
|
|
||||||
- "./mvnw clean dependency:list test -Pjava11 -Dsort -U"
|
|
||||||
126
Jenkinsfile
vendored
126
Jenkinsfile
vendored
@@ -3,7 +3,7 @@ pipeline {
|
|||||||
|
|
||||||
triggers {
|
triggers {
|
||||||
pollSCM 'H/10 * * * *'
|
pollSCM 'H/10 * * * *'
|
||||||
upstream(upstreamProjects: "spring-data-commons/master", threshold: hudson.model.Result.SUCCESS)
|
upstream(upstreamProjects: "spring-data-commons/2.2.x", threshold: hudson.model.Result.SUCCESS)
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -30,76 +30,79 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Publish JDK 8 + MongoDB 4.1') {
|
||||||
|
when {
|
||||||
|
changeset "ci/openjdk8-mongodb-4.1/**"
|
||||||
|
}
|
||||||
|
agent { label 'data' }
|
||||||
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-4.1", "ci/openjdk8-mongodb-4.1/")
|
||||||
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
|
image.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Publish JDK 8 + MongoDB 4.2') {
|
stage('Publish JDK 8 + MongoDB 4.2') {
|
||||||
when {
|
when {
|
||||||
changeset "ci/openjdk8-mongodb-4.2/**"
|
changeset "ci/openjdk8-mongodb-4.2/**"
|
||||||
}
|
}
|
||||||
agent { label 'data' }
|
agent { label 'data' }
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-4.2.0", "ci/openjdk8-mongodb-4.2/")
|
def image = docker.build("springci/spring-data-openjdk8-with-mongodb-4.2", "ci/openjdk8-mongodb-4.2/")
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
||||||
image.push()
|
image.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Publish JDK 14 + MongoDB 4.2') {
|
|
||||||
when {
|
|
||||||
changeset "ci/openjdk14-mongodb-4.2/**"
|
|
||||||
}
|
|
||||||
agent { label 'data' }
|
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
|
||||||
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
def image = docker.build("springci/spring-data-openjdk14-with-mongodb-4.2.0", "ci/openjdk14-mongodb-4.2/")
|
|
||||||
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
|
|
||||||
image.push()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("test: baseline (jdk8)") {
|
stage("test: baseline") {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch 'master'
|
branch '2.2.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.2.0:latest'
|
image 'springci/spring-data-openjdk8-with-mongodb-4.2:latest'
|
||||||
label 'data'
|
label 'data'
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
args '-v $HOME:/tmp/jenkins-home'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 10'
|
sh 'sleep 10'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'sleep 15'
|
sh 'sleep 15'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Dsort -U -B'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("Test other configurations") {
|
stage("Test other configurations") {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch 'master'
|
branch '2.2.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel {
|
parallel {
|
||||||
stage("test: mongodb 4.0 (jdk8)") {
|
stage("test: mongodb 4.0") {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.0:latest'
|
image 'springci/spring-data-openjdk8-with-mongodb-4.0:latest'
|
||||||
@@ -108,54 +111,39 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 10'
|
sh 'sleep 10'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'sleep 15'
|
sh 'sleep 15'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Dsort -U -B'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage("test: mongodb 4.1") {
|
||||||
stage("test: mongodb 4.2 (jdk8)") {
|
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'springci/spring-data-openjdk8-with-mongodb-4.2.0:latest'
|
image 'springci/spring-data-openjdk8-with-mongodb-4.1:latest'
|
||||||
label 'data'
|
label 'data'
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
args '-v $HOME:/tmp/jenkins-home'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
options { timeout(time: 30, unit: 'MINUTES') }
|
||||||
|
environment {
|
||||||
|
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
sh 'mongod --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
||||||
sh 'sleep 10'
|
sh 'sleep 10'
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
||||||
sh 'sleep 15'
|
sh 'sleep 15'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml clean dependency:list test -Dsort -U -B'
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage("test: baseline (jdk14)") {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'springci/spring-data-openjdk14-with-mongodb-4.2.0:latest'
|
|
||||||
label 'data'
|
|
||||||
args '-v $HOME:/tmp/jenkins-home'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options { timeout(time: 30, unit: 'MINUTES') }
|
|
||||||
steps {
|
|
||||||
sh 'rm -rf ?'
|
|
||||||
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
|
|
||||||
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
|
|
||||||
sh 'sleep 10'
|
|
||||||
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
|
|
||||||
sh 'sleep 15'
|
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +152,7 @@ pipeline {
|
|||||||
stage('Release to artifactory') {
|
stage('Release to artifactory') {
|
||||||
when {
|
when {
|
||||||
anyOf {
|
anyOf {
|
||||||
branch 'master'
|
branch '2.2.x'
|
||||||
not { triggeredBy 'UpstreamCause' }
|
not { triggeredBy 'UpstreamCause' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +171,7 @@ pipeline {
|
|||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'rm -rf ?'
|
sh 'rm -rf ?'
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,artifactory ' +
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
@@ -196,7 +184,7 @@ pipeline {
|
|||||||
|
|
||||||
stage('Publish documentation') {
|
stage('Publish documentation') {
|
||||||
when {
|
when {
|
||||||
branch 'master'
|
branch '2.2.x'
|
||||||
}
|
}
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
@@ -212,7 +200,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
steps {
|
||||||
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,distribute ' +
|
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -s settings.xml -Pci,distribute ' +
|
||||||
'-Dartifactory.server=https://repo.spring.io ' +
|
'-Dartifactory.server=https://repo.spring.io ' +
|
||||||
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
"-Dartifactory.username=${ARTIFACTORY_USR} " +
|
||||||
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
|
||||||
|
|||||||
202
LICENSE.txt
Normal file
202
LICENSE.txt
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
https://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright {yyyy} {name of copyright owner}
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
156
README.adoc
156
README.adoc
@@ -50,11 +50,11 @@ public class MyService {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableMongoRepositories
|
@EnableMongoRepositories
|
||||||
class ApplicationConfig extends AbstractMongoClientConfiguration {
|
class ApplicationConfig extends AbstractMongoConfiguration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MongoClient mongoClient() {
|
public MongoClient mongoClient() {
|
||||||
return MongoClients.create();
|
return new MongoClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,143 +94,6 @@ If you'd rather like the latest snapshots of the upcoming major version, use our
|
|||||||
</repository>
|
</repository>
|
||||||
----
|
----
|
||||||
|
|
||||||
== Upgrading from 2.x
|
|
||||||
|
|
||||||
The 4.0 MongoDB Java Driver does no longer support certain features that have already been deprecated in one of the last minor versions.
|
|
||||||
Some of the changes affect the initial setup configuration as well as compile/runtime features. We summarized the most typical changes one might encounter.
|
|
||||||
|
|
||||||
=== XML Namespace
|
|
||||||
|
|
||||||
.Changed XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
Element / Attribute | 2.x | 3.x
|
|
||||||
|
|
||||||
| `<mongo:mongo-client />`
|
|
||||||
| Used to create a `com.mongodb.MongoClient`
|
|
||||||
| Now exposes a `com.mongodb.client.MongoClient`
|
|
||||||
|
|
||||||
| `<mongo:mongo-client replica-set="..." />`
|
|
||||||
| Was a comma delimited list of replica set members (host/port)
|
|
||||||
| Now defines the replica set name. +
|
|
||||||
Use `<mongo:client-settings cluster-hosts="..." />` instead
|
|
||||||
|
|
||||||
| `<mongo:db-factory writeConcern="..." />`
|
|
||||||
| NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICAS_SAFE, MAJORITY
|
|
||||||
| W1, W2, W3, UNAKNOWLEDGED, AKNOWLEDGED, JOURNALED, MAJORITY
|
|
||||||
|===
|
|
||||||
|
|
||||||
.Removed XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
Element / Attribute | Replacement in 3.x | Comment
|
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-ref="..." />`
|
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
|
||||||
| Referencing a `com.mongodb.client.MongoClient`.
|
|
||||||
|
|
||||||
| `<mongo:mongo-client credentials="..." />`
|
|
||||||
| `<mongo:mongo-client credential="..." />`
|
|
||||||
| Single authentication data instead of list.
|
|
||||||
|
|
||||||
| `<mongo:client-options />`
|
|
||||||
| `<mongo:client-settings />`
|
|
||||||
| See `com.mongodb.MongoClientSettings` for details.
|
|
||||||
|===
|
|
||||||
|
|
||||||
.New XML Namespace Elements and Attributes:
|
|
||||||
|===
|
|
||||||
Element | Comment
|
|
||||||
|
|
||||||
| `<mongo:db-factory mongo-client-ref="..." />`
|
|
||||||
| Replacement for `<mongo:db-factory mongo-ref="..." />`
|
|
||||||
|
|
||||||
| `<mongo:db-factory connection-string="..." />`
|
|
||||||
| Replacement for `uri` and `client-uri`.
|
|
||||||
|
|
||||||
| `<mongo:mongo-client connection-string="..." />`
|
|
||||||
| Replacement for `uri` and `client-uri`.
|
|
||||||
|
|
||||||
| `<mongo:client-settings />`
|
|
||||||
| Namespace element for `com.mongodb.MongoClientSettings`.
|
|
||||||
|
|
||||||
|===
|
|
||||||
|
|
||||||
=== Java Configuration
|
|
||||||
|
|
||||||
.Java API changes
|
|
||||||
|===
|
|
||||||
Type | Comment
|
|
||||||
|
|
||||||
| `MongoClientFactoryBean`
|
|
||||||
| Creates `com.mongodb.client.MongoClient` instead of `com.mongodb.MongoClient` +
|
|
||||||
Uses `MongoClientSettings` instead of `MongoClientOptions`.
|
|
||||||
|
|
||||||
| `MongoDataIntegrityViolationException`
|
|
||||||
| Uses `WriteConcernResult` instead of `WriteResult`.
|
|
||||||
|
|
||||||
| `BulkOperationException`
|
|
||||||
| Uses `MongoBulkWriteException` and `com.mongodb.bulk.BulkWriteError` instead of `BulkWriteException` and `com.mongodb.BulkWriteError`
|
|
||||||
|
|
||||||
| `ReactiveMongoClientFactoryBean`
|
|
||||||
| Uses `com.mongodb.MongoClientSettings` instead of `com.mongodb.async.client.MongoClientSettings`
|
|
||||||
|
|
||||||
| `ReactiveMongoClientSettingsFactoryBean`
|
|
||||||
| Now produces `com.mongodb.MongoClientSettings` instead of `com.mongodb.async.client.MongoClientSettings`
|
|
||||||
|===
|
|
||||||
|
|
||||||
.Removed Java API:
|
|
||||||
|===
|
|
||||||
2.x | Replacement in 3.x | Comment
|
|
||||||
|
|
||||||
| `MongoClientOptionsFactoryBean`
|
|
||||||
| `MongoClientSettingsFactoryBean`
|
|
||||||
| Creating a `com.mongodb.MongoClientSettings`.
|
|
||||||
|
|
||||||
| `AbstractMongoConfiguration`
|
|
||||||
| `AbstractMongoClientConfiguration` +
|
|
||||||
(Available since 2.1)
|
|
||||||
| Using `com.mongodb.client.MongoClient`.
|
|
||||||
|
|
||||||
| `MongoDbFactory#getLegacyDb()`
|
|
||||||
| -
|
|
||||||
| -
|
|
||||||
|
|
||||||
| `SimpleMongoDbFactory`
|
|
||||||
| `SimpleMongoClientDbFactory` +
|
|
||||||
(Available since 2.1)
|
|
||||||
|
|
|
||||||
|
|
||||||
| `MapReduceOptions#getOutputType()`
|
|
||||||
| `MapReduceOptions#getMapReduceAction()`
|
|
||||||
| Returns `MapReduceAction` instead of `MapReduceCommand.OutputType`.
|
|
||||||
|
|
||||||
| `Meta\|Query` maxScan & snapshot
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|===
|
|
||||||
|
|
||||||
=== Other Changes
|
|
||||||
|
|
||||||
==== UUID Types
|
|
||||||
|
|
||||||
The MongoDB UUID representation can now be configured with different formats.
|
|
||||||
This has to be done via `MongoClientSettings` as shown in the snippet below.
|
|
||||||
|
|
||||||
.UUID Codec Configuration
|
|
||||||
====
|
|
||||||
[source,java]
|
|
||||||
----
|
|
||||||
static class Config extends AbstractMongoClientConfiguration {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureClientSettings(MongoClientSettings.Builder builder) {
|
|
||||||
builder.uuidRepresentation(UuidRepresentation.STANDARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
----
|
|
||||||
====
|
|
||||||
|
|
||||||
== Getting Help
|
== Getting Help
|
||||||
|
|
||||||
Having trouble with Spring Data? We’d love to help!
|
Having trouble with Spring Data? We’d love to help!
|
||||||
@@ -242,18 +105,17 @@ If you are just starting out with Spring, try one of the https://spring.io/guide
|
|||||||
* If you are upgrading, check out the https://docs.spring.io/spring-data/mongodb/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
* If you are upgrading, check out the https://docs.spring.io/spring-data/mongodb/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features.
|
||||||
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-mongodb`].
|
* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/tags/spring-data[`spring-data-mongodb`].
|
||||||
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
|
||||||
* Report bugs with Spring Data MongoDB at https://jira.spring.io/browse/DATAMONGO[jira.spring.io/browse/DATAMONGO].
|
* Report bugs with Spring Data MongoDB at https://github.com/spring-projects/spring-data-mongodb/issues[github.com/spring-projects/spring-data-mongodb/issues].
|
||||||
|
|
||||||
== Reporting Issues
|
== Reporting Issues
|
||||||
|
|
||||||
Spring Data uses JIRA as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
|
Spring Data uses Github as issue tracking system to record bugs and feature requests.
|
||||||
|
If you want to raise an issue, please follow the recommendations below:
|
||||||
|
|
||||||
* Before you log a bug, please search the
|
* Before you log a bug, please search the https://github.com/spring-projects/spring-data-mongodb/issues[issue tracker] to see if someone has already reported the problem.
|
||||||
https://jira.spring.io/browse/DATAMONGO[issue tracker] to see if someone has already reported the problem.
|
* If the issue does not already exist, https://github.com/spring-projects/spring-data-mongodb/issues/new[create a new issue].
|
||||||
* If the issue doesn’t already exist, https://jira.spring.io/browse/DATAMONGO[create a new issue].
|
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.
|
||||||
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version.
|
* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.
|
||||||
* If you need to paste code, or include a stack trace use JIRA `{code}…{code}` escapes before and after your text.
|
|
||||||
* If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.
|
|
||||||
|
|
||||||
== Building from Source
|
== Building from Source
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
FROM adoptopenjdk/openjdk11:latest
|
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN set -eux; \
|
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b ; \
|
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list; \
|
|
||||||
echo ${TZ} > /etc/timezone;
|
|
||||||
|
|
||||||
RUN apt-get update ; \
|
|
||||||
apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0 ; \
|
|
||||||
apt-get clean; \
|
|
||||||
rm -rf /var/lib/apt/lists/*;
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
FROM adoptopenjdk/openjdk14:latest
|
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN set -eux; \
|
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b ; \
|
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list; \
|
|
||||||
echo ${TZ} > /etc/timezone;
|
|
||||||
|
|
||||||
RUN apt-get update ; \
|
|
||||||
apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0 ; \
|
|
||||||
apt-get clean; \
|
|
||||||
rm -rf /var/lib/apt/lists/*;
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
FROM adoptopenjdk/openjdk8:latest
|
FROM adoptopenjdk/openjdk8:latest
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN RUN set -eux; \
|
RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 ; \
|
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list; \
|
|
||||||
echo ${TZ} > /etc/timezone;
|
|
||||||
|
|
||||||
RUN apt-get update ; \
|
RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list
|
||||||
apt-get install -y mongodb-org=4.0.14 mongodb-org-server=4.0.14 mongodb-org-shell=4.0.14 mongodb-org-mongos=4.0.14 mongodb-org-tools=4.0.14 ; \
|
|
||||||
apt-get clean; \
|
RUN apt-get update
|
||||||
rm -rf /var/lib/apt/lists/*;
|
|
||||||
|
RUN apt-get install -y mongodb-org=4.0.9 mongodb-org-server=4.0.9 mongodb-org-shell=4.0.9 mongodb-org-mongos=4.0.9 mongodb-org-tools=4.0.9
|
||||||
|
|
||||||
|
RUN apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
14
ci/openjdk8-mongodb-4.1/Dockerfile
Normal file
14
ci/openjdk8-mongodb-4.1/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
FROM adoptopenjdk/openjdk8:latest
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2
|
||||||
|
|
||||||
|
RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 4B7C549A058F8B6B
|
||||||
|
|
||||||
|
RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.1 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.1.list
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
|
||||||
|
RUN apt-get install -y mongodb-org-unstable=4.1.13 mongodb-org-unstable-server=4.1.13 mongodb-org-unstable-shell=4.1.13 mongodb-org-unstable-mongos=4.1.13 mongodb-org-unstable-tools=4.1.13
|
||||||
|
|
||||||
|
RUN apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
FROM adoptopenjdk/openjdk8:latest
|
FROM adoptopenjdk/openjdk8:latest
|
||||||
|
|
||||||
ENV TZ=Etc/UTC
|
RUN apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b
|
||||||
apt-get update && apt-get install -y apt-transport-https apt-utils gnupg2 ; \
|
|
||||||
apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv e162f504a20cdf15827f718d4b7c549a058f8b6b ; \
|
|
||||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list; \
|
|
||||||
echo ${TZ} > /etc/timezone;
|
|
||||||
|
|
||||||
RUN apt-get update ; \
|
RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
|
||||||
apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0 ; \
|
|
||||||
apt-get clean; \
|
RUN apt-get update
|
||||||
rm -rf /var/lib/apt/lists/*;
|
|
||||||
|
RUN apt-get install -y mongodb-org=4.2.0 mongodb-org-server=4.2.0 mongodb-org-shell=4.2.0 mongodb-org-mongos=4.2.0 mongodb-org-tools=4.2.0
|
||||||
|
|
||||||
|
RUN apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
27
pom.xml
27
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.RC2</version>
|
<version>2.2.14.BUILD-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data.build</groupId>
|
<groupId>org.springframework.data.build</groupId>
|
||||||
<artifactId>spring-data-parent</artifactId>
|
<artifactId>spring-data-parent</artifactId>
|
||||||
<version>2.3.0.RC2</version>
|
<version>2.2.14.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@@ -26,9 +26,9 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.type>multi</project.type>
|
<project.type>multi</project.type>
|
||||||
<dist.id>spring-data-mongodb</dist.id>
|
<dist.id>spring-data-mongodb</dist.id>
|
||||||
<springdata.commons>2.3.0.RC2</springdata.commons>
|
<springdata.commons>2.2.14.BUILD-SNAPSHOT</springdata.commons>
|
||||||
<mongo>4.0.2</mongo>
|
<mongo>3.11.2</mongo>
|
||||||
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
<mongo.reactivestreams>1.12.0</mongo.reactivestreams>
|
||||||
<jmh.version>1.19</jmh.version>
|
<jmh.version>1.19</jmh.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@@ -127,25 +127,15 @@
|
|||||||
<!-- MongoDB -->
|
<!-- MongoDB -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver-core</artifactId>
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
<version>${mongo}</version>
|
<version>${mongo}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spring-libs-milestone</id>
|
<id>spring-libs-snapshot</id>
|
||||||
<url>https://repo.spring.io/libs-milestone</url>
|
<url>https://repo.spring.io/libs-snapshot</url>
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>sonatype-libs-snapshot</id>
|
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@@ -158,7 +148,6 @@
|
|||||||
<id>spring-libs-milestone</id>
|
<id>spring-libs-milestone</id>
|
||||||
<url>https://repo.spring.io/libs-milestone</url>
|
<url>https://repo.spring.io/libs-milestone</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
|
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
29
settings.xml
Normal file
29
settings.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
||||||
|
https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>spring-plugins-release</id>
|
||||||
|
<username>${env.ARTIFACTORY_USR}</username>
|
||||||
|
<password>${env.ARTIFACTORY_PSW}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>spring-libs-snapshot</id>
|
||||||
|
<username>${env.ARTIFACTORY_USR}</username>
|
||||||
|
<password>${env.ARTIFACTORY_PSW}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>spring-libs-milestone</id>
|
||||||
|
<username>${env.ARTIFACTORY_USR}</username>
|
||||||
|
<password>${env.ARTIFACTORY_PSW}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>spring-libs-release</id>
|
||||||
|
<username>${env.ARTIFACTORY_USR}</username>
|
||||||
|
<password>${env.ARTIFACTORY_PSW}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
|
||||||
|
</settings>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.RC2</version>
|
<version>2.2.14.BUILD-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.RC2</version>
|
<version>2.2.14.BUILD-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.RC2</version>
|
<version>2.2.14.BUILD-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -65,12 +65,6 @@
|
|||||||
<artifactId>querydsl-mongodb</artifactId>
|
<artifactId>querydsl-mongodb</artifactId>
|
||||||
<version>${querydsl}</version>
|
<version>${querydsl}</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongo-java-driver</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -88,14 +82,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- reactive -->
|
<!-- reactive -->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mongodb</groupId>
|
|
||||||
<artifactId>mongodb-driver-sync</artifactId>
|
|
||||||
<version>${mongo}</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver-reactivestreams</artifactId>
|
<artifactId>mongodb-driver-reactivestreams</artifactId>
|
||||||
@@ -103,6 +89,23 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-async</artifactId>
|
||||||
|
<version>${mongo}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongodb-driver-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>bson</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-core</artifactId>
|
<artifactId>reactor-core</artifactId>
|
||||||
@@ -250,13 +253,6 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit-pioneer</groupId>
|
|
||||||
<artifactId>junit-pioneer</artifactId>
|
|
||||||
<version>0.5.3</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.transaction</groupId>
|
<groupId>javax.transaction</groupId>
|
||||||
<artifactId>jta</artifactId>
|
<artifactId>jta</artifactId>
|
||||||
@@ -344,6 +340,12 @@
|
|||||||
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
|
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
|
||||||
<reactor.trace.cancel>true</reactor.trace.cancel>
|
<reactor.trace.cancel>true</reactor.trace.cancel>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
<properties>
|
||||||
|
<property>
|
||||||
|
<name>listener</name>
|
||||||
|
<value>org.springframework.data.mongodb.test.util.CleanMongoDBJunitRunListener</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,9 +19,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
|
|
||||||
import com.mongodb.MongoBulkWriteException;
|
import com.mongodb.BulkWriteError;
|
||||||
import com.mongodb.bulk.BulkWriteError;
|
import com.mongodb.BulkWriteException;
|
||||||
import com.mongodb.bulk.BulkWriteResult;
|
import com.mongodb.BulkWriteResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is thrown when errors occur during bulk operations.
|
* Is thrown when errors occur during bulk operations.
|
||||||
@@ -38,12 +38,12 @@ public class BulkOperationException extends DataAccessException {
|
|||||||
private final BulkWriteResult result;
|
private final BulkWriteResult result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link BulkOperationException} with the given message and source {@link MongoBulkWriteException}.
|
* Creates a new {@link BulkOperationException} with the given message and source {@link BulkWriteException}.
|
||||||
*
|
*
|
||||||
* @param message must not be {@literal null}.
|
* @param message must not be {@literal null}.
|
||||||
* @param source must not be {@literal null}.
|
* @param source must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public BulkOperationException(String message, MongoBulkWriteException source) {
|
public BulkOperationException(String message, BulkWriteException source) {
|
||||||
|
|
||||||
super(message, source);
|
super(message, source);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2020 the original author or authors.
|
* Copyright 2013-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -25,8 +25,10 @@ public class LazyLoadingException extends UncategorizedDataAccessException {
|
|||||||
private static final long serialVersionUID = -7089224903873220037L;
|
private static final long serialVersionUID = -7089224903873220037L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param msg
|
* Constructor for LazyLoadingException.
|
||||||
* @param cause
|
*
|
||||||
|
* @param msg the detail message.
|
||||||
|
* @param cause the exception thrown by underlying data access API.
|
||||||
*/
|
*/
|
||||||
public LazyLoadingException(String msg, Throwable cause) {
|
public LazyLoadingException(String msg, Throwable cause) {
|
||||||
super(msg, cause);
|
super(msg, cause);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb;
|
|
||||||
|
|
||||||
import org.bson.codecs.configuration.CodecRegistry;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
|
||||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
|
||||||
import org.springframework.data.mongodb.core.MongoExceptionTranslator;
|
|
||||||
|
|
||||||
import com.mongodb.ClientSessionOptions;
|
|
||||||
import com.mongodb.client.ClientSession;
|
|
||||||
import com.mongodb.client.MongoDatabase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for factories creating {@link MongoDatabase} instances.
|
|
||||||
*
|
|
||||||
* @author Mark Pollack
|
|
||||||
* @author Thomas Darimont
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public interface MongoDatabaseFactory extends CodecRegistryProvider, MongoSessionProvider {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain a {@link MongoDatabase} from the underlying factory.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
MongoDatabase getMongoDatabase() throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain a {@link MongoDatabase} instance to access the database with the given name.
|
|
||||||
*
|
|
||||||
* @param dbName
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @throws DataAccessException
|
|
||||||
*/
|
|
||||||
MongoDatabase getMongoDatabase(String dbName) throws DataAccessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes a shared {@link MongoExceptionTranslator}.
|
|
||||||
*
|
|
||||||
* @return will never be {@literal null}.
|
|
||||||
*/
|
|
||||||
PersistenceExceptionTranslator getExceptionTranslator();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the underlying {@link CodecRegistry} used by the MongoDB Java driver.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
default CodecRegistry getCodecRegistry() {
|
|
||||||
return getMongoDatabase().getCodecRegistry();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain a {@link ClientSession} for given ClientSessionOptions.
|
|
||||||
*
|
|
||||||
* @param options must not be {@literal null}.
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
ClientSession getSession(ClientSessionOptions options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain a {@link ClientSession} bound instance of {@link MongoDatabaseFactory} returning {@link MongoDatabase}
|
|
||||||
* instances that are aware and bound to a new session with given {@link ClientSessionOptions options}.
|
|
||||||
*
|
|
||||||
* @param options must not be {@literal null}.
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
default MongoDatabaseFactory withSession(ClientSessionOptions options) {
|
|
||||||
return withSession(getSession(options));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain a {@link ClientSession} bound instance of {@link MongoDatabaseFactory} returning {@link MongoDatabase}
|
|
||||||
* instances that are aware and bound to the given session.
|
|
||||||
*
|
|
||||||
* @param session must not be {@literal null}.
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
MongoDatabaseFactory withSession(ClientSession session);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the given {@link MongoDatabaseFactory} is bound to a {@link ClientSession} that has an
|
|
||||||
* {@link ClientSession#hasActiveTransaction() active transaction}.
|
|
||||||
*
|
|
||||||
* @return {@literal true} if there's an active transaction, {@literal false} otherwise.
|
|
||||||
* @since 2.1.3
|
|
||||||
*/
|
|
||||||
default boolean isTransactionActive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -27,7 +27,7 @@ import com.mongodb.client.ClientSession;
|
|||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for managing a {@link MongoDatabase} instances via {@link MongoDatabaseFactory}. Used for obtaining
|
* Helper class for managing a {@link MongoDatabase} instances via {@link MongoDbFactory}. Used for obtaining
|
||||||
* {@link ClientSession session bound} resources, such as {@link MongoDatabase} and
|
* {@link ClientSession session bound} resources, such as {@link MongoDatabase} and
|
||||||
* {@link com.mongodb.client.MongoCollection} suitable for transactional usage.
|
* {@link com.mongodb.client.MongoCollection} suitable for transactional usage.
|
||||||
* <p />
|
* <p />
|
||||||
@@ -41,94 +41,93 @@ import com.mongodb.client.MongoDatabase;
|
|||||||
public class MongoDatabaseUtils {
|
public class MongoDatabaseUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory} using
|
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDbFactory factory} using
|
||||||
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <p />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
* @param factory the {@link MongoDbFactory} to get the {@link MongoDatabase} from.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(MongoDatabaseFactory factory) {
|
public static MongoDatabase getDatabase(MongoDbFactory factory) {
|
||||||
return doGetMongoDatabase(null, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
return doGetMongoDatabase(null, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDatabaseFactory factory}.
|
* Obtain the default {@link MongoDatabase database} form the given {@link MongoDbFactory factory}.
|
||||||
* <p />
|
* <p />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
* @param factory the {@link MongoDbFactory} to get the {@link MongoDatabase} from.
|
||||||
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(MongoDatabaseFactory factory, SessionSynchronization sessionSynchronization) {
|
public static MongoDatabase getDatabase(MongoDbFactory factory, SessionSynchronization sessionSynchronization) {
|
||||||
return doGetMongoDatabase(null, factory, sessionSynchronization);
|
return doGetMongoDatabase(null, factory, sessionSynchronization);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory} using
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDbFactory factory} using
|
||||||
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
* {@link SessionSynchronization#ON_ACTUAL_TRANSACTION native session synchronization}.
|
||||||
* <p />
|
* <p />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
* @param dbName the name of the {@link MongoDatabase} to get.
|
* @param dbName the name of the {@link MongoDatabase} to get.
|
||||||
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
* @param factory the {@link MongoDbFactory} to get the {@link MongoDatabase} from.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(String dbName, MongoDatabaseFactory factory) {
|
public static MongoDatabase getDatabase(@Nullable String dbName, MongoDbFactory factory) {
|
||||||
return doGetMongoDatabase(dbName, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
return doGetMongoDatabase(dbName, factory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDatabaseFactory factory}.
|
* Obtain the {@link MongoDatabase database} with given name form the given {@link MongoDbFactory factory}.
|
||||||
* <p />
|
* <p />
|
||||||
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
* Registers a {@link MongoSessionSynchronization MongoDB specific transaction synchronization} within the current
|
||||||
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
* {@link Thread} if {@link TransactionSynchronizationManager#isSynchronizationActive() synchronization is active}.
|
||||||
*
|
*
|
||||||
* @param dbName the name of the {@link MongoDatabase} to get.
|
* @param dbName the name of the {@link MongoDatabase} to get.
|
||||||
* @param factory the {@link MongoDatabaseFactory} to get the {@link MongoDatabase} from.
|
* @param factory the {@link MongoDbFactory} to get the {@link MongoDatabase} from.
|
||||||
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
* @param sessionSynchronization the synchronization to use. Must not be {@literal null}.
|
||||||
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
* @return the {@link MongoDatabase} that is potentially associated with a transactional {@link ClientSession}.
|
||||||
*/
|
*/
|
||||||
public static MongoDatabase getDatabase(String dbName, MongoDatabaseFactory factory,
|
public static MongoDatabase getDatabase(@Nullable String dbName, MongoDbFactory factory,
|
||||||
SessionSynchronization sessionSynchronization) {
|
SessionSynchronization sessionSynchronization) {
|
||||||
return doGetMongoDatabase(dbName, factory, sessionSynchronization);
|
return doGetMongoDatabase(dbName, factory, sessionSynchronization);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MongoDatabase doGetMongoDatabase(@Nullable String dbName, MongoDatabaseFactory factory,
|
private static MongoDatabase doGetMongoDatabase(@Nullable String dbName, MongoDbFactory factory,
|
||||||
SessionSynchronization sessionSynchronization) {
|
SessionSynchronization sessionSynchronization) {
|
||||||
|
|
||||||
Assert.notNull(factory, "Factory must not be null!");
|
Assert.notNull(factory, "Factory must not be null!");
|
||||||
|
|
||||||
if (!TransactionSynchronizationManager.isSynchronizationActive()) {
|
if (!TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||||
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
return StringUtils.hasText(dbName) ? factory.getDb(dbName) : factory.getDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientSession session = doGetSession(factory, sessionSynchronization);
|
ClientSession session = doGetSession(factory, sessionSynchronization);
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
return StringUtils.hasText(dbName) ? factory.getDb(dbName) : factory.getDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
MongoDatabaseFactory factoryToUse = factory.withSession(session);
|
MongoDbFactory factoryToUse = factory.withSession(session);
|
||||||
return StringUtils.hasText(dbName) ? factoryToUse.getMongoDatabase(dbName) : factoryToUse.getMongoDatabase();
|
return StringUtils.hasText(dbName) ? factoryToUse.getDb(dbName) : factoryToUse.getDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the {@link MongoDatabaseFactory} is actually bound to a {@link ClientSession} that has an active
|
* Check if the {@link MongoDbFactory} is actually bound to a {@link ClientSession} that has an active transaction, or
|
||||||
* transaction, or if a {@link TransactionSynchronization} has been registered for the {@link MongoDatabaseFactory
|
* if a {@link TransactionSynchronization} has been registered for the {@link MongoDbFactory resource} and if the
|
||||||
* resource} and if the associated {@link ClientSession} has an {@link ClientSession#hasActiveTransaction() active
|
* associated {@link ClientSession} has an {@link ClientSession#hasActiveTransaction() active transaction}.
|
||||||
* transaction}.
|
|
||||||
*
|
*
|
||||||
* @param dbFactory the resource to check transactions for. Must not be {@literal null}.
|
* @param dbFactory the resource to check transactions for. Must not be {@literal null}.
|
||||||
* @return {@literal true} if the factory has an ongoing transaction.
|
* @return {@literal true} if the factory has an ongoing transaction.
|
||||||
* @since 2.1.3
|
* @since 2.1.3
|
||||||
*/
|
*/
|
||||||
public static boolean isTransactionActive(MongoDatabaseFactory dbFactory) {
|
public static boolean isTransactionActive(MongoDbFactory dbFactory) {
|
||||||
|
|
||||||
if (dbFactory.isTransactionActive()) {
|
if (dbFactory.isTransactionActive()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -139,8 +138,7 @@ public class MongoDatabaseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ClientSession doGetSession(MongoDatabaseFactory dbFactory,
|
private static ClientSession doGetSession(MongoDbFactory dbFactory, SessionSynchronization sessionSynchronization) {
|
||||||
SessionSynchronization sessionSynchronization) {
|
|
||||||
|
|
||||||
MongoResourceHolder resourceHolder = (MongoResourceHolder) TransactionSynchronizationManager.getResource(dbFactory);
|
MongoResourceHolder resourceHolder = (MongoResourceHolder) TransactionSynchronizationManager.getResource(dbFactory);
|
||||||
|
|
||||||
@@ -171,7 +169,7 @@ public class MongoDatabaseUtils {
|
|||||||
return resourceHolder.getSession();
|
return resourceHolder.getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClientSession createClientSession(MongoDatabaseFactory dbFactory) {
|
private static ClientSession createClientSession(MongoDbFactory dbFactory) {
|
||||||
return dbFactory.getSession(ClientSessionOptions.builder().causallyConsistent(true).build());
|
return dbFactory.getSession(ClientSessionOptions.builder().causallyConsistent(true).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +184,7 @@ public class MongoDatabaseUtils {
|
|||||||
|
|
||||||
private final MongoResourceHolder resourceHolder;
|
private final MongoResourceHolder resourceHolder;
|
||||||
|
|
||||||
MongoSessionSynchronization(MongoResourceHolder resourceHolder, MongoDatabaseFactory dbFactory) {
|
MongoSessionSynchronization(MongoResourceHolder resourceHolder, MongoDbFactory dbFactory) {
|
||||||
|
|
||||||
super(resourceHolder, dbFactory);
|
super(resourceHolder, dbFactory);
|
||||||
this.resourceHolder = resourceHolder;
|
this.resourceHolder = resourceHolder;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb;
|
package org.springframework.data.mongodb;
|
||||||
|
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||||
|
import org.springframework.data.mongodb.core.MongoExceptionTranslator;
|
||||||
|
|
||||||
|
import com.mongodb.ClientSessionOptions;
|
||||||
|
import com.mongodb.DB;
|
||||||
|
import com.mongodb.client.ClientSession;
|
||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,33 +31,92 @@ import com.mongodb.client.MongoDatabase;
|
|||||||
* @author Mark Pollack
|
* @author Mark Pollack
|
||||||
* @author Thomas Darimont
|
* @author Thomas Darimont
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @deprecated since 3.0, use {@link MongoDatabaseFactory} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public interface MongoDbFactory extends CodecRegistryProvider, MongoSessionProvider {
|
||||||
public interface MongoDbFactory extends MongoDatabaseFactory {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default {@link MongoDatabase} instance.
|
* Creates a default {@link MongoDatabase} instance.
|
||||||
*
|
*
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws DataAccessException
|
* @throws DataAccessException
|
||||||
* @deprecated since 3.0. Use {@link #getMongoDatabase()} instead.
|
*/
|
||||||
|
MongoDatabase getDb() throws DataAccessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link DB} instance to access the database with the given name.
|
||||||
|
*
|
||||||
|
* @param dbName must not be {@literal null} or empty.
|
||||||
|
* @return never {@literal null}.
|
||||||
|
* @throws DataAccessException
|
||||||
|
*/
|
||||||
|
MongoDatabase getDb(String dbName) throws DataAccessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposes a shared {@link MongoExceptionTranslator}.
|
||||||
|
*
|
||||||
|
* @return will never be {@literal null}.
|
||||||
|
*/
|
||||||
|
PersistenceExceptionTranslator getExceptionTranslator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the legacy database entry point. Please consider {@link #getDb()} instead.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @deprecated since 2.1, use {@link #getDb()}. This method will be removed with a future version as it works only
|
||||||
|
* with the legacy MongoDB driver.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default MongoDatabase getDb() throws DataAccessException {
|
DB getLegacyDb();
|
||||||
return getMongoDatabase();
|
|
||||||
|
/**
|
||||||
|
* Get the underlying {@link CodecRegistry} used by the MongoDB Java driver.
|
||||||
|
*
|
||||||
|
* @return never {@literal null}.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
default CodecRegistry getCodecRegistry() {
|
||||||
|
return getDb().getCodecRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a {@link MongoDatabase} instance to access the database with the given name.
|
* Obtain a {@link ClientSession} for given ClientSessionOptions.
|
||||||
*
|
*
|
||||||
* @param dbName must not be {@literal null} or empty.
|
* @param options must not be {@literal null}.
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws DataAccessException
|
* @since 2.1
|
||||||
* @deprecated since 3.0. Use {@link #getMongoDatabase(String)} instead.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
ClientSession getSession(ClientSessionOptions options);
|
||||||
default MongoDatabase getDb(String dbName) throws DataAccessException {
|
|
||||||
return getMongoDatabase(dbName);
|
/**
|
||||||
|
* Obtain a {@link ClientSession} bound instance of {@link MongoDbFactory} returning {@link MongoDatabase} instances
|
||||||
|
* that are aware and bound to a new session with given {@link ClientSessionOptions options}.
|
||||||
|
*
|
||||||
|
* @param options must not be {@literal null}.
|
||||||
|
* @return never {@literal null}.
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
default MongoDbFactory withSession(ClientSessionOptions options) {
|
||||||
|
return withSession(getSession(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a {@link ClientSession} bound instance of {@link MongoDbFactory} returning {@link MongoDatabase} instances
|
||||||
|
* that are aware and bound to the given session.
|
||||||
|
*
|
||||||
|
* @param session must not be {@literal null}.
|
||||||
|
* @return never {@literal null}.
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
MongoDbFactory withSession(ClientSession session);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the given {@link MongoDbFactory} is bound to a {@link ClientSession} that has an
|
||||||
|
* {@link ClientSession#hasActiveTransaction() active transaction}.
|
||||||
|
*
|
||||||
|
* @return {@literal true} if there's an active transaction, {@literal false} otherwise.
|
||||||
|
* @since 2.1.3
|
||||||
|
*/
|
||||||
|
default boolean isTransactionActive() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,15 +36,15 @@ import com.mongodb.client.ClientSession;
|
|||||||
class MongoResourceHolder extends ResourceHolderSupport {
|
class MongoResourceHolder extends ResourceHolderSupport {
|
||||||
|
|
||||||
private @Nullable ClientSession session;
|
private @Nullable ClientSession session;
|
||||||
private MongoDatabaseFactory dbFactory;
|
private MongoDbFactory dbFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link MongoResourceHolder} for a given {@link ClientSession session}.
|
* Create a new {@link MongoResourceHolder} for a given {@link ClientSession session}.
|
||||||
*
|
*
|
||||||
* @param session the associated {@link ClientSession}. Can be {@literal null}.
|
* @param session the associated {@link ClientSession}. Can be {@literal null}.
|
||||||
* @param dbFactory the associated {@link MongoDatabaseFactory}. must not be {@literal null}.
|
* @param dbFactory the associated {@link MongoDbFactory}. must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
MongoResourceHolder(@Nullable ClientSession session, MongoDatabaseFactory dbFactory) {
|
MongoResourceHolder(@Nullable ClientSession session, MongoDbFactory dbFactory) {
|
||||||
|
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.dbFactory = dbFactory;
|
this.dbFactory = dbFactory;
|
||||||
@@ -75,9 +75,9 @@ class MongoResourceHolder extends ResourceHolderSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the associated {@link MongoDatabaseFactory}.
|
* @return the associated {@link MongoDbFactory}.
|
||||||
*/
|
*/
|
||||||
public MongoDatabaseFactory getDbFactory() {
|
public MongoDbFactory getDbFactory() {
|
||||||
return dbFactory;
|
return dbFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -36,18 +36,17 @@ import com.mongodb.client.ClientSession;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link org.springframework.transaction.PlatformTransactionManager} implementation that manages
|
* A {@link org.springframework.transaction.PlatformTransactionManager} implementation that manages
|
||||||
* {@link ClientSession} based transactions for a single {@link MongoDatabaseFactory}.
|
* {@link ClientSession} based transactions for a single {@link MongoDbFactory}.
|
||||||
* <p />
|
* <p />
|
||||||
* Binds a {@link ClientSession} from the specified {@link MongoDatabaseFactory} to the thread.
|
* Binds a {@link ClientSession} from the specified {@link MongoDbFactory} to the thread.
|
||||||
* <p />
|
* <p />
|
||||||
* {@link TransactionDefinition#isReadOnly() Readonly} transactions operate on a {@link ClientSession} and enable causal
|
* {@link TransactionDefinition#isReadOnly() Readonly} transactions operate on a {@link ClientSession} and enable causal
|
||||||
* consistency, and also {@link ClientSession#startTransaction() start}, {@link ClientSession#commitTransaction()
|
* consistency, and also {@link ClientSession#startTransaction() start}, {@link ClientSession#commitTransaction()
|
||||||
* commit} or {@link ClientSession#abortTransaction() abort} a transaction.
|
* commit} or {@link ClientSession#abortTransaction() abort} a transaction.
|
||||||
* <p />
|
* <p />
|
||||||
* Application code is required to retrieve the {@link com.mongodb.client.MongoDatabase} via
|
* Application code is required to retrieve the {@link com.mongodb.client.MongoDatabase} via
|
||||||
* {@link MongoDatabaseUtils#getDatabase(MongoDatabaseFactory)} instead of a standard
|
* {@link MongoDatabaseUtils#getDatabase(MongoDbFactory)} instead of a standard {@link MongoDbFactory#getDb()} call.
|
||||||
* {@link MongoDatabaseFactory#getMongoDatabase()} call. Spring classes such as
|
* Spring classes such as {@link org.springframework.data.mongodb.core.MongoTemplate} use this strategy implicitly.
|
||||||
* {@link org.springframework.data.mongodb.core.MongoTemplate} use this strategy implicitly.
|
|
||||||
* <p />
|
* <p />
|
||||||
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. One may override
|
* By default failure of a {@literal commit} operation raises a {@link TransactionSystemException}. One may override
|
||||||
* {@link #doCommit(MongoTransactionObject)} to implement the
|
* {@link #doCommit(MongoTransactionObject)} to implement the
|
||||||
@@ -59,46 +58,46 @@ import com.mongodb.client.ClientSession;
|
|||||||
* @currentRead Shadow's Edge - Brent Weeks
|
* @currentRead Shadow's Edge - Brent Weeks
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
* @see <a href="https://www.mongodb.com/transactions">MongoDB Transaction Documentation</a>
|
* @see <a href="https://www.mongodb.com/transactions">MongoDB Transaction Documentation</a>
|
||||||
* @see MongoDatabaseUtils#getDatabase(MongoDatabaseFactory, SessionSynchronization)
|
* @see MongoDatabaseUtils#getDatabase(MongoDbFactory, SessionSynchronization)
|
||||||
*/
|
*/
|
||||||
public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
||||||
implements ResourceTransactionManager, InitializingBean {
|
implements ResourceTransactionManager, InitializingBean {
|
||||||
|
|
||||||
private @Nullable MongoDatabaseFactory dbFactory;
|
private @Nullable MongoDbFactory dbFactory;
|
||||||
private @Nullable TransactionOptions options;
|
private @Nullable TransactionOptions options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link MongoTransactionManager} for bean-style usage.
|
* Create a new {@link MongoTransactionManager} for bean-style usage.
|
||||||
* <p />
|
* <p />
|
||||||
* <strong>Note:</strong>The {@link MongoDatabaseFactory db factory} has to be
|
* <strong>Note:</strong>The {@link MongoDbFactory db factory} has to be {@link #setDbFactory(MongoDbFactory) set}
|
||||||
* {@link #setDbFactory(MongoDatabaseFactory) set} before using the instance. Use this constructor to prepare a
|
* before using the instance. Use this constructor to prepare a {@link MongoTransactionManager} via a
|
||||||
* {@link MongoTransactionManager} via a {@link org.springframework.beans.factory.BeanFactory}.
|
* {@link org.springframework.beans.factory.BeanFactory}.
|
||||||
* <p />
|
* <p />
|
||||||
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
* Optionally it is possible to set default {@link TransactionOptions transaction options} defining
|
||||||
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
* {@link com.mongodb.ReadConcern} and {@link com.mongodb.WriteConcern}.
|
||||||
*
|
*
|
||||||
* @see #setDbFactory(MongoDatabaseFactory)
|
* @see #setDbFactory(MongoDbFactory)
|
||||||
* @see #setTransactionSynchronization(int)
|
* @see #setTransactionSynchronization(int)
|
||||||
*/
|
*/
|
||||||
public MongoTransactionManager() {}
|
public MongoTransactionManager() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link MongoTransactionManager} obtaining sessions from the given {@link MongoDatabaseFactory}.
|
* Create a new {@link MongoTransactionManager} obtaining sessions from the given {@link MongoDbFactory}.
|
||||||
*
|
*
|
||||||
* @param dbFactory must not be {@literal null}.
|
* @param dbFactory must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public MongoTransactionManager(MongoDatabaseFactory dbFactory) {
|
public MongoTransactionManager(MongoDbFactory dbFactory) {
|
||||||
this(dbFactory, null);
|
this(dbFactory, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link MongoTransactionManager} obtaining sessions from the given {@link MongoDatabaseFactory}
|
* Create a new {@link MongoTransactionManager} obtaining sessions from the given {@link MongoDbFactory} applying the
|
||||||
* applying the given {@link TransactionOptions options}, if present, when starting a new transaction.
|
* given {@link TransactionOptions options}, if present, when starting a new transaction.
|
||||||
*
|
*
|
||||||
* @param dbFactory must not be {@literal null}.
|
* @param dbFactory must not be {@literal null}.
|
||||||
* @param options can be {@literal null}.
|
* @param options can be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public MongoTransactionManager(MongoDatabaseFactory dbFactory, @Nullable TransactionOptions options) {
|
public MongoTransactionManager(MongoDbFactory dbFactory, @Nullable TransactionOptions options) {
|
||||||
|
|
||||||
Assert.notNull(dbFactory, "DbFactory must not be null!");
|
Assert.notNull(dbFactory, "DbFactory must not be null!");
|
||||||
|
|
||||||
@@ -296,11 +295,11 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link MongoDatabaseFactory} that this instance should manage transactions for.
|
* Set the {@link MongoDbFactory} that this instance should manage transactions for.
|
||||||
*
|
*
|
||||||
* @param dbFactory must not be {@literal null}.
|
* @param dbFactory must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
public void setDbFactory(MongoDatabaseFactory dbFactory) {
|
public void setDbFactory(MongoDbFactory dbFactory) {
|
||||||
|
|
||||||
Assert.notNull(dbFactory, "DbFactory must not be null!");
|
Assert.notNull(dbFactory, "DbFactory must not be null!");
|
||||||
this.dbFactory = dbFactory;
|
this.dbFactory = dbFactory;
|
||||||
@@ -316,12 +315,12 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link MongoDatabaseFactory} that this instance manages transactions for.
|
* Get the {@link MongoDbFactory} that this instance manages transactions for.
|
||||||
*
|
*
|
||||||
* @return can be {@literal null}.
|
* @return can be {@literal null}.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public MongoDatabaseFactory getDbFactory() {
|
public MongoDbFactory getDbFactory() {
|
||||||
return dbFactory;
|
return dbFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +329,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
* @see org.springframework.transaction.support.ResourceTransactionManager#getResourceFactory()
|
* @see org.springframework.transaction.support.ResourceTransactionManager#getResourceFactory()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MongoDatabaseFactory getResourceFactory() {
|
public MongoDbFactory getResourceFactory() {
|
||||||
return getRequiredDbFactory();
|
return getRequiredDbFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +344,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
|
|
||||||
private MongoResourceHolder newResourceHolder(TransactionDefinition definition, ClientSessionOptions options) {
|
private MongoResourceHolder newResourceHolder(TransactionDefinition definition, ClientSessionOptions options) {
|
||||||
|
|
||||||
MongoDatabaseFactory dbFactory = getResourceFactory();
|
MongoDbFactory dbFactory = getResourceFactory();
|
||||||
|
|
||||||
MongoResourceHolder resourceHolder = new MongoResourceHolder(dbFactory.getSession(options), dbFactory);
|
MongoResourceHolder resourceHolder = new MongoResourceHolder(dbFactory.getSession(options), dbFactory);
|
||||||
resourceHolder.setTimeoutIfNotDefaulted(determineTimeout(definition));
|
resourceHolder.setTimeoutIfNotDefaulted(determineTimeout(definition));
|
||||||
@@ -356,7 +355,7 @@ public class MongoTransactionManager extends AbstractPlatformTransactionManager
|
|||||||
/**
|
/**
|
||||||
* @throws IllegalStateException if {@link #dbFactory} is {@literal null}.
|
* @throws IllegalStateException if {@link #dbFactory} is {@literal null}.
|
||||||
*/
|
*/
|
||||||
private MongoDatabaseFactory getRequiredDbFactory() {
|
private MongoDbFactory getRequiredDbFactory() {
|
||||||
|
|
||||||
Assert.state(dbFactory != null,
|
Assert.state(dbFactory != null,
|
||||||
"MongoTransactionManager operates upon a MongoDbFactory. Did you forget to provide one? It's required.");
|
"MongoTransactionManager operates upon a MongoDbFactory. Did you forget to provide one? It's required.");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -31,7 +31,6 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
|
|||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mathieu Ouellet
|
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public interface ReactiveMongoDatabaseFactory extends CodecRegistryProvider {
|
public interface ReactiveMongoDatabaseFactory extends CodecRegistryProvider {
|
||||||
@@ -39,19 +38,19 @@ public interface ReactiveMongoDatabaseFactory extends CodecRegistryProvider {
|
|||||||
/**
|
/**
|
||||||
* Creates a default {@link MongoDatabase} instance.
|
* Creates a default {@link MongoDatabase} instance.
|
||||||
*
|
*
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws DataAccessException
|
* @throws DataAccessException
|
||||||
*/
|
*/
|
||||||
Mono<MongoDatabase> getMongoDatabase() throws DataAccessException;
|
MongoDatabase getMongoDatabase() throws DataAccessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a {@link MongoDatabase} instance to access the database with the given name.
|
* Creates a {@link MongoDatabase} instance to access the database with the given name.
|
||||||
*
|
*
|
||||||
* @param dbName must not be {@literal null} or empty.
|
* @param dbName must not be {@literal null} or empty.
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws DataAccessException
|
* @throws DataAccessException
|
||||||
*/
|
*/
|
||||||
Mono<MongoDatabase> getMongoDatabase(String dbName) throws DataAccessException;
|
MongoDatabase getMongoDatabase(String dbName) throws DataAccessException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposes a shared {@link MongoExceptionTranslator}.
|
* Exposes a shared {@link MongoExceptionTranslator}.
|
||||||
@@ -65,7 +64,10 @@ public interface ReactiveMongoDatabaseFactory extends CodecRegistryProvider {
|
|||||||
*
|
*
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
CodecRegistry getCodecRegistry();
|
@Override
|
||||||
|
default CodecRegistry getCodecRegistry() {
|
||||||
|
return getMongoDatabase().getCodecRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a {@link Mono} emitting a {@link ClientSession} for given {@link ClientSessionOptions options}.
|
* Obtain a {@link Mono} emitting a {@link ClientSession} for given {@link ClientSessionOptions options}.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 the original author or authors.
|
* Copyright 2019-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -41,7 +41,6 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
|
|||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mathieu Ouellet
|
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public class ReactiveMongoDatabaseUtils {
|
public class ReactiveMongoDatabaseUtils {
|
||||||
@@ -143,13 +142,14 @@ public class ReactiveMongoDatabaseUtils {
|
|||||||
.flatMap(synchronizationManager -> {
|
.flatMap(synchronizationManager -> {
|
||||||
|
|
||||||
return doGetSession(synchronizationManager, factory, sessionSynchronization) //
|
return doGetSession(synchronizationManager, factory, sessionSynchronization) //
|
||||||
.flatMap(it -> getMongoDatabaseOrDefault(dbName, factory.withSession(it)));
|
.map(it -> getMongoDatabaseOrDefault(dbName, factory.withSession(it)));
|
||||||
}) //
|
})
|
||||||
.onErrorResume(NoTransactionException.class, e -> getMongoDatabaseOrDefault(dbName, factory))
|
.onErrorResume(NoTransactionException.class,
|
||||||
.switchIfEmpty(getMongoDatabaseOrDefault(dbName, factory));
|
e -> Mono.fromSupplier(() -> getMongoDatabaseOrDefault(dbName, factory)))
|
||||||
|
.defaultIfEmpty(getMongoDatabaseOrDefault(dbName, factory));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Mono<MongoDatabase> getMongoDatabaseOrDefault(@Nullable String dbName,
|
private static MongoDatabase getMongoDatabaseOrDefault(@Nullable String dbName,
|
||||||
ReactiveMongoDatabaseFactory factory) {
|
ReactiveMongoDatabaseFactory factory) {
|
||||||
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
return StringUtils.hasText(dbName) ? factory.getMongoDatabase(dbName) : factory.getMongoDatabase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 the original author or authors.
|
* Copyright 2019-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -42,7 +42,7 @@ class ReactiveMongoResourceHolder extends ResourceHolderSupport {
|
|||||||
* Create a new {@link ReactiveMongoResourceHolder} for a given {@link ClientSession session}.
|
* Create a new {@link ReactiveMongoResourceHolder} for a given {@link ClientSession session}.
|
||||||
*
|
*
|
||||||
* @param session the associated {@link ClientSession}. Can be {@literal null}.
|
* @param session the associated {@link ClientSession}. Can be {@literal null}.
|
||||||
* @param databaseFactory the associated {@link MongoDatabaseFactory}. must not be {@literal null}.
|
* @param databaseFactory the associated {@link MongoDbFactory}. must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
ReactiveMongoResourceHolder(@Nullable ClientSession session, ReactiveMongoDatabaseFactory databaseFactory) {
|
ReactiveMongoResourceHolder(@Nullable ClientSession session, ReactiveMongoDatabaseFactory databaseFactory) {
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ class ReactiveMongoResourceHolder extends ResourceHolderSupport {
|
|||||||
* If the {@link ReactiveMongoResourceHolder} is {@link #hasSession() not already associated} with a
|
* If the {@link ReactiveMongoResourceHolder} is {@link #hasSession() not already associated} with a
|
||||||
* {@link ClientSession} the given value is {@link #setSession(ClientSession) set} and returned, otherwise the current
|
* {@link ClientSession} the given value is {@link #setSession(ClientSession) set} and returned, otherwise the current
|
||||||
* bound session is returned.
|
* bound session is returned.
|
||||||
*
|
*
|
||||||
* @param session
|
* @param session
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 the original author or authors.
|
* Copyright 2019-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -110,7 +110,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doGetTransaction(org.springframework.transaction.reactive.TransactionSynchronizationManager)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doGetTransaction(org.springframework.transaction.reactive.TransactionSynchronizationManager)
|
||||||
*/
|
*/
|
||||||
@@ -123,7 +123,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return new ReactiveMongoTransactionObject(resourceHolder);
|
return new ReactiveMongoTransactionObject(resourceHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#isExistingTransaction(java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#isExistingTransaction(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -132,7 +132,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return extractMongoTransaction(transaction).hasResourceHolder();
|
return extractMongoTransaction(transaction).hasResourceHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doBegin(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, org.springframework.transaction.TransactionDefinition)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doBegin(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, org.springframework.transaction.TransactionDefinition)
|
||||||
*/
|
*/
|
||||||
@@ -175,7 +175,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSuspend(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSuspend(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -192,7 +192,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doResume(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doResume(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -203,7 +203,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
.fromRunnable(() -> synchronizationManager.bindResource(getRequiredDatabaseFactory(), suspendedResources));
|
.fromRunnable(() -> synchronizationManager.bindResource(getRequiredDatabaseFactory(), suspendedResources));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCommit(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCommit(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -243,7 +243,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return transactionObject.commitTransaction();
|
return transactionObject.commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doRollback(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doRollback(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -268,7 +268,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSetRollbackOnly(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doSetRollbackOnly(org.springframework.transaction.reactive.TransactionSynchronizationManager, org.springframework.transaction.reactive.GenericReactiveTransaction)
|
||||||
*/
|
*/
|
||||||
@@ -282,7 +282,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCleanupAfterCompletion(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
* @see org.springframework.transaction.reactive.AbstractReactiveTransactionManager#doCleanupAfterCompletion(org.springframework.transaction.reactive.TransactionSynchronizationManager, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -509,7 +509,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.support.SmartTransactionObject#isRollbackOnly()
|
* @see org.springframework.transaction.support.SmartTransactionObject#isRollbackOnly()
|
||||||
*/
|
*/
|
||||||
@@ -518,7 +518,7 @@ public class ReactiveMongoTransactionManager extends AbstractReactiveTransaction
|
|||||||
return this.resourceHolder != null && this.resourceHolder.isRollbackOnly();
|
return this.resourceHolder != null && this.resourceHolder.isRollbackOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.transaction.support.SmartTransactionObject#flush()
|
* @see org.springframework.transaction.support.SmartTransactionObject#flush()
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.data.util.Version;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.mongodb.MongoDriverInformation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class that exposes the SpringData MongoDB specific information like the current {@link Version} or
|
|
||||||
* {@link MongoDriverInformation driver information}.
|
|
||||||
*
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public class SpringDataMongoDB {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(SpringDataMongoDB.class);
|
|
||||||
|
|
||||||
private static final Version FALLBACK_VERSION = new Version(3);
|
|
||||||
private static final MongoDriverInformation DRIVER_INFORMATION = MongoDriverInformation
|
|
||||||
.builder(MongoDriverInformation.builder().build()).driverName("spring-data").build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain the SpringData MongoDB specific driver information.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
*/
|
|
||||||
public static MongoDriverInformation driverInformation() {
|
|
||||||
return DRIVER_INFORMATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the "Implementation-Version" manifest attribute from the jar file.
|
|
||||||
* <p />
|
|
||||||
* Note that some ClassLoaders do not expose the package metadata, hence this class might not be able to determine the
|
|
||||||
* version in all environments. In this case the current Major version is returned as a fallback.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
*/
|
|
||||||
public static Version version() {
|
|
||||||
|
|
||||||
Package pkg = SpringDataMongoDB.class.getPackage();
|
|
||||||
String versionString = (pkg != null ? pkg.getImplementationVersion() : null);
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(versionString)) {
|
|
||||||
|
|
||||||
LOGGER.debug("Unable to find Spring Data MongoDB version.");
|
|
||||||
return FALLBACK_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return Version.parse(versionString);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.debug("Cannot read Spring Data MongoDB version '{}'.", versionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALLBACK_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,22 +17,17 @@ package org.springframework.data.mongodb.config;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
import org.springframework.data.mongodb.MongoDbFactory;
|
||||||
import org.springframework.data.mongodb.SpringDataMongoDB;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
import org.springframework.data.mongodb.core.SimpleMongoClientDbFactory;
|
||||||
|
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
||||||
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
import com.mongodb.MongoClientSettings;
|
|
||||||
import com.mongodb.MongoClientSettings.Builder;
|
|
||||||
import com.mongodb.client.MongoClient;
|
import com.mongodb.client.MongoClient;
|
||||||
import com.mongodb.client.MongoClients;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Spring Data MongoDB configuration using JavaConfig with {@link com.mongodb.client.MongoClient}.
|
* Base class for Spring Data MongoDB configuration using JavaConfig with {@link com.mongodb.client.MongoClient}.
|
||||||
@@ -40,44 +35,40 @@ import com.mongodb.client.MongoClients;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
* @see MongoConfigurationSupport
|
* @see MongoConfigurationSupport
|
||||||
|
* @see AbstractMongoConfiguration
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration
|
||||||
public abstract class AbstractMongoClientConfiguration extends MongoConfigurationSupport {
|
public abstract class AbstractMongoClientConfiguration extends MongoConfigurationSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link MongoClient} instance to connect to. Annotate with {@link Bean} in case you want to expose a
|
* Return the {@link MongoClient} instance to connect to. Annotate with {@link Bean} in case you want to expose a
|
||||||
* {@link MongoClient} instance to the {@link org.springframework.context.ApplicationContext}. <br />
|
* {@link MongoClient} instance to the {@link org.springframework.context.ApplicationContext}.
|
||||||
* Override {@link #mongoClientSettings()} to configure connection details.
|
|
||||||
*
|
*
|
||||||
* @return never {@literal null}.
|
* @return
|
||||||
* @see #mongoClientSettings()
|
|
||||||
* @see #configureClientSettings(Builder)
|
|
||||||
*/
|
*/
|
||||||
public MongoClient mongoClient() {
|
public abstract MongoClient mongoClient();
|
||||||
return createMongoClient(mongoClientSettings());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link MongoTemplate}.
|
* Creates a {@link MongoTemplate}.
|
||||||
*
|
*
|
||||||
* @see #mongoDbFactory()
|
* @return
|
||||||
* @see #mappingMongoConverter(MongoDatabaseFactory, MongoCustomConversions, MongoMappingContext)
|
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MongoTemplate mongoTemplate(MongoDatabaseFactory databaseFactory, MappingMongoConverter converter) {
|
public MongoTemplate mongoTemplate() throws Exception {
|
||||||
return new MongoTemplate(databaseFactory, converter);
|
return new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory} to be used by the
|
* Creates a {@link SimpleMongoDbFactory} to be used by the {@link MongoTemplate}. Will use the {@link MongoClient}
|
||||||
* {@link MongoTemplate}. Will use the {@link MongoClient} instance configured in {@link #mongoClient()}.
|
* instance configured in {@link #mongoClient()}.
|
||||||
*
|
*
|
||||||
* @see #mongoClient()
|
* @see #mongoClient()
|
||||||
* @see #mongoTemplate(MongoDatabaseFactory, MappingMongoConverter)
|
* @see #mongoTemplate()
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MongoDatabaseFactory mongoDbFactory() {
|
public MongoDbFactory mongoDbFactory() {
|
||||||
return new SimpleMongoClientDatabaseFactory(mongoClient(), getDatabaseName());
|
return new SimpleMongoClientDbFactory(mongoClient(), getDatabaseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,32 +91,22 @@ public abstract class AbstractMongoClientConfiguration extends MongoConfiguratio
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link MappingMongoConverter} using the configured {@link #mongoDbFactory()} and
|
* Creates a {@link MappingMongoConverter} using the configured {@link #mongoDbFactory()} and
|
||||||
* {@link #mongoMappingContext(MongoCustomConversions)}. Will get {@link #customConversions()} applied.
|
* {@link #mongoMappingContext()}. Will get {@link #customConversions()} applied.
|
||||||
*
|
*
|
||||||
* @see #customConversions()
|
* @see #customConversions()
|
||||||
* @see #mongoMappingContext(MongoCustomConversions)
|
* @see #mongoMappingContext()
|
||||||
* @see #mongoDbFactory()
|
* @see #mongoDbFactory()
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MappingMongoConverter mappingMongoConverter(MongoDatabaseFactory databaseFactory,
|
public MappingMongoConverter mappingMongoConverter() throws Exception {
|
||||||
MongoCustomConversions customConversions, MongoMappingContext mappingContext) {
|
|
||||||
|
|
||||||
DbRefResolver dbRefResolver = new DefaultDbRefResolver(databaseFactory);
|
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory());
|
||||||
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mappingContext);
|
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext());
|
||||||
converter.setCustomConversions(customConversions);
|
converter.setCustomConversions(customConversions());
|
||||||
converter.setCodecRegistryProvider(databaseFactory);
|
converter.setCodecRegistryProvider(mongoDbFactory());
|
||||||
|
|
||||||
return converter;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the Reactive Streams {@link com.mongodb.reactivestreams.client.MongoClient} instance with given
|
|
||||||
* {@link MongoClientSettings}.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
protected MongoClient createMongoClient(MongoClientSettings settings) {
|
|
||||||
return MongoClients.create(settings, SpringDataMongoDB.driverInformation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011-2021 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.mongodb.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.mongodb.MongoDbFactory;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
||||||
|
import org.springframework.data.mongodb.core.convert.DbRefResolver;
|
||||||
|
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||||
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
import com.mongodb.MongoClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for Spring Data MongoDB configuration using JavaConfig with {@link com.mongodb.MongoClient}.
|
||||||
|
* <p />
|
||||||
|
* <strong>INFO:</strong>In case you want to use {@link com.mongodb.client.MongoClients} for configuration please refer
|
||||||
|
* to {@link AbstractMongoClientConfiguration}.
|
||||||
|
*
|
||||||
|
* @author Mark Pollack
|
||||||
|
* @author Oliver Gierke
|
||||||
|
* @author Thomas Darimont
|
||||||
|
* @author Ryan Tenney
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @author Mark Paluch
|
||||||
|
* @see MongoConfigurationSupport
|
||||||
|
* @see AbstractMongoClientConfiguration
|
||||||
|
* @deprecated since 2.2 in favor of {@link AbstractMongoClientConfiguration}.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@Deprecated
|
||||||
|
public abstract class AbstractMongoConfiguration extends MongoConfigurationSupport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link MongoClient} instance to connect to. Annotate with {@link Bean} in case you want to expose a
|
||||||
|
* {@link MongoClient} instance to the {@link org.springframework.context.ApplicationContext}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract MongoClient mongoClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link MongoTemplate}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MongoTemplate mongoTemplate() throws Exception {
|
||||||
|
return new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link SimpleMongoDbFactory} to be used by the {@link MongoTemplate}. Will use the {@link MongoClient}
|
||||||
|
* instance configured in {@link #mongoClient()}.
|
||||||
|
*
|
||||||
|
* @see #mongoClient()
|
||||||
|
* @see #mongoTemplate()
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MongoDbFactory mongoDbFactory() {
|
||||||
|
return new SimpleMongoDbFactory(mongoClient(), getDatabaseName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the base package to scan for mapped {@link Document}s. Will return the package name of the configuration
|
||||||
|
* class' (the concrete class, not this one here) by default. So if you have a {@code com.acme.AppConfig} extending
|
||||||
|
* {@link AbstractMongoConfiguration} the base package will be considered {@code com.acme} unless the method is
|
||||||
|
* overridden to implement alternate behavior.
|
||||||
|
*
|
||||||
|
* @return the base package to scan for mapped {@link Document} classes or {@literal null} to not enable scanning for
|
||||||
|
* entities.
|
||||||
|
* @deprecated use {@link #getMappingBasePackages()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
protected String getMappingBasePackage() {
|
||||||
|
|
||||||
|
Package mappingBasePackage = getClass().getPackage();
|
||||||
|
return mappingBasePackage == null ? null : mappingBasePackage.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link MappingMongoConverter} using the configured {@link #mongoDbFactory()} and
|
||||||
|
* {@link #mongoMappingContext()}. Will get {@link #customConversions()} applied.
|
||||||
|
*
|
||||||
|
* @see #customConversions()
|
||||||
|
* @see #mongoMappingContext()
|
||||||
|
* @see #mongoDbFactory()
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MappingMongoConverter mappingMongoConverter() throws Exception {
|
||||||
|
|
||||||
|
DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoDbFactory());
|
||||||
|
MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, mongoMappingContext());
|
||||||
|
converter.setCustomConversions(customConversions());
|
||||||
|
converter.setCodecRegistryProvider(mongoDbFactory());
|
||||||
|
|
||||||
|
return converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,19 +18,13 @@ package org.springframework.data.mongodb.config;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
|
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
|
||||||
import org.springframework.data.mongodb.SpringDataMongoDB;
|
|
||||||
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
|
||||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;
|
import org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;
|
||||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
|
||||||
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
|
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
|
||||||
|
|
||||||
import com.mongodb.MongoClientSettings;
|
|
||||||
import com.mongodb.MongoClientSettings.Builder;
|
|
||||||
import com.mongodb.reactivestreams.client.MongoClient;
|
import com.mongodb.reactivestreams.client.MongoClient;
|
||||||
import com.mongodb.reactivestreams.client.MongoClients;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for reactive Spring Data MongoDB configuration using JavaConfig.
|
* Base class for reactive Spring Data MongoDB configuration using JavaConfig.
|
||||||
@@ -40,33 +34,25 @@ import com.mongodb.reactivestreams.client.MongoClients;
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @see MongoConfigurationSupport
|
* @see MongoConfigurationSupport
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration
|
||||||
public abstract class AbstractReactiveMongoConfiguration extends MongoConfigurationSupport {
|
public abstract class AbstractReactiveMongoConfiguration extends MongoConfigurationSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Reactive Streams {@link MongoClient} instance to connect to. Annotate with {@link Bean} in case you want
|
* Return the Reactive Streams {@link MongoClient} instance to connect to. Annotate with {@link Bean} in case you want
|
||||||
* to expose a {@link MongoClient} instance to the {@link org.springframework.context.ApplicationContext}. <br />
|
* to expose a {@link MongoClient} instance to the {@link org.springframework.context.ApplicationContext}.
|
||||||
* Override {@link #mongoClientSettings()} to configure connection details.
|
|
||||||
*
|
*
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
* @see #mongoClientSettings()
|
|
||||||
* @see #configureClientSettings(Builder)
|
|
||||||
*/
|
*/
|
||||||
public MongoClient reactiveMongoClient() {
|
public abstract MongoClient reactiveMongoClient();
|
||||||
return createReactiveMongoClient(mongoClientSettings());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates {@link ReactiveMongoOperations}.
|
* Creates {@link ReactiveMongoOperations}.
|
||||||
*
|
*
|
||||||
* @see #reactiveMongoDbFactory()
|
|
||||||
* @see #mappingMongoConverter(ReactiveMongoDatabaseFactory, MongoCustomConversions, MongoMappingContext)
|
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ReactiveMongoTemplate reactiveMongoTemplate(ReactiveMongoDatabaseFactory databaseFactory,
|
public ReactiveMongoOperations reactiveMongoTemplate() throws Exception {
|
||||||
MappingMongoConverter mongoConverter) {
|
return new ReactiveMongoTemplate(reactiveMongoDbFactory(), mappingMongoConverter());
|
||||||
return new ReactiveMongoTemplate(databaseFactory, mongoConverter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +60,7 @@ public abstract class AbstractReactiveMongoConfiguration extends MongoConfigurat
|
|||||||
* {@link MongoClient} instance configured in {@link #reactiveMongoClient()}.
|
* {@link MongoClient} instance configured in {@link #reactiveMongoClient()}.
|
||||||
*
|
*
|
||||||
* @see #reactiveMongoClient()
|
* @see #reactiveMongoClient()
|
||||||
* @see #reactiveMongoTemplate(ReactiveMongoDatabaseFactory, MappingMongoConverter)
|
* @see #reactiveMongoTemplate()
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -84,31 +70,21 @@ public abstract class AbstractReactiveMongoConfiguration extends MongoConfigurat
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link MappingMongoConverter} using the configured {@link #reactiveMongoDbFactory()} and
|
* Creates a {@link MappingMongoConverter} using the configured {@link #reactiveMongoDbFactory()} and
|
||||||
* {@link #mongoMappingContext(MongoCustomConversions)}. Will get {@link #customConversions()} applied.
|
* {@link #mongoMappingContext()}. Will get {@link #customConversions()} applied.
|
||||||
*
|
*
|
||||||
* @see #customConversions()
|
* @see #customConversions()
|
||||||
* @see #mongoMappingContext(MongoCustomConversions)
|
* @see #mongoMappingContext()
|
||||||
* @see #reactiveMongoDbFactory()
|
* @see #reactiveMongoDbFactory()
|
||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MappingMongoConverter mappingMongoConverter(ReactiveMongoDatabaseFactory databaseFactory,
|
public MappingMongoConverter mappingMongoConverter() throws Exception {
|
||||||
MongoCustomConversions customConversions, MongoMappingContext mappingContext) {
|
|
||||||
|
|
||||||
MappingMongoConverter converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mappingContext);
|
MappingMongoConverter converter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, mongoMappingContext());
|
||||||
converter.setCustomConversions(customConversions);
|
converter.setCustomConversions(customConversions());
|
||||||
converter.setCodecRegistryProvider(databaseFactory);
|
converter.setCodecRegistryProvider(reactiveMongoDbFactory());
|
||||||
|
|
||||||
return converter;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the Reactive Streams {@link MongoClient} instance with given {@link MongoClientSettings}.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
protected MongoClient createReactiveMongoClient(MongoClientSettings settings) {
|
|
||||||
return MongoClients.create(settings, SpringDataMongoDB.driverInformation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb.config;
|
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.mongodb.ConnectionString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a {@link String} to a {@link com.mongodb.ConnectionString}.
|
|
||||||
*
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public class ConnectionStringPropertyEditor extends PropertyEditorSupport {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAsText(@Nullable String connectionString) {
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(connectionString)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(new ConnectionString(connectionString));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2020 the original author or authors.
|
* Copyright 2013-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -42,21 +42,21 @@ public @interface EnableMongoAuditing {
|
|||||||
/**
|
/**
|
||||||
* Configures the {@link AuditorAware} bean to be used to lookup the current principal.
|
* Configures the {@link AuditorAware} bean to be used to lookup the current principal.
|
||||||
*
|
*
|
||||||
* @return
|
* @return empty {@link String} by default.
|
||||||
*/
|
*/
|
||||||
String auditorAwareRef() default "";
|
String auditorAwareRef() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
|
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@literal true} by default.
|
||||||
*/
|
*/
|
||||||
boolean setDates() default true;
|
boolean setDates() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
|
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@literal true} by default.
|
||||||
*/
|
*/
|
||||||
boolean modifyOnCreate() default true;
|
boolean modifyOnCreate() default true;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public @interface EnableMongoAuditing {
|
|||||||
* Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
|
* Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
|
||||||
* used for setting creation and modification dates.
|
* used for setting creation and modification dates.
|
||||||
*
|
*
|
||||||
* @return
|
* @return empty {@link String} by default.
|
||||||
*/
|
*/
|
||||||
String dateTimeProviderRef() default "";
|
String dateTimeProviderRef() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2020 the original author or authors.
|
* Copyright 2013-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -96,9 +96,6 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
String id = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
|
String id = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
|
||||||
id = StringUtils.hasText(id) ? id : DEFAULT_CONVERTER_BEAN_NAME;
|
id = StringUtils.hasText(id) ? id : DEFAULT_CONVERTER_BEAN_NAME;
|
||||||
|
|
||||||
String autoIndexCreation = element.getAttribute("auto-index-creation");
|
|
||||||
boolean autoIndexCreationEnabled = StringUtils.hasText(autoIndexCreation) && Boolean.valueOf(autoIndexCreation);
|
|
||||||
|
|
||||||
parserContext.pushContainingComponent(new CompositeComponentDefinition("Mapping Mongo Converter", element));
|
parserContext.pushContainingComponent(new CompositeComponentDefinition("Mapping Mongo Converter", element));
|
||||||
|
|
||||||
BeanDefinition conversionsDefinition = getCustomConversions(element, parserContext);
|
BeanDefinition conversionsDefinition = getCustomConversions(element, parserContext);
|
||||||
@@ -202,11 +199,6 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
|
|
||||||
public static String potentiallyCreateMappingContext(Element element, ParserContext parserContext,
|
public static String potentiallyCreateMappingContext(Element element, ParserContext parserContext,
|
||||||
@Nullable BeanDefinition conversionsDefinition, @Nullable String converterId) {
|
@Nullable BeanDefinition conversionsDefinition, @Nullable String converterId) {
|
||||||
return potentiallyCreateMappingContext(element, parserContext, conversionsDefinition, converterId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String potentiallyCreateMappingContext(Element element, ParserContext parserContext,
|
|
||||||
@Nullable BeanDefinition conversionsDefinition, @Nullable String converterId, boolean autoIndexCreation) {
|
|
||||||
|
|
||||||
String ctxRef = element.getAttribute("mapping-context-ref");
|
String ctxRef = element.getAttribute("mapping-context-ref");
|
||||||
|
|
||||||
@@ -234,8 +226,6 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
|
|||||||
mappingContextBuilder.addPropertyValue("simpleTypeHolder", simpleTypesDefinition);
|
mappingContextBuilder.addPropertyValue("simpleTypeHolder", simpleTypesDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
mappingContextBuilder.addPropertyValue("autoIndexCreation", autoIndexCreation);
|
|
||||||
|
|
||||||
parseFieldNamingStrategy(element, parserContext.getReaderContext(), mappingContextBuilder);
|
parseFieldNamingStrategy(element, parserContext.getReaderContext(), mappingContextBuilder);
|
||||||
|
|
||||||
ctxRef = converterId == null || DEFAULT_CONVERTER_BEAN_NAME.equals(converterId) ? MAPPING_CONTEXT_BEAN_NAME
|
ctxRef = converterId == null || DEFAULT_CONVERTER_BEAN_NAME.equals(converterId) ? MAPPING_CONTEXT_BEAN_NAME
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2020 the original author or authors.
|
* Copyright 2013-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -50,11 +50,10 @@ public class MongoClientParser implements BeanDefinitionParser {
|
|||||||
|
|
||||||
ParsingUtils.setPropertyValue(builder, element, "port", "port");
|
ParsingUtils.setPropertyValue(builder, element, "port", "port");
|
||||||
ParsingUtils.setPropertyValue(builder, element, "host", "host");
|
ParsingUtils.setPropertyValue(builder, element, "host", "host");
|
||||||
ParsingUtils.setPropertyValue(builder, element, "credential", "credential");
|
ParsingUtils.setPropertyValue(builder, element, "credentials", "credentials");
|
||||||
ParsingUtils.setPropertyValue(builder, element, "replica-set", "replicaSet");
|
|
||||||
ParsingUtils.setPropertyValue(builder, element, "connection-string", "connectionString");
|
|
||||||
|
|
||||||
MongoParsingUtils.parseMongoClientSettings(element, builder);
|
MongoParsingUtils.parseMongoClientOptions(element, builder);
|
||||||
|
MongoParsingUtils.parseReplicaSet(element, builder);
|
||||||
|
|
||||||
String defaultedId = StringUtils.hasText(id) ? id : BeanNames.MONGO_BEAN_NAME;
|
String defaultedId = StringUtils.hasText(id) ? id : BeanNames.MONGO_BEAN_NAME;
|
||||||
|
|
||||||
@@ -63,34 +62,22 @@ public class MongoClientParser implements BeanDefinitionParser {
|
|||||||
BeanComponentDefinition mongoComponent = helper.getComponent(builder, defaultedId);
|
BeanComponentDefinition mongoComponent = helper.getComponent(builder, defaultedId);
|
||||||
parserContext.registerBeanComponent(mongoComponent);
|
parserContext.registerBeanComponent(mongoComponent);
|
||||||
|
|
||||||
BeanComponentDefinition connectionStringPropertyEditor = helper
|
BeanComponentDefinition serverAddressPropertyEditor = helper.getComponent(MongoParsingUtils
|
||||||
.getComponent(MongoParsingUtils.getConnectionStringPropertyEditorBuilder());
|
.getServerAddressPropertyEditorBuilder());
|
||||||
parserContext.registerBeanComponent(connectionStringPropertyEditor);
|
|
||||||
|
|
||||||
BeanComponentDefinition serverAddressPropertyEditor = helper
|
|
||||||
.getComponent(MongoParsingUtils.getServerAddressPropertyEditorBuilder());
|
|
||||||
parserContext.registerBeanComponent(serverAddressPropertyEditor);
|
parserContext.registerBeanComponent(serverAddressPropertyEditor);
|
||||||
|
|
||||||
BeanComponentDefinition writeConcernEditor = helper
|
BeanComponentDefinition writeConcernEditor = helper.getComponent(MongoParsingUtils
|
||||||
.getComponent(MongoParsingUtils.getWriteConcernPropertyEditorBuilder());
|
.getWriteConcernPropertyEditorBuilder());
|
||||||
parserContext.registerBeanComponent(writeConcernEditor);
|
parserContext.registerBeanComponent(writeConcernEditor);
|
||||||
|
|
||||||
BeanComponentDefinition readConcernEditor = helper
|
BeanComponentDefinition readPreferenceEditor = helper.getComponent(MongoParsingUtils
|
||||||
.getComponent(MongoParsingUtils.getReadConcernPropertyEditorBuilder());
|
.getReadPreferencePropertyEditorBuilder());
|
||||||
parserContext.registerBeanComponent(readConcernEditor);
|
|
||||||
|
|
||||||
BeanComponentDefinition readPreferenceEditor = helper
|
|
||||||
.getComponent(MongoParsingUtils.getReadPreferencePropertyEditorBuilder());
|
|
||||||
parserContext.registerBeanComponent(readPreferenceEditor);
|
parserContext.registerBeanComponent(readPreferenceEditor);
|
||||||
|
|
||||||
BeanComponentDefinition credentialsEditor = helper
|
BeanComponentDefinition credentialsEditor = helper.getComponent(MongoParsingUtils
|
||||||
.getComponent(MongoParsingUtils.getMongoCredentialPropertyEditor());
|
.getMongoCredentialPropertyEditor());
|
||||||
parserContext.registerBeanComponent(credentialsEditor);
|
parserContext.registerBeanComponent(credentialsEditor);
|
||||||
|
|
||||||
BeanComponentDefinition uuidRepresentationEditor = helper
|
|
||||||
.getComponent(MongoParsingUtils.getUUidRepresentationEditorBuilder());
|
|
||||||
parserContext.registerBeanComponent(uuidRepresentationEditor);
|
|
||||||
|
|
||||||
parserContext.popAndRegisterContainingComponent();
|
parserContext.popAndRegisterContainingComponent();
|
||||||
|
|
||||||
return mongoComponent.getBeanDefinition();
|
return mongoComponent.getBeanDefinition();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,7 +20,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bson.UuidRepresentation;
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
@@ -32,15 +31,11 @@ import org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingSt
|
|||||||
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
import org.springframework.data.mapping.model.FieldNamingStrategy;
|
||||||
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
|
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
|
||||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
||||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions.MongoConverterConfigurationAdapter;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.mongodb.MongoClientSettings;
|
|
||||||
import com.mongodb.MongoClientSettings.Builder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Spring Data MongoDB to be extended for JavaConfiguration usage.
|
* Base class for Spring Data MongoDB to be extended for JavaConfiguration usage.
|
||||||
*
|
*
|
||||||
@@ -80,12 +75,11 @@ public abstract class MongoConfigurationSupport {
|
|||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MongoMappingContext mongoMappingContext(MongoCustomConversions customConversions)
|
public MongoMappingContext mongoMappingContext() throws ClassNotFoundException {
|
||||||
throws ClassNotFoundException {
|
|
||||||
|
|
||||||
MongoMappingContext mappingContext = new MongoMappingContext();
|
MongoMappingContext mappingContext = new MongoMappingContext();
|
||||||
mappingContext.setInitialEntitySet(getInitialEntitySet());
|
mappingContext.setInitialEntitySet(getInitialEntitySet());
|
||||||
mappingContext.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
|
mappingContext.setSimpleTypeHolder(customConversions().getSimpleTypeHolder());
|
||||||
mappingContext.setFieldNamingStrategy(fieldNamingStrategy());
|
mappingContext.setFieldNamingStrategy(fieldNamingStrategy());
|
||||||
mappingContext.setAutoIndexCreation(autoIndexCreation());
|
mappingContext.setAutoIndexCreation(autoIndexCreation());
|
||||||
|
|
||||||
@@ -94,30 +88,14 @@ public abstract class MongoConfigurationSupport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register custom {@link Converter}s in a {@link CustomConversions} object if required. These
|
* Register custom {@link Converter}s in a {@link CustomConversions} object if required. These
|
||||||
* {@link CustomConversions} will be registered with the
|
* {@link CustomConversions} will be registered with the {@link #mappingMongoConverter()} and
|
||||||
* {@link org.springframework.data.mongodb.core.convert.MappingMongoConverter} and {@link #mongoMappingContext()}.
|
* {@link MongoMappingContext}. Returns an empty {@link MongoCustomConversions} instance by default.
|
||||||
* Returns an empty {@link MongoCustomConversions} instance by default.
|
|
||||||
* <p>
|
|
||||||
* <strong>NOTE:</strong> Use {@link #configureConverters(MongoConverterConfigurationAdapter)} to configure MongoDB
|
|
||||||
* native simple types and register custom {@link Converter converters}.
|
|
||||||
*
|
*
|
||||||
* @return must not be {@literal null}.
|
* @return must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public MongoCustomConversions customConversions() {
|
public CustomConversions customConversions() {
|
||||||
return MongoCustomConversions.create(this::configureConverters);
|
return new MongoCustomConversions(Collections.emptyList());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration hook for {@link MongoCustomConversions} creation.
|
|
||||||
*
|
|
||||||
* @param converterConfigurationAdapter never {@literal null}.
|
|
||||||
* @since 2.3
|
|
||||||
* @see MongoConverterConfigurationAdapter#useNativeDriverJavaTimeCodecs()
|
|
||||||
* @see MongoConverterConfigurationAdapter#useSpringDataJavaTimeCodecs()
|
|
||||||
*/
|
|
||||||
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,36 +177,11 @@ public abstract class MongoConfigurationSupport {
|
|||||||
* Configure whether to automatically create indices for domain types by deriving the
|
* Configure whether to automatically create indices for domain types by deriving the
|
||||||
* {@link org.springframework.data.mongodb.core.index.IndexDefinition} from the entity or not.
|
* {@link org.springframework.data.mongodb.core.index.IndexDefinition} from the entity or not.
|
||||||
*
|
*
|
||||||
* @return {@literal false} by default. <br />
|
* @return {@literal true} by default. <br />
|
||||||
* <strong>INFO</strong>: As of 3.x the default is set to {@literal false}; In 2.x it was {@literal true}.
|
* <strong>INFO</strong>: As of 3.x the default will be set to {@literal false}.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
protected boolean autoIndexCreation() {
|
protected boolean autoIndexCreation() {
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the {@link MongoClientSettings} used to create the actual {@literal MongoClient}. <br />
|
|
||||||
* Override either this method, or use {@link #configureClientSettings(Builder)} to alter the setup.
|
|
||||||
*
|
|
||||||
* @return never {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
protected MongoClientSettings mongoClientSettings() {
|
|
||||||
|
|
||||||
MongoClientSettings.Builder builder = MongoClientSettings.builder();
|
|
||||||
builder.uuidRepresentation(UuidRepresentation.JAVA_LEGACY);
|
|
||||||
configureClientSettings(builder);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure {@link MongoClientSettings} via its {@link Builder} API.
|
|
||||||
*
|
|
||||||
* @param builder never {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
protected void configureClientSettings(MongoClientSettings.Builder builder) {
|
|
||||||
// customization hook
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,12 +32,14 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
|||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
import org.springframework.data.config.BeanComponentDefinitionBuilder;
|
import org.springframework.data.config.BeanComponentDefinitionBuilder;
|
||||||
import org.springframework.data.mongodb.core.MongoClientFactoryBean;
|
import org.springframework.data.mongodb.core.MongoClientFactoryBean;
|
||||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import com.mongodb.ConnectionString;
|
import com.mongodb.Mongo;
|
||||||
|
import com.mongodb.MongoClientURI;
|
||||||
|
import com.mongodb.MongoURI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BeanDefinitionParser} to parse {@code db-factory} elements into {@link BeanDefinition}s.
|
* {@link BeanDefinitionParser} to parse {@code db-factory} elements into {@link BeanDefinition}s.
|
||||||
@@ -82,11 +84,10 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||||
|
|
||||||
// Common setup
|
// Common setup
|
||||||
BeanDefinitionBuilder dbFactoryBuilder = BeanDefinitionBuilder
|
BeanDefinitionBuilder dbFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SimpleMongoDbFactory.class);
|
||||||
.genericBeanDefinition(SimpleMongoClientDatabaseFactory.class);
|
|
||||||
setPropertyValue(dbFactoryBuilder, element, "write-concern", "writeConcern");
|
setPropertyValue(dbFactoryBuilder, element, "write-concern", "writeConcern");
|
||||||
|
|
||||||
BeanDefinition mongoUri = getConnectionString(element, parserContext);
|
BeanDefinition mongoUri = getMongoUri(element, parserContext);
|
||||||
|
|
||||||
if (mongoUri != null) {
|
if (mongoUri != null) {
|
||||||
|
|
||||||
@@ -96,8 +97,7 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
|
|
||||||
BeanComponentDefinitionBuilder helper = new BeanComponentDefinitionBuilder(element, parserContext);
|
BeanComponentDefinitionBuilder helper = new BeanComponentDefinitionBuilder(element, parserContext);
|
||||||
|
|
||||||
String mongoRef = element.getAttribute("mongo-client-ref");
|
String mongoRef = element.getAttribute("mongo-ref");
|
||||||
|
|
||||||
String dbname = element.getAttribute("dbname");
|
String dbname = element.getAttribute("dbname");
|
||||||
|
|
||||||
// Defaulting
|
// Defaulting
|
||||||
@@ -119,8 +119,8 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a default {@link BeanDefinition} of a {@link com.mongodb.client.MongoClient} instance and returns the
|
* Registers a default {@link BeanDefinition} of a {@link Mongo} instance and returns the name under which the
|
||||||
* name under which the {@link com.mongodb.client.MongoClient} instance was registered under.
|
* {@link Mongo} instance was registered under.
|
||||||
*
|
*
|
||||||
* @param element must not be {@literal null}.
|
* @param element must not be {@literal null}.
|
||||||
* @param parserContext must not be {@literal null}.
|
* @param parserContext must not be {@literal null}.
|
||||||
@@ -136,7 +136,8 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link BeanDefinition} for a {@link ConnectionString} depending on configured attributes. <br />
|
* Creates a {@link BeanDefinition} for a {@link MongoURI} or {@link MongoClientURI} depending on configured
|
||||||
|
* attributes. <br />
|
||||||
* Errors when configured element contains {@literal uri} or {@literal client-uri} along with other attributes except
|
* Errors when configured element contains {@literal uri} or {@literal client-uri} along with other attributes except
|
||||||
* {@literal write-concern} and/or {@literal id}.
|
* {@literal write-concern} and/or {@literal id}.
|
||||||
*
|
*
|
||||||
@@ -145,19 +146,11 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
* @return {@literal null} in case no client-/uri defined.
|
* @return {@literal null} in case no client-/uri defined.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private BeanDefinition getConnectionString(Element element, ParserContext parserContext) {
|
private BeanDefinition getMongoUri(Element element, ParserContext parserContext) {
|
||||||
|
|
||||||
String type = null;
|
boolean hasClientUri = element.hasAttribute("client-uri");
|
||||||
|
|
||||||
if (element.hasAttribute("client-uri")) {
|
if (!hasClientUri && !element.hasAttribute("uri")) {
|
||||||
type = "client-uri";
|
|
||||||
} else if (element.hasAttribute("connection-string")) {
|
|
||||||
type = "connection-string";
|
|
||||||
} else if (element.hasAttribute("uri")) {
|
|
||||||
type = "uri";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(type)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +164,16 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser {
|
|||||||
|
|
||||||
if (element.getAttributes().getLength() > allowedAttributesCount) {
|
if (element.getAttributes().getLength() > allowedAttributesCount) {
|
||||||
|
|
||||||
parserContext.getReaderContext().error("Configure either MongoDB " + type + " or details individually!",
|
parserContext.getReaderContext().error(
|
||||||
|
"Configure either " + (hasClientUri ? "Mongo Client URI" : "Mongo URI") + " or details individually!",
|
||||||
parserContext.extractSource(element));
|
parserContext.extractSource(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ConnectionString.class);
|
Class<?> type = MongoClientURI.class;
|
||||||
builder.addConstructorArgValue(element.getAttribute(type));
|
String uri = hasClientUri ? element.getAttribute("client-uri") : element.getAttribute("uri");
|
||||||
|
|
||||||
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(type);
|
||||||
|
builder.addConstructorArgValue(uri);
|
||||||
|
|
||||||
return builder.getBeanDefinition();
|
return builder.getBeanDefinition();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.config.CustomEditorConfigurer;
|
|||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
import org.springframework.beans.factory.support.ManagedMap;
|
import org.springframework.beans.factory.support.ManagedMap;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.data.mongodb.core.MongoClientSettingsFactoryBean;
|
import org.springframework.data.mongodb.core.MongoClientOptionsFactoryBean;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
@@ -43,78 +43,60 @@ abstract class MongoParsingUtils {
|
|||||||
private MongoParsingUtils() {}
|
private MongoParsingUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the {@code mongo:client-settings} sub-element. Populates the given attribute factory with the proper
|
* Parses the mongo replica-set element.
|
||||||
* attributes.
|
*
|
||||||
*
|
* @param parserContext the parser context
|
||||||
* @param element
|
* @param element the mongo element
|
||||||
* @param mongoClientBuilder
|
* @param mongoBuilder the bean definition builder to populate
|
||||||
* @return
|
* @return
|
||||||
* @since 3.0
|
|
||||||
*/
|
*/
|
||||||
public static boolean parseMongoClientSettings(Element element, BeanDefinitionBuilder mongoClientBuilder) {
|
static void parseReplicaSet(Element element, BeanDefinitionBuilder mongoBuilder) {
|
||||||
|
setPropertyValue(mongoBuilder, element, "replica-set", "replicaSetSeeds");
|
||||||
|
}
|
||||||
|
|
||||||
Element settingsElement = DomUtils.getChildElementByTagName(element, "client-settings");
|
/**
|
||||||
if (settingsElement == null) {
|
* Parses the {@code mongo:client-options} sub-element. Populates the given attribute factory with the proper
|
||||||
|
* attributes.
|
||||||
|
*
|
||||||
|
* @param element must not be {@literal null}.
|
||||||
|
* @param mongoClientBuilder must not be {@literal null}.
|
||||||
|
* @return
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
public static boolean parseMongoClientOptions(Element element, BeanDefinitionBuilder mongoClientBuilder) {
|
||||||
|
|
||||||
|
Element optionsElement = DomUtils.getChildElementByTagName(element, "client-options");
|
||||||
|
|
||||||
|
if (optionsElement == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanDefinitionBuilder clientOptionsDefBuilder = BeanDefinitionBuilder
|
BeanDefinitionBuilder clientOptionsDefBuilder = BeanDefinitionBuilder
|
||||||
.genericBeanDefinition(MongoClientSettingsFactoryBean.class);
|
.genericBeanDefinition(MongoClientOptionsFactoryBean.class);
|
||||||
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "application-name", "applicationName");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "description", "description");
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "read-preference", "readPreference");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "min-connections-per-host", "minConnectionsPerHost");
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "read-concern", "readConcern");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "connections-per-host", "connectionsPerHost");
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "write-concern", "writeConcern");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "threads-allowed-to-block-for-connection-multiplier",
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "retry-reads", "retryReads");
|
"threadsAllowedToBlockForConnectionMultiplier");
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "retry-writes", "retryWrites");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "max-wait-time", "maxWaitTime");
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "uuid-representation", "uUidRepresentation");
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "max-connection-idle-time", "maxConnectionIdleTime");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "max-connection-life-time", "maxConnectionLifeTime");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "connect-timeout", "connectTimeout");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "socket-timeout", "socketTimeout");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "socket-keep-alive", "socketKeepAlive");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "read-preference", "readPreference");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "write-concern", "writeConcern");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "heartbeat-frequency", "heartbeatFrequency");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "min-heartbeat-frequency", "minHeartbeatFrequency");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "heartbeat-connect-timeout", "heartbeatConnectTimeout");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "heartbeat-socket-timeout", "heartbeatSocketTimeout");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "ssl", "ssl");
|
||||||
|
setPropertyReference(clientOptionsDefBuilder, optionsElement, "ssl-socket-factory-ref", "sslSocketFactory");
|
||||||
|
setPropertyReference(clientOptionsDefBuilder, optionsElement, "encryption-settings-ref", "autoEncryptionSettings");
|
||||||
|
setPropertyValue(clientOptionsDefBuilder, optionsElement, "server-selection-timeout", "serverSelectionTimeout");
|
||||||
|
|
||||||
// SocketSettings
|
mongoClientBuilder.addPropertyValue("mongoClientOptions", clientOptionsDefBuilder.getBeanDefinition());
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "socket-connect-timeout", "socketConnectTimeoutMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "socket-read-timeout", "socketReadTimeoutMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "socket-receive-buffer-size", "socketReceiveBufferSize");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "socket-send-buffer-size", "socketSendBufferSize");
|
|
||||||
|
|
||||||
// Server Settings
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "server-heartbeat-frequency",
|
|
||||||
"serverHeartbeatFrequencyMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "server-min-heartbeat-frequency",
|
|
||||||
"serverMinHeartbeatFrequencyMS");
|
|
||||||
|
|
||||||
// Cluster Settings
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-srv-host", "clusterSrvHost");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-hosts", "clusterHosts");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-connection-mode", "clusterConnectionMode");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-type", "custerRequiredClusterType");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-local-threshold", "clusterLocalThresholdMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "cluster-server-selection-timeout",
|
|
||||||
"clusterServerSelectionTimeoutMS");
|
|
||||||
|
|
||||||
// Connection Pool Settings
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-max-size", "poolMaxSize");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-min-size", "poolMinSize");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-max-wait-time", "poolMaxWaitTimeMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-max-connection-life-time",
|
|
||||||
"poolMaxConnectionLifeTimeMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-max-connection-idle-time",
|
|
||||||
"poolMaxConnectionIdleTimeMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-maintenance-initial-delay",
|
|
||||||
"poolMaintenanceInitialDelayMS");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "connection-pool-maintenance-frequency",
|
|
||||||
"poolMaintenanceFrequencyMS");
|
|
||||||
|
|
||||||
// SSL Settings
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "ssl-enabled", "sslEnabled");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "ssl-invalid-host-name-allowed",
|
|
||||||
"sslInvalidHostNameAllowed");
|
|
||||||
setPropertyValue(clientOptionsDefBuilder, settingsElement, "ssl-provider", "sslProvider");
|
|
||||||
|
|
||||||
// Field level encryption
|
|
||||||
setPropertyReference(clientOptionsDefBuilder, settingsElement, "encryption-settings-ref", "autoEncryptionSettings");
|
|
||||||
|
|
||||||
// and the rest
|
|
||||||
|
|
||||||
mongoClientBuilder.addPropertyValue("mongoClientSettings", clientOptionsDefBuilder.getBeanDefinition());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -136,24 +118,6 @@ abstract class MongoParsingUtils {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link BeanDefinitionBuilder} to build a {@link BeanDefinition} for a
|
|
||||||
* {@link ReadConcernPropertyEditor}.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
static BeanDefinitionBuilder getReadConcernPropertyEditorBuilder() {
|
|
||||||
|
|
||||||
Map<String, Class<?>> customEditors = new ManagedMap<>();
|
|
||||||
customEditors.put("com.mongodb.ReadConcern", ReadConcernPropertyEditor.class);
|
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
|
|
||||||
builder.addPropertyValue("customEditors", customEditors);
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One should only register one bean definition but want to have the convenience of using
|
* One should only register one bean definition but want to have the convenience of using
|
||||||
* AbstractSingleBeanDefinitionParser but have the side effect of registering a 'default' property editor with the
|
* AbstractSingleBeanDefinitionParser but have the side effect of registering a 'default' property editor with the
|
||||||
@@ -161,7 +125,7 @@ abstract class MongoParsingUtils {
|
|||||||
*/
|
*/
|
||||||
static BeanDefinitionBuilder getServerAddressPropertyEditorBuilder() {
|
static BeanDefinitionBuilder getServerAddressPropertyEditorBuilder() {
|
||||||
|
|
||||||
Map<String, String> customEditors = new ManagedMap<>();
|
Map<String, String> customEditors = new ManagedMap<String, String>();
|
||||||
customEditors.put("com.mongodb.ServerAddress[]",
|
customEditors.put("com.mongodb.ServerAddress[]",
|
||||||
"org.springframework.data.mongodb.config.ServerAddressPropertyEditor");
|
"org.springframework.data.mongodb.config.ServerAddressPropertyEditor");
|
||||||
|
|
||||||
@@ -179,7 +143,7 @@ abstract class MongoParsingUtils {
|
|||||||
*/
|
*/
|
||||||
static BeanDefinitionBuilder getReadPreferencePropertyEditorBuilder() {
|
static BeanDefinitionBuilder getReadPreferencePropertyEditorBuilder() {
|
||||||
|
|
||||||
Map<String, Class<?>> customEditors = new ManagedMap<>();
|
Map<String, Class<?>> customEditors = new ManagedMap<String, Class<?>>();
|
||||||
customEditors.put("com.mongodb.ReadPreference", ReadPreferencePropertyEditor.class);
|
customEditors.put("com.mongodb.ReadPreference", ReadPreferencePropertyEditor.class);
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
|
||||||
@@ -205,41 +169,4 @@ abstract class MongoParsingUtils {
|
|||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link BeanDefinitionBuilder} to build a {@link BeanDefinition} for a
|
|
||||||
* {@link ConnectionStringPropertyEditor}.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
static BeanDefinitionBuilder getConnectionStringPropertyEditorBuilder() {
|
|
||||||
|
|
||||||
Map<String, Class<?>> customEditors = new ManagedMap<>();
|
|
||||||
customEditors.put("com.mongodb.ConnectionString", ConnectionStringPropertyEditor.class);
|
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
|
|
||||||
builder.addPropertyValue("customEditors", customEditors);
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link BeanDefinitionBuilder} to build a {@link BeanDefinition} for a
|
|
||||||
* {@link ConnectionStringPropertyEditor}.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
static BeanDefinitionBuilder getUUidRepresentationEditorBuilder() {
|
|
||||||
|
|
||||||
Map<String, Class<?>> customEditors = new ManagedMap<>();
|
|
||||||
customEditors.put("org.bson.UuidRepresentation", UUidRepresentationPropertyEditor.class);
|
|
||||||
|
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
|
|
||||||
builder.addPropertyValue("customEditors", customEditors);
|
|
||||||
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb.config;
|
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.mongodb.ReadConcern;
|
|
||||||
import com.mongodb.ReadConcernLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a {@link String} to a {@link ReadConcern}. If it is a well know {@link String} as identified by the
|
|
||||||
* {@link ReadConcernLevel#fromString(String)}.
|
|
||||||
*
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public class ReadConcernPropertyEditor extends PropertyEditorSupport {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAsText(@Nullable String readConcernString) {
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(readConcernString)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(new ReadConcern(ReadConcernLevel.fromString(readConcernString)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb.config;
|
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
|
||||||
|
|
||||||
import org.bson.UuidRepresentation;
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a {@link String} to a {@link UuidRepresentation}.
|
|
||||||
*
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public class UUidRepresentationPropertyEditor extends PropertyEditorSupport {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAsText(@Nullable String value) {
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(UuidRepresentation.valueOf(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -34,7 +34,7 @@ import com.mongodb.WriteConcern;
|
|||||||
public class WriteConcernPropertyEditor extends PropertyEditorSupport {
|
public class WriteConcernPropertyEditor extends PropertyEditorSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a string to a {@link WriteConcern}.
|
* Parse a string to a List<ServerAddress>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(@Nullable String writeConcernString) {
|
public void setAsText(@Nullable String writeConcernString) {
|
||||||
@@ -51,5 +51,6 @@ public class WriteConcernPropertyEditor extends PropertyEditorSupport {
|
|||||||
// pass on the string to the constructor
|
// pass on the string to the constructor
|
||||||
setValue(new WriteConcern(writeConcernString));
|
setValue(new WriteConcern(writeConcernString));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -94,7 +94,6 @@ public interface BulkOperations {
|
|||||||
* Add a list of updates to the bulk operation. For each update request, all matching documents are updated.
|
* Add a list of updates to the bulk operation. For each update request, all matching documents are updated.
|
||||||
*
|
*
|
||||||
* @param updates Update operations to perform.
|
* @param updates Update operations to perform.
|
||||||
* @return The bulk operation.
|
|
||||||
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
||||||
*/
|
*/
|
||||||
BulkOperations updateMulti(List<Pair<Query, Update>> updates);
|
BulkOperations updateMulti(List<Pair<Query, Update>> updates);
|
||||||
@@ -105,7 +104,6 @@ public interface BulkOperations {
|
|||||||
*
|
*
|
||||||
* @param query Update criteria.
|
* @param query Update criteria.
|
||||||
* @param update Update operation to perform.
|
* @param update Update operation to perform.
|
||||||
* @return The bulk operation.
|
|
||||||
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
||||||
*/
|
*/
|
||||||
BulkOperations upsert(Query query, Update update);
|
BulkOperations upsert(Query query, Update update);
|
||||||
@@ -115,7 +113,6 @@ public interface BulkOperations {
|
|||||||
* else an insert.
|
* else an insert.
|
||||||
*
|
*
|
||||||
* @param updates Updates/insert operations to perform.
|
* @param updates Updates/insert operations to perform.
|
||||||
* @return The bulk operation.
|
|
||||||
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
|
||||||
*/
|
*/
|
||||||
BulkOperations upsert(List<Pair<Query, Update>> updates);
|
BulkOperations upsert(List<Pair<Query, Update>> updates);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -29,7 +29,7 @@ import com.mongodb.client.MongoCollection;
|
|||||||
* @author Grame Rocher
|
* @author Grame Rocher
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author John Brisbin
|
* @author John Brisbin
|
||||||
* @auhtor Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public interface CollectionCallback<T> {
|
public interface CollectionCallback<T> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -95,7 +95,7 @@ public class CollectionOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new {@link CollectionOptions} with already given settings and capped set to {@literal true}. <br />
|
* Create new {@link CollectionOptions} with already given settings and capped set to {@literal true}. <br />
|
||||||
* <strong>NOTE</strong> Using capped collections requires defining {@link #size(int)}.
|
* <strong>NOTE</strong> Using capped collections requires defining {@link #size(long)}.
|
||||||
*
|
*
|
||||||
* @return new {@link CollectionOptions}.
|
* @return new {@link CollectionOptions}.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
|
|||||||
@@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.mongodb.core;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bson.Document;
|
|
||||||
|
|
||||||
import org.springframework.data.geo.Point;
|
|
||||||
import org.springframework.lang.Nullable;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Value object representing a count query. Count queries using {@code $near} or {@code $nearSphere} require a rewrite
|
|
||||||
* to {@code $geoWithin}.
|
|
||||||
*
|
|
||||||
* @author Christoph Strobl
|
|
||||||
* @author Mark Paluch
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
class CountQuery {
|
|
||||||
|
|
||||||
private Document source;
|
|
||||||
|
|
||||||
private CountQuery(Document source) {
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CountQuery of(Document source) {
|
|
||||||
return new CountQuery(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the query {@link Document} that can be used with {@code countDocuments()}. Potentially rewrites the query
|
|
||||||
* to be usable with {@code countDocuments()}.
|
|
||||||
*
|
|
||||||
* @return the query {@link Document} that can be used with {@code countDocuments()}.
|
|
||||||
*/
|
|
||||||
public Document toQueryDocument() {
|
|
||||||
|
|
||||||
if (!requiresRewrite(source)) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
Document target = new Document();
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : source.entrySet()) {
|
|
||||||
|
|
||||||
if (entry.getValue() instanceof Document && requiresRewrite(entry.getValue())) {
|
|
||||||
|
|
||||||
Document theValue = (Document) entry.getValue();
|
|
||||||
target.putAll(createGeoWithin(entry.getKey(), theValue, source.get("$and")));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry.getValue() instanceof Collection && requiresRewrite(entry.getValue())) {
|
|
||||||
|
|
||||||
Collection<?> source = (Collection<?>) entry.getValue();
|
|
||||||
|
|
||||||
target.put(entry.getKey(), rewriteCollection(source));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("$and".equals(entry.getKey()) && target.containsKey("$and")) {
|
|
||||||
// Expect $and to be processed with Document and createGeoWithin.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
target.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param valueToInspect
|
|
||||||
* @return {@code true} if the enclosing element needs to be rewritten.
|
|
||||||
*/
|
|
||||||
private boolean requiresRewrite(Object valueToInspect) {
|
|
||||||
|
|
||||||
if (valueToInspect instanceof Document) {
|
|
||||||
return requiresRewrite((Document) valueToInspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueToInspect instanceof Collection) {
|
|
||||||
return requiresRewrite((Collection) valueToInspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean requiresRewrite(Collection<?> collection) {
|
|
||||||
|
|
||||||
for (Object o : collection) {
|
|
||||||
if (o instanceof Document && requiresRewrite((Document) o)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean requiresRewrite(Document document) {
|
|
||||||
|
|
||||||
if (containsNear(document)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Object entry : document.values()) {
|
|
||||||
|
|
||||||
if (requiresRewrite(entry)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<Object> rewriteCollection(Collection<?> source) {
|
|
||||||
|
|
||||||
Collection<Object> rewrittenCollection = new ArrayList<>(source.size());
|
|
||||||
|
|
||||||
for (Object item : source) {
|
|
||||||
if (item instanceof Document && requiresRewrite(item)) {
|
|
||||||
rewrittenCollection.add(CountQuery.of((Document) item).toQueryDocument());
|
|
||||||
} else {
|
|
||||||
rewrittenCollection.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rewrittenCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rewrite the near query for field {@code key} to {@code $geoWithin}.
|
|
||||||
*
|
|
||||||
* @param key the queried field.
|
|
||||||
* @param source source {@link Document}.
|
|
||||||
* @param $and potentially existing {@code $and} condition.
|
|
||||||
* @return the rewritten query {@link Document}.
|
|
||||||
*/
|
|
||||||
private static Document createGeoWithin(String key, Document source, @Nullable Object $and) {
|
|
||||||
|
|
||||||
boolean spheric = source.containsKey("$nearSphere");
|
|
||||||
Object $near = spheric ? source.get("$nearSphere") : source.get("$near");
|
|
||||||
|
|
||||||
Number maxDistance = source.containsKey("$maxDistance") ? (Number) source.get("$maxDistance") : Double.MAX_VALUE;
|
|
||||||
List<Object> $centerMax = Arrays.asList(toCenterCoordinates($near), maxDistance);
|
|
||||||
Document $geoWithinMax = new Document("$geoWithin",
|
|
||||||
new Document(spheric ? "$centerSphere" : "$center", $centerMax));
|
|
||||||
|
|
||||||
if (!containsNearWithMinDistance(source)) {
|
|
||||||
return new Document(key, $geoWithinMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
Number minDistance = (Number) source.get("$minDistance");
|
|
||||||
List<Object> $centerMin = Arrays.asList(toCenterCoordinates($near), minDistance);
|
|
||||||
Document $geoWithinMin = new Document("$geoWithin",
|
|
||||||
new Document(spheric ? "$centerSphere" : "$center", $centerMin));
|
|
||||||
|
|
||||||
List<Document> criteria = new ArrayList<>();
|
|
||||||
|
|
||||||
if ($and != null) {
|
|
||||||
if ($and instanceof Collection) {
|
|
||||||
criteria.addAll((Collection) $and);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Cannot rewrite query as it contains an '$and' element that is not a Collection!: Offending element: "
|
|
||||||
+ $and);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
criteria.add(new Document("$nor", Collections.singletonList(new Document(key, $geoWithinMin))));
|
|
||||||
criteria.add(new Document(key, $geoWithinMax));
|
|
||||||
return new Document("$and", criteria);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean containsNear(Document source) {
|
|
||||||
return source.containsKey("$near") || source.containsKey("$nearSphere");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean containsNearWithMinDistance(Document source) {
|
|
||||||
|
|
||||||
if (!containsNear(source)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source.containsKey("$minDistance");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object toCenterCoordinates(Object value) {
|
|
||||||
|
|
||||||
if (ObjectUtils.isArray(value)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Point) {
|
|
||||||
return Arrays.asList(((Point) value).getX(), ((Point) value).getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Document && ((Document) value).containsKey("x")) {
|
|
||||||
|
|
||||||
Document point = (Document) value;
|
|
||||||
return Arrays.asList(point.get("x"), point.get("y"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,9 +43,10 @@ public interface CursorPreparer extends ReadPreferenceAware {
|
|||||||
/**
|
/**
|
||||||
* Prepare the given cursor (apply limits, skips and so on). Returns the prepared cursor.
|
* Prepare the given cursor (apply limits, skips and so on). Returns the prepared cursor.
|
||||||
*
|
*
|
||||||
* @param cursor
|
* @param iterable must not be {@literal null}.
|
||||||
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
FindIterable<Document> prepare(FindIterable<Document> cursor);
|
FindIterable<Document> prepare(FindIterable<Document> iterable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply query specific settings to {@link MongoCollection} and initate a find operation returning a
|
* Apply query specific settings to {@link MongoCollection} and initate a find operation returning a
|
||||||
@@ -53,7 +54,7 @@ public interface CursorPreparer extends ReadPreferenceAware {
|
|||||||
*
|
*
|
||||||
* @param collection must not be {@literal null}.
|
* @param collection must not be {@literal null}.
|
||||||
* @param find must not be {@literal null}.
|
* @param find must not be {@literal null}.
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws IllegalArgumentException if one of the required arguments is {@literal null}.
|
* @throws IllegalArgumentException if one of the required arguments is {@literal null}.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -32,7 +32,6 @@ import org.springframework.data.mapping.callback.EntityCallbacks;
|
|||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
import org.springframework.data.mongodb.core.convert.UpdateMapper;
|
import org.springframework.data.mongodb.core.convert.UpdateMapper;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.AfterSaveCallback;
|
|
||||||
import org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent;
|
import org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback;
|
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback;
|
||||||
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
|
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
|
||||||
@@ -63,7 +62,6 @@ import com.mongodb.client.model.*;
|
|||||||
* @author Minsu Kim
|
* @author Minsu Kim
|
||||||
* @author Jens Schauder
|
* @author Jens Schauder
|
||||||
* @author Michail Nikolaev
|
* @author Michail Nikolaev
|
||||||
* @author Roman Puchkovskiy
|
|
||||||
* @since 1.9
|
* @since 1.9
|
||||||
*/
|
*/
|
||||||
class DefaultBulkOperations implements BulkOperations {
|
class DefaultBulkOperations implements BulkOperations {
|
||||||
@@ -302,7 +300,6 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
Assert.state(result != null, "Result must not be null.");
|
Assert.state(result != null, "Result must not be null.");
|
||||||
|
|
||||||
models.forEach(this::maybeEmitAfterSaveEvent);
|
models.forEach(this::maybeEmitAfterSaveEvent);
|
||||||
models.forEach(this::maybeInvokeAfterSaveCallback);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -424,52 +421,38 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
models.add(new SourceAwareWriteModelHolder(source, model));
|
models.add(new SourceAwareWriteModelHolder(source, model));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeEmitBeforeSaveEvent(SourceAwareWriteModelHolder holder) {
|
private void maybeEmitBeforeSaveEvent(SourceAwareWriteModelHolder it) {
|
||||||
|
|
||||||
if (holder.getModel() instanceof InsertOneModel) {
|
if (it.getModel() instanceof InsertOneModel) {
|
||||||
|
|
||||||
Document target = ((InsertOneModel<Document>) holder.getModel()).getDocument();
|
Document target = ((InsertOneModel<Document>) it.getModel()).getDocument();
|
||||||
maybeEmitEvent(new BeforeSaveEvent<>(holder.getSource(), target, collectionName));
|
maybeEmitEvent(new BeforeSaveEvent<>(it.getSource(), target, collectionName));
|
||||||
} else if (holder.getModel() instanceof ReplaceOneModel) {
|
} else if (it.getModel() instanceof ReplaceOneModel) {
|
||||||
|
|
||||||
Document target = ((ReplaceOneModel<Document>) holder.getModel()).getReplacement();
|
Document target = ((ReplaceOneModel<Document>) it.getModel()).getReplacement();
|
||||||
maybeEmitEvent(new BeforeSaveEvent<>(holder.getSource(), target, collectionName));
|
maybeEmitEvent(new BeforeSaveEvent<>(it.getSource(), target, collectionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeEmitAfterSaveEvent(SourceAwareWriteModelHolder holder) {
|
private void maybeEmitAfterSaveEvent(SourceAwareWriteModelHolder it) {
|
||||||
|
|
||||||
if (holder.getModel() instanceof InsertOneModel) {
|
if (it.getModel() instanceof InsertOneModel) {
|
||||||
|
|
||||||
Document target = ((InsertOneModel<Document>) holder.getModel()).getDocument();
|
Document target = ((InsertOneModel<Document>) it.getModel()).getDocument();
|
||||||
maybeEmitEvent(new AfterSaveEvent<>(holder.getSource(), target, collectionName));
|
maybeEmitEvent(new AfterSaveEvent<>(it.getSource(), target, collectionName));
|
||||||
} else if (holder.getModel() instanceof ReplaceOneModel) {
|
} else if (it.getModel() instanceof ReplaceOneModel) {
|
||||||
|
|
||||||
Document target = ((ReplaceOneModel<Document>) holder.getModel()).getReplacement();
|
Document target = ((ReplaceOneModel<Document>) it.getModel()).getReplacement();
|
||||||
maybeEmitEvent(new AfterSaveEvent<>(holder.getSource(), target, collectionName));
|
maybeEmitEvent(new AfterSaveEvent<>(it.getSource(), target, collectionName));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void maybeInvokeAfterSaveCallback(SourceAwareWriteModelHolder holder) {
|
|
||||||
|
|
||||||
if (holder.getModel() instanceof InsertOneModel) {
|
|
||||||
|
|
||||||
Document target = ((InsertOneModel<Document>) holder.getModel()).getDocument();
|
|
||||||
maybeInvokeAfterSaveCallback(holder.getSource(), target);
|
|
||||||
} else if (holder.getModel() instanceof ReplaceOneModel) {
|
|
||||||
|
|
||||||
Document target = ((ReplaceOneModel<Document>) holder.getModel()).getReplacement();
|
|
||||||
maybeInvokeAfterSaveCallback(holder.getSource(), target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <E extends MongoMappingEvent<T>, T> E maybeEmitEvent(E event) {
|
private <E extends MongoMappingEvent<T>, T> E maybeEmitEvent(E event) {
|
||||||
|
|
||||||
if (bulkOperationContext.getEventPublisher() == null) {
|
if (null != bulkOperationContext.getEventPublisher()) {
|
||||||
return event;
|
bulkOperationContext.getEventPublisher().publishEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bulkOperationContext.getEventPublisher().publishEvent(event);
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,16 +475,6 @@ class DefaultBulkOperations implements BulkOperations {
|
|||||||
collectionName);
|
collectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object maybeInvokeAfterSaveCallback(Object value, Document mappedDocument) {
|
|
||||||
|
|
||||||
if (bulkOperationContext.getEntityCallbacks() == null) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bulkOperationContext.getEntityCallbacks().callback(AfterSaveCallback.class, value, mappedDocument,
|
|
||||||
collectionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BulkWriteOptions getBulkWriteOptions(BulkMode bulkMode) {
|
private static BulkWriteOptions getBulkWriteOptions(BulkMode bulkMode) {
|
||||||
|
|
||||||
BulkWriteOptions options = new BulkWriteOptions();
|
BulkWriteOptions options = new BulkWriteOptions();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011-2020 the original author or authors.
|
* Copyright 2011-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
import org.springframework.data.mongodb.MongoDbFactory;
|
||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
import org.springframework.data.mongodb.core.index.IndexDefinition;
|
import org.springframework.data.mongodb.core.index.IndexDefinition;
|
||||||
import org.springframework.data.mongodb.core.index.IndexInfo;
|
import org.springframework.data.mongodb.core.index.IndexInfo;
|
||||||
@@ -64,7 +64,7 @@ public class DefaultIndexOperations implements IndexOperations {
|
|||||||
* {@link DefaultIndexOperations#DefaultIndexOperations(MongoOperations, String, Class)}.
|
* {@link DefaultIndexOperations#DefaultIndexOperations(MongoOperations, String, Class)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper) {
|
public DefaultIndexOperations(MongoDbFactory mongoDbFactory, String collectionName, QueryMapper queryMapper) {
|
||||||
this(mongoDbFactory, collectionName, queryMapper, null);
|
this(mongoDbFactory, collectionName, queryMapper, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class DefaultIndexOperations implements IndexOperations {
|
|||||||
* {@link DefaultIndexOperations#DefaultIndexOperations(MongoOperations, String, Class)}.
|
* {@link DefaultIndexOperations#DefaultIndexOperations(MongoOperations, String, Class)}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DefaultIndexOperations(MongoDatabaseFactory mongoDbFactory, String collectionName, QueryMapper queryMapper,
|
public DefaultIndexOperations(MongoDbFactory mongoDbFactory, String collectionName, QueryMapper queryMapper,
|
||||||
@Nullable Class<?> type) {
|
@Nullable Class<?> type) {
|
||||||
|
|
||||||
Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!");
|
Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
import org.springframework.data.mongodb.MongoDbFactory;
|
||||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||||
import org.springframework.data.mongodb.core.index.IndexOperations;
|
import org.springframework.data.mongodb.core.index.IndexOperations;
|
||||||
import org.springframework.data.mongodb.core.index.IndexOperationsProvider;
|
import org.springframework.data.mongodb.core.index.IndexOperationsProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link IndexOperationsProvider} to obtain {@link IndexOperations} from a given {@link MongoDatabaseFactory}.
|
* {@link IndexOperationsProvider} to obtain {@link IndexOperations} from a given {@link MongoDbFactory}.
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
@@ -29,14 +29,14 @@ import org.springframework.data.mongodb.core.index.IndexOperationsProvider;
|
|||||||
*/
|
*/
|
||||||
class DefaultIndexOperationsProvider implements IndexOperationsProvider {
|
class DefaultIndexOperationsProvider implements IndexOperationsProvider {
|
||||||
|
|
||||||
private final MongoDatabaseFactory mongoDbFactory;
|
private final MongoDbFactory mongoDbFactory;
|
||||||
private final QueryMapper mapper;
|
private final QueryMapper mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mongoDbFactory must not be {@literal null}.
|
* @param mongoDbFactory must not be {@literal null}.
|
||||||
* @param mapper must not be {@literal null}.
|
* @param mapper must not be {@literal null}.
|
||||||
*/
|
*/
|
||||||
DefaultIndexOperationsProvider(MongoDatabaseFactory mongoDbFactory, QueryMapper mapper) {
|
DefaultIndexOperationsProvider(MongoDbFactory mongoDbFactory, QueryMapper mapper) {
|
||||||
|
|
||||||
this.mongoDbFactory = mongoDbFactory;
|
this.mongoDbFactory = mongoDbFactory;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2020 the original author or authors.
|
* Copyright 2014-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2020 the original author or authors.
|
* Copyright 2015-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,7 @@ import com.mongodb.MongoException;
|
|||||||
/**
|
/**
|
||||||
* An interface used by {@link MongoTemplate} for processing documents returned from a MongoDB query on a per-document
|
* An interface used by {@link MongoTemplate} for processing documents returned from a MongoDB query on a per-document
|
||||||
* basis. Implementations of this interface perform the actual work of prcoessing each document but don't need to worry
|
* basis. Implementations of this interface perform the actual work of prcoessing each document but don't need to worry
|
||||||
* about exception handling. {@MongoException}s will be caught and translated by the calling MongoTemplate An
|
* about exception handling. {@link MongoException}s will be caught and translated by the calling MongoTemplate An
|
||||||
* DocumentCallbackHandler is typically stateful: It keeps the result state within the object, to be available later for
|
* DocumentCallbackHandler is typically stateful: It keeps the result state within the object, to be available later for
|
||||||
* later inspection.
|
* later inspection.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -66,7 +66,7 @@ class EntityOperations {
|
|||||||
* Creates a new {@link Entity} for the given bean.
|
* Creates a new {@link Entity} for the given bean.
|
||||||
*
|
*
|
||||||
* @param entity must not be {@literal null}.
|
* @param entity must not be {@literal null}.
|
||||||
* @return
|
* @return new instance of {@link Entity}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public <T> Entity<T> forEntity(T entity) {
|
public <T> Entity<T> forEntity(T entity) {
|
||||||
@@ -89,7 +89,7 @@ class EntityOperations {
|
|||||||
*
|
*
|
||||||
* @param entity must not be {@literal null}.
|
* @param entity must not be {@literal null}.
|
||||||
* @param conversionService must not be {@literal null}.
|
* @param conversionService must not be {@literal null}.
|
||||||
* @return
|
* @return new instance of {@link AdaptibleEntity}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public <T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) {
|
public <T> AdaptibleEntity<T> forEntity(T entity, ConversionService conversionService) {
|
||||||
@@ -108,6 +108,10 @@ class EntityOperations {
|
|||||||
return AdaptibleMappedEntity.of(entity, context, conversionService);
|
return AdaptibleMappedEntity.of(entity, context, conversionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param entityClass should not be null.
|
||||||
|
* @return the {@link MongoPersistentEntity#getCollection() collection name}.
|
||||||
|
*/
|
||||||
public String determineCollectionName(@Nullable Class<?> entityClass) {
|
public String determineCollectionName(@Nullable Class<?> entityClass) {
|
||||||
|
|
||||||
if (entityClass == null) {
|
if (entityClass == null) {
|
||||||
@@ -138,7 +142,7 @@ class EntityOperations {
|
|||||||
* {@code _id} if no identifier property can be found.
|
* {@code _id} if no identifier property can be found.
|
||||||
*
|
*
|
||||||
* @param type must not be {@literal null}.
|
* @param type must not be {@literal null}.
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
public String getIdPropertyName(Class<?> type) {
|
public String getIdPropertyName(Class<?> type) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -88,10 +88,10 @@ public interface ExecutableAggregationOperation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply pipeline operations as specified and stream all matching elements. <br />
|
* Apply pipeline operations as specified and stream all matching elements. <br />
|
||||||
* Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link com.mongodb.Cursor}
|
* Returns a {@link CloseableIterator} that wraps the a Mongo DB {@link com.mongodb.client.FindIterable}
|
||||||
*
|
*
|
||||||
* @return a {@link CloseableIterator} that wraps the a Mongo DB {@link com.mongodb.Cursor} that needs to be closed.
|
* @return a {@link CloseableIterator} that wraps the a Mongo DB {@link com.mongodb.client.FindIterable} that needs
|
||||||
* Never {@literal null}.
|
* to be closed. Never {@literal null}.
|
||||||
*/
|
*/
|
||||||
CloseableIterator<T> stream();
|
CloseableIterator<T> stream();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,6 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.geo.GeoResults;
|
import org.springframework.data.geo.GeoResults;
|
||||||
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
|
|
||||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
@@ -44,7 +43,7 @@ import com.mongodb.client.MongoCollection;
|
|||||||
* query(Human.class)
|
* query(Human.class)
|
||||||
* .inCollection("star-wars")
|
* .inCollection("star-wars")
|
||||||
* .as(Jedi.class)
|
* .as(Jedi.class)
|
||||||
* .matching(where("firstname").is("luke"))
|
* .matching(query(where("firstname").is("luke")))
|
||||||
* .all();
|
* .all();
|
||||||
* </code>
|
* </code>
|
||||||
* </pre>
|
* </pre>
|
||||||
@@ -118,8 +117,8 @@ public interface ExecutableFindOperation {
|
|||||||
/**
|
/**
|
||||||
* Stream all matching elements.
|
* Stream all matching elements.
|
||||||
*
|
*
|
||||||
* @return a {@link Stream} that wraps the a Mongo DB {@link com.mongodb.Cursor} that needs to be closed. Never
|
* @return a {@link Stream} that wraps the a Mongo DB {@link com.mongodb.client.FindIterable} that needs to be
|
||||||
* {@literal null}.
|
* closed. Never {@literal null}.
|
||||||
*/
|
*/
|
||||||
Stream<T> stream();
|
Stream<T> stream();
|
||||||
|
|
||||||
@@ -171,18 +170,6 @@ public interface ExecutableFindOperation {
|
|||||||
*/
|
*/
|
||||||
TerminatingFind<T> matching(Query query);
|
TerminatingFind<T> matching(Query query);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the filter {@link CriteriaDefinition criteria} to be used.
|
|
||||||
*
|
|
||||||
* @param criteria must not be {@literal null}.
|
|
||||||
* @return new instance of {@link TerminatingFind}.
|
|
||||||
* @throws IllegalArgumentException if criteria is {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
default TerminatingFind<T> matching(CriteriaDefinition criteria) {
|
|
||||||
return matching(Query.query(criteria));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filter query for the geoNear execution.
|
* Set the filter query for the geoNear execution.
|
||||||
*
|
*
|
||||||
@@ -304,21 +291,9 @@ public interface ExecutableFindOperation {
|
|||||||
*
|
*
|
||||||
* @param query must not be {@literal null}.
|
* @param query must not be {@literal null}.
|
||||||
* @return new instance of {@link TerminatingDistinct}.
|
* @return new instance of {@link TerminatingDistinct}.
|
||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
* @throws IllegalArgumentException if resultType is {@literal null}.
|
||||||
*/
|
*/
|
||||||
TerminatingDistinct<T> matching(Query query);
|
TerminatingDistinct<T> matching(Query query);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the filter {@link CriteriaDefinition criteria} to be used.
|
|
||||||
*
|
|
||||||
* @param criteria must not be {@literal null}.
|
|
||||||
* @return new instance of {@link TerminatingDistinct}.
|
|
||||||
* @throws IllegalArgumentException if criteria is {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
default TerminatingDistinct<T> matching(CriteriaDefinition criteria) {
|
|
||||||
return matching(Query.query(criteria));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.mongodb.core;
|
package org.springframework.data.mongodb.core;
|
||||||
|
|
||||||
import com.mongodb.ReadPreference;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -26,6 +25,7 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
|
||||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
|||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.mongodb.ReadPreference;
|
||||||
import com.mongodb.client.FindIterable;
|
import com.mongodb.client.FindIterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,9 +258,9 @@ class ExecutableFindOperationSupport implements ExecutableFindOperation {
|
|||||||
* @see org.springframework.data.mongodb.core.CursorPreparer#prepare(com.mongodb.clientFindIterable)
|
* @see org.springframework.data.mongodb.core.CursorPreparer#prepare(com.mongodb.clientFindIterable)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FindIterable<Document> prepare(FindIterable<Document> cursor) {
|
public FindIterable<Document> prepare(FindIterable<Document> iterable) {
|
||||||
|
|
||||||
FindIterable<Document> target = delegate != null ? delegate.prepare(cursor) : cursor;
|
FindIterable<Document> target = delegate != null ? delegate.prepare(iterable) : iterable;
|
||||||
return limit.map(target::limit).orElse(target);
|
return limit.map(target::limit).orElse(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,7 +19,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
import org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind;
|
||||||
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
|
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
|
||||||
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +30,7 @@ import org.springframework.data.mongodb.core.query.Query;
|
|||||||
* The collection to operate on is by default derived from the initial {@literal domainType} and can be defined there
|
* The collection to operate on is by default derived from the initial {@literal domainType} and can be defined there
|
||||||
* via {@link org.springframework.data.mongodb.core.mapping.Document}. Using {@code inCollection} allows to override the
|
* via {@link org.springframework.data.mongodb.core.mapping.Document}. Using {@code inCollection} allows to override the
|
||||||
* collection name for the execution.
|
* collection name for the execution.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* <code>
|
* <code>
|
||||||
* mapReduce(Human.class)
|
* mapReduce(Human.class)
|
||||||
@@ -45,7 +44,6 @@ import org.springframework.data.mongodb.core.query.Query;
|
|||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public interface ExecutableMapReduceOperation {
|
public interface ExecutableMapReduceOperation {
|
||||||
@@ -148,18 +146,6 @@ public interface ExecutableMapReduceOperation {
|
|||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
* @throws IllegalArgumentException if query is {@literal null}.
|
||||||
*/
|
*/
|
||||||
TerminatingMapReduce<T> matching(Query query);
|
TerminatingMapReduce<T> matching(Query query);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the filter {@link CriteriaDefinition criteria} to be used.
|
|
||||||
*
|
|
||||||
* @param criteria must not be {@literal null}.
|
|
||||||
* @return new instance of {@link TerminatingMapReduce}.
|
|
||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
default TerminatingMapReduce<T> matching(CriteriaDefinition criteria) {
|
|
||||||
return matching(Query.query(criteria));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,7 +17,6 @@ package org.springframework.data.mongodb.core;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
|
||||||
import com.mongodb.client.result.DeleteResult;
|
import com.mongodb.client.result.DeleteResult;
|
||||||
@@ -120,18 +119,6 @@ public interface ExecutableRemoveOperation {
|
|||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
* @throws IllegalArgumentException if query is {@literal null}.
|
||||||
*/
|
*/
|
||||||
TerminatingRemove<T> matching(Query query);
|
TerminatingRemove<T> matching(Query query);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the filter {@link CriteriaDefinition criteria} to be used.
|
|
||||||
*
|
|
||||||
* @param criteria must not be {@literal null}.
|
|
||||||
* @return new instance of {@link TerminatingRemove}.
|
|
||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
default TerminatingRemove<T> matching(CriteriaDefinition criteria) {
|
|
||||||
return matching(Query.query(criteria));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,11 +17,8 @@ package org.springframework.data.mongodb.core;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.aggregation.AggregationUpdate;
|
|
||||||
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.data.mongodb.core.query.Update;
|
import org.springframework.data.mongodb.core.query.Update;
|
||||||
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
import com.mongodb.client.result.UpdateResult;
|
import com.mongodb.client.result.UpdateResult;
|
||||||
@@ -154,16 +151,13 @@ public interface ExecutableUpdateOperation {
|
|||||||
interface UpdateWithUpdate<T> {
|
interface UpdateWithUpdate<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link UpdateDefinition} to be applied.
|
* Set the {@link Update} to be applied.
|
||||||
*
|
*
|
||||||
* @param update must not be {@literal null}.
|
* @param update must not be {@literal null}.
|
||||||
* @return new instance of {@link TerminatingUpdate}.
|
* @return new instance of {@link TerminatingUpdate}.
|
||||||
* @throws IllegalArgumentException if update is {@literal null}.
|
* @throws IllegalArgumentException if update is {@literal null}.
|
||||||
* @since 3.0
|
|
||||||
* @see Update
|
|
||||||
* @see AggregationUpdate
|
|
||||||
*/
|
*/
|
||||||
TerminatingUpdate<T> apply(UpdateDefinition update);
|
TerminatingUpdate<T> apply(Update update);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify {@code replacement} object.
|
* Specify {@code replacement} object.
|
||||||
@@ -211,18 +205,6 @@ public interface ExecutableUpdateOperation {
|
|||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
* @throws IllegalArgumentException if query is {@literal null}.
|
||||||
*/
|
*/
|
||||||
UpdateWithUpdate<T> matching(Query query);
|
UpdateWithUpdate<T> matching(Query query);
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the filter {@link CriteriaDefinition criteria} to be used.
|
|
||||||
*
|
|
||||||
* @param criteria must not be {@literal null}.
|
|
||||||
* @return new instance of {@link UpdateWithUpdate}.
|
|
||||||
* @throws IllegalArgumentException if query is {@literal null}.
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
default UpdateWithUpdate<T> matching(CriteriaDefinition criteria) {
|
|
||||||
return matching(Query.query(criteria));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.data.mongodb.core.query.UpdateDefinition;
|
import org.springframework.data.mongodb.core.query.Update;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -67,7 +67,7 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
|||||||
@NonNull MongoTemplate template;
|
@NonNull MongoTemplate template;
|
||||||
@NonNull Class domainType;
|
@NonNull Class domainType;
|
||||||
Query query;
|
Query query;
|
||||||
@Nullable UpdateDefinition update;
|
@Nullable Update update;
|
||||||
@Nullable String collection;
|
@Nullable String collection;
|
||||||
@Nullable FindAndModifyOptions findAndModifyOptions;
|
@Nullable FindAndModifyOptions findAndModifyOptions;
|
||||||
@Nullable FindAndReplaceOptions findAndReplaceOptions;
|
@Nullable FindAndReplaceOptions findAndReplaceOptions;
|
||||||
@@ -76,10 +76,10 @@ class ExecutableUpdateOperationSupport implements ExecutableUpdateOperation {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.springframework.data.mongodb.core.ExecutableUpdateOperation.UpdateWithUpdate#apply(org.springframework.data.mongodb.core.query.UpdateDefinition)
|
* @see org.springframework.data.mongodb.core.ExecutableUpdateOperation.UpdateWithUpdate#apply(Update)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TerminatingUpdate<T> apply(UpdateDefinition update) {
|
public TerminatingUpdate<T> apply(Update update) {
|
||||||
|
|
||||||
Assert.notNull(update, "Update must not be null!");
|
Assert.notNull(update, "Update must not be null!");
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 the original author or authors.
|
* Copyright 2010-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -78,7 +78,7 @@ public class FindAndModifyOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new {@link FindAndModifyOptions} based on option of given {@litearl source}.
|
* Create new {@link FindAndModifyOptions} based on option of given {@literal source}.
|
||||||
*
|
*
|
||||||
* @param source can be {@literal null}.
|
* @param source can be {@literal null}.
|
||||||
* @return new instance of {@link FindAndModifyOptions}.
|
* @return new instance of {@link FindAndModifyOptions}.
|
||||||
@@ -117,8 +117,8 @@ public class FindAndModifyOptions {
|
|||||||
/**
|
/**
|
||||||
* Define the {@link Collation} specifying language-specific rules for string comparison.
|
* Define the {@link Collation} specifying language-specific rules for string comparison.
|
||||||
*
|
*
|
||||||
* @param collation
|
* @param collation can be {@literal null}.
|
||||||
* @return
|
* @return this.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public FindAndModifyOptions collation(@Nullable Collation collation) {
|
public FindAndModifyOptions collation(@Nullable Collation collation) {
|
||||||
@@ -142,7 +142,7 @@ public class FindAndModifyOptions {
|
|||||||
/**
|
/**
|
||||||
* Get the {@link Collation} specifying language-specific rules for string comparison.
|
* Get the {@link Collation} specifying language-specific rules for string comparison.
|
||||||
*
|
*
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public Optional<Collation> getCollation() {
|
public Optional<Collation> getCollation() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018-2020 the original author or authors.
|
* Copyright 2018-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -116,7 +116,7 @@ public class FindAndReplaceOptions {
|
|||||||
/**
|
/**
|
||||||
* Get the bit indicating to return the replacement document.
|
* Get the bit indicating to return the replacement document.
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@literal true} if set.
|
||||||
*/
|
*/
|
||||||
public boolean isReturnNew() {
|
public boolean isReturnNew() {
|
||||||
return returnNew;
|
return returnNew;
|
||||||
@@ -125,7 +125,7 @@ public class FindAndReplaceOptions {
|
|||||||
/**
|
/**
|
||||||
* Get the bit indicating if to create a new document if not exists.
|
* Get the bit indicating if to create a new document if not exists.
|
||||||
*
|
*
|
||||||
* @return
|
* @return {@literal true} if set.
|
||||||
*/
|
*/
|
||||||
public boolean isUpsert() {
|
public boolean isUpsert() {
|
||||||
return upsert;
|
return upsert;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016-2020 the original author or authors.
|
* Copyright 2016-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -54,7 +54,7 @@ public interface FindPublisherPreparer extends ReadPreferenceAware {
|
|||||||
*
|
*
|
||||||
* @param collection must not be {@literal null}.
|
* @param collection must not be {@literal null}.
|
||||||
* @param find must not be {@literal null}.
|
* @param find must not be {@literal null}.
|
||||||
* @return
|
* @return never {@literal null}.
|
||||||
* @throws IllegalArgumentException if one of the required arguments is {@literal null}.
|
* @throws IllegalArgumentException if one of the required arguments is {@literal null}.
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017-2020 the original author or authors.
|
* Copyright 2017-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user