Skip to content

Commit 962cb6c

Browse files
committed
Add auto-configuration support for Spring Data Geode Repositories.
1 parent a94c6f8 commit 962cb6c

File tree

11 files changed

+710
-9
lines changed

11 files changed

+710
-9
lines changed

spring-boot-autoconfigure/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@
351351
</exclusion>
352352
</exclusions>
353353
</dependency>
354+
<dependency>
355+
<groupId>org.springframework.data</groupId>
356+
<artifactId>spring-data-geode</artifactId>
357+
<optional>true</optional>
358+
</dependency>
354359
<dependency>
355360
<groupId>org.springframework.data</groupId>
356361
<artifactId>spring-data-jpa</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.geode;
18+
19+
import com.gemstone.gemfire.cache.Cache;
20+
import com.gemstone.gemfire.cache.client.ClientCache;
21+
22+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
26+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
27+
import org.springframework.context.annotation.Configuration;
28+
import org.springframework.context.annotation.Import;
29+
import org.springframework.data.gemfire.repository.GemfireRepository;
30+
import org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension;
31+
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
32+
33+
/**
34+
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's Geode Repositories.
35+
* <p>
36+
* Activates when there is a bean of type {@link Cache} or {@link ClientCache} configured
37+
* in the Spring context, the Spring Data GemFire
38+
* {@link org.springframework.data.gemfire.repository.GemfireRepository}
39+
* type is on the classpath, and there is no other, existing
40+
* {@link org.springframework.data.gemfire.repository.GemfireRepository}
41+
* configured.
42+
* <p>
43+
* Once in effect, the auto-configuration is the equivalent of enabling Geode Repositories
44+
* using the
45+
* {@link org.springframework.data.gemfire.repository.config.EnableGemfireRepositories}
46+
* annotation.
47+
*
48+
* @author John Blum
49+
* @since 1.4.1
50+
* @see org.springframework.boot.autoconfigure.data.geode.GeodeRepositoriesAutoConfigureRegistrar
51+
* @see org.springframework.context.annotation.Configuration
52+
* @see org.springframework.data.gemfire.repository.config.EnableGemfireRepositories
53+
* @see com.gemstone.gemfire.cache.Cache
54+
* @see com.gemstone.gemfire.cache.client.ClientCache
55+
*/
56+
@Configuration
57+
@ConditionalOnBean({ Cache.class, ClientCache.class })
58+
@ConditionalOnClass(GemfireRepository.class)
59+
@ConditionalOnMissingBean({ GemfireRepositoryConfigurationExtension.class, GemfireRepositoryFactoryBean.class })
60+
@ConditionalOnProperty(prefix = "spring.data.geode.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
61+
@Import(GeodeRepositoriesAutoConfigureRegistrar.class)
62+
public class GeodeRepositoriesAutoConfiguration {
63+
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2011-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.geode;
18+
19+
import java.lang.annotation.Annotation;
20+
21+
import org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport;
22+
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
23+
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
24+
import org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension;
25+
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
26+
27+
/**
28+
* {@link ImportBeanDefinitionRegistrar} used to auto-configure Spring Data Geode Repositories.
29+
*
30+
* @author John Blum
31+
* @since 1.4.1
32+
* @see org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport
33+
* @see org.springframework.data.gemfire.repository.config.EnableGemfireRepositories
34+
* @see org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension
35+
*/
36+
public class GeodeRepositoriesAutoConfigureRegistrar
37+
extends AbstractRepositoryConfigurationSourceSupport {
38+
39+
@Override
40+
protected Class<? extends Annotation> getAnnotation() {
41+
return EnableGemfireRepositories.class;
42+
}
43+
44+
@Override
45+
protected Class<?> getConfiguration() {
46+
return EnableGeodeRepositoriesConfiguration.class;
47+
}
48+
49+
@Override
50+
protected RepositoryConfigurationExtension getRepositoryConfigurationExtension() {
51+
return new GemfireRepositoryConfigurationExtension();
52+
}
53+
54+
@EnableGemfireRepositories
55+
private static class EnableGeodeRepositoriesConfiguration {
56+
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2011-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Auto-configuration for Spring Data GemFire.
19+
*/
20+
package org.springframework.boot.autoconfigure.data.geode;

spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoC
2828
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,\
2929
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\
3030
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\
31+
org.springframework.boot.autoconfigure.data.geode.GeodeRepositoriesAutoConfiguration,\
3132
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
3233
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\
3334
org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.data.alt.geode;
18+
19+
import org.springframework.boot.autoconfigure.data.geode.city.City;
20+
import org.springframework.data.repository.Repository;
21+
22+
public interface CityGeodeRepository extends Repository<City, Long> {
23+
24+
}

0 commit comments

Comments
 (0)