Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
78ce06cc
Commit
78ce06cc
authored
Nov 19, 2013
by
Michael Nitschinger
Committed by
Dave Syer
Apr 25, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for spring-data-couchbase
Fixes gh-124
parent
c4ffe721
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
398 additions
and
0 deletions
+398
-0
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-0
CouchbaseRepositoriesAutoConfiguration.java
...onfigure/data/CouchbaseRepositoriesAutoConfiguration.java
+114
-0
CouchbaseRepositoriesAutoConfigureRegistrar.java
...ure/data/CouchbaseRepositoriesAutoConfigureRegistrar.java
+55
-0
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+1
-0
CouchbaseRepositoriesAutoConfigurationTests.java
...ure/data/CouchbaseRepositoriesAutoConfigurationTests.java
+81
-0
City.java
...ringframework/boot/autoconfigure/data/couchbase/City.java
+83
-0
CityRepository.java
...ork/boot/autoconfigure/data/couchbase/CityRepository.java
+25
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-0
pom.xml
spring-boot-starters/pom.xml
+1
-0
.gitignore
...ot-starters/spring-boot-starter-data-couchbase/.gitignore
+1
-0
pom.xml
...-boot-starters/spring-boot-starter-data-couchbase/pom.xml
+21
-0
pom.xml
spring-boot-starters/spring-boot-starter-parent/pom.xml
+5
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
78ce06cc
...
@@ -136,6 +136,11 @@
...
@@ -136,6 +136,11 @@
<artifactId>
spring-data-mongodb
</artifactId>
<artifactId>
spring-data-mongodb
</artifactId>
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-couchbase
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
<artifactId>
spring-data-redis
</artifactId>
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/CouchbaseRepositoriesAutoConfiguration.java
0 → 100644
View file @
78ce06cc
/*
* Copyright 2012-2013 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
*
* http://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
.
boot
.
autoconfigure
.
data
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.Arrays
;
import
javax.annotation.PreDestroy
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.data.couchbase.core.CouchbaseTemplate
;
import
org.springframework.data.couchbase.repository.CouchbaseRepository
;
import
org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories
;
import
com.couchbase.client.CouchbaseClient
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Couchbase
* Repositories.
*
* @author Michael Nitschinger
* @see EnableCouchbaseRepositories
*/
@Configuration
@ConditionalOnClass
({
CouchbaseClient
.
class
,
CouchbaseRepository
.
class
})
public
class
CouchbaseRepositoriesAutoConfiguration
{
@Import
(
CouchbaseRepositoriesAutoConfigureRegistrar
.
class
)
@Configuration
@EnableConfigurationProperties
(
CouchbaseProperties
.
class
)
protected
static
class
CouchbaseRepositoriesConfiguration
{
@Autowired
private
CouchbaseProperties
config
;
@PreDestroy
public
void
close
()
throws
URISyntaxException
,
IOException
{
couchbaseClient
().
shutdown
();
}
@Bean
@ConditionalOnMissingBean
(
CouchbaseClient
.
class
)
CouchbaseClient
couchbaseClient
()
throws
URISyntaxException
,
IOException
{
return
this
.
config
.
couchbaseClient
();
}
@Bean
@ConditionalOnMissingBean
(
CouchbaseTemplate
.
class
)
CouchbaseTemplate
couchbaseTemplate
(
CouchbaseClient
couchbaseClient
)
{
return
new
CouchbaseTemplate
(
couchbaseClient
);
}
}
@ConfigurationProperties
(
prefix
=
"spring.data.couchbase"
)
public
static
class
CouchbaseProperties
{
private
String
host
=
"127.0.0.1"
;
private
String
bucket
=
"default"
;
private
String
password
=
""
;
public
CouchbaseClient
couchbaseClient
()
throws
URISyntaxException
,
IOException
{
return
new
CouchbaseClient
(
Arrays
.
asList
(
new
URI
(
"http://"
+
getHost
()
+
":8091/pools"
)),
getBucket
(),
getPassword
());
}
public
String
getHost
()
{
return
this
.
host
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
String
getBucket
()
{
return
this
.
bucket
;
}
public
void
setBucket
(
String
bucket
)
{
this
.
bucket
=
bucket
;
}
public
String
getPassword
()
{
return
this
.
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/CouchbaseRepositoriesAutoConfigureRegistrar.java
0 → 100644
View file @
78ce06cc
/*
* Copyright 2012-2013 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
*
* http://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
.
boot
.
autoconfigure
.
data
;
import
org.springframework.data.couchbase.repository.config.CouchbaseRepositoryConfigurationExtension
;
import
org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories
;
import
org.springframework.data.repository.config.RepositoryConfigurationExtension
;
import
java.lang.annotation.Annotation
;
import
org.springframework.context.annotation.ImportBeanDefinitionRegistrar
;
/**
* {@link ImportBeanDefinitionRegistrar} used to auto-configure Spring Data Couchbase
* Repositories.
*
* @author Michael Nitschinger
*/
class
CouchbaseRepositoriesAutoConfigureRegistrar
extends
AbstractRepositoryConfigurationSourceSupport
{
@Override
protected
Class
<?
extends
Annotation
>
getAnnotation
()
{
return
EnableCouchbaseRepositories
.
class
;
}
@Override
protected
Class
<?>
getConfiguration
()
{
return
EnableCouchbaseRepositoriesConfiguration
.
class
;
}
@Override
protected
RepositoryConfigurationExtension
getRepositoryConfigurationExtension
()
{
return
new
CouchbaseRepositoryConfigurationExtension
();
}
@EnableCouchbaseRepositories
private
static
class
EnableCouchbaseRepositoriesConfiguration
{
}
}
spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
78ce06cc
...
@@ -13,6 +13,7 @@ org.springframework.boot.autoconfigure.data.JpaRepositoriesAutoConfiguration,\
...
@@ -13,6 +13,7 @@ org.springframework.boot.autoconfigure.data.JpaRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.MongoRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.MongoRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.data.CouchbaseRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration,\
org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/CouchbaseRepositoriesAutoConfigurationTests.java
0 → 100644
View file @
78ce06cc
/*
* Copyright 2012-2013 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
*
* http://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
.
boot
.
autoconfigure
.
data
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.TestAutoConfigurationPackage
;
import
org.springframework.boot.autoconfigure.data.couchbase.City
;
import
org.springframework.boot.autoconfigure.data.couchbase.CityRepository
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.couchbase.client.CouchbaseClient
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
* Tests for {@link CouchbaseRepositoriesAutoConfiguration}.
*
* @author Michael Nitschinger
*/
public
class
CouchbaseRepositoriesAutoConfigurationTests
{
private
AnnotationConfigApplicationContext
context
;
@Test
public
void
testDefaultRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
CouchbaseRepositoriesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertNotNull
(
this
.
context
.
getBean
(
CityRepository
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
CouchbaseClient
.
class
));
}
@Test
public
void
testNoRepositoryConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
EmptyConfiguration
.
class
,
CouchbaseRepositoriesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertNotNull
(
this
.
context
.
getBean
(
CouchbaseClient
.
class
));
}
@Configuration
@TestAutoConfigurationPackage
(
City
.
class
)
protected
static
class
TestConfiguration
{
@Bean
public
CouchbaseClient
clientMock
()
{
return
mock
(
CouchbaseClient
.
class
);
}
}
@Configuration
@TestAutoConfigurationPackage
(
CouchbaseRepositoriesAutoConfigurationTests
.
class
)
protected
static
class
EmptyConfiguration
{
@Bean
public
CouchbaseClient
clientMock
()
{
return
mock
(
CouchbaseClient
.
class
);
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/City.java
0 → 100644
View file @
78ce06cc
/*
* Copyright 2012-2013 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
*
* http://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
.
boot
.
autoconfigure
.
data
.
couchbase
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.couchbase.core.mapping.Document
;
import
java.io.Serializable
;
/**
* @author Michael Nitschinger
*/
@Document
public
class
City
implements
Serializable
{
@Id
private
String
id
;
private
String
name
;
private
String
state
;
private
String
country
;
private
String
map
;
public
City
(
String
id
,
String
name
,
String
country
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
country
=
country
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
String
getCountry
()
{
return
country
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
String
getMap
()
{
return
map
;
}
public
void
setMap
(
String
map
)
{
this
.
map
=
map
;
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CityRepository.java
0 → 100644
View file @
78ce06cc
/*
* Copyright 2012-2013 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
*
* http://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
.
boot
.
autoconfigure
.
data
.
couchbase
;
import
org.springframework.data.couchbase.repository.CouchbaseRepository
;
/**
* @author Michael Nitschinger
*/
public
interface
CityRepository
extends
CouchbaseRepository
<
City
,
String
>
{
}
spring-boot-dependencies/pom.xml
View file @
78ce06cc
...
@@ -83,6 +83,7 @@
...
@@ -83,6 +83,7 @@
<spring.version>
4.0.3.RELEASE
</spring.version>
<spring.version>
4.0.3.RELEASE
</spring.version>
<spring-integration.version>
3.0.2.RELEASE
</spring-integration.version>
<spring-integration.version>
3.0.2.RELEASE
</spring-integration.version>
<spring-batch.version>
2.2.6.RELEASE
</spring-batch.version>
<spring-batch.version>
2.2.6.RELEASE
</spring-batch.version>
<spring-data-couchbase.version>
1.0.0.RELEASE
</spring-data-couchbase.version>
<spring-data-redis.version>
1.1.1.RELEASE
</spring-data-redis.version>
<spring-data-redis.version>
1.1.1.RELEASE
</spring-data-redis.version>
<spring-data-releasetrain.version>
Codd-SR2
</spring-data-releasetrain.version>
<spring-data-releasetrain.version>
Codd-SR2
</spring-data-releasetrain.version>
<spring-hateoas.version>
0.9.0.RELEASE
</spring-hateoas.version>
<spring-hateoas.version>
0.9.0.RELEASE
</spring-hateoas.version>
...
@@ -518,6 +519,11 @@
...
@@ -518,6 +519,11 @@
<type>
pom
</type>
<type>
pom
</type>
<scope>
import
</scope>
<scope>
import
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-couchbase
</artifactId>
<version>
${spring-data-couchbase.version}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
<artifactId>
spring-data-redis
</artifactId>
...
...
spring-boot-starters/pom.xml
View file @
78ce06cc
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
<module>
spring-boot-starter-amqp
</module>
<module>
spring-boot-starter-amqp
</module>
<module>
spring-boot-starter-aop
</module>
<module>
spring-boot-starter-aop
</module>
<module>
spring-boot-starter-batch
</module>
<module>
spring-boot-starter-batch
</module>
<module>
spring-boot-starter-data-couchbase
</module>
<module>
spring-boot-starter-data-jpa
</module>
<module>
spring-boot-starter-data-jpa
</module>
<module>
spring-boot-starter-data-mongodb
</module>
<module>
spring-boot-starter-data-mongodb
</module>
<module>
spring-boot-starter-integration
</module>
<module>
spring-boot-starter-integration
</module>
...
...
spring-boot-starters/spring-boot-starter-data-couchbase/.gitignore
0 → 100644
View file @
78ce06cc
/target
spring-boot-starters/spring-boot-starter-data-couchbase/pom.xml
0 → 100644
View file @
78ce06cc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starters
</artifactId>
<version>
0.5.0.BUILD-SNAPSHOT
</version>
</parent>
<artifactId>
spring-boot-starter-data-couchbase
</artifactId>
<packaging>
jar
</packaging>
<properties>
<main.basedir>
${basedir}/../..
</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-couchbase
</artifactId>
</dependency>
</dependencies>
</project>
spring-boot-starters/spring-boot-starter-parent/pom.xml
View file @
78ce06cc
...
@@ -86,6 +86,11 @@
...
@@ -86,6 +86,11 @@
<artifactId>
spring-boot-starter-data-rest
</artifactId>
<artifactId>
spring-boot-starter-data-rest
</artifactId>
<version>
${spring-boot.version}
</version>
<version>
${spring-boot.version}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-couchbase
</artifactId>
<version>
0.5.0.BUILD-SNAPSHOT
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-integration
</artifactId>
<artifactId>
spring-boot-starter-integration
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment