SGF-708 - Enable the spring.data.gemfire.name property to be used in addition to spring.data.gemfire.cache.name for naming members of the cluster.
This commit is contained in:
@@ -274,8 +274,9 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
setLogLevel(resolveProperty(cacheProperty("log-level"),
|
||||
(String) cacheMetadataAttributes.get("logLevel")));
|
||||
|
||||
setName(resolveProperty(cacheProperty("name"),
|
||||
(String) cacheMetadataAttributes.get("name")));
|
||||
setName(resolveProperty(propertyName("name"),
|
||||
resolveProperty(cacheProperty("name"),
|
||||
(String) cacheMetadataAttributes.get("name"))));
|
||||
|
||||
setUseBeanFactoryLocator(resolveProperty(propertyName("use-bean-factory-locator"),
|
||||
Boolean.TRUE.equals(cacheMetadataAttributes.get("useBeanFactoryLocator"))));
|
||||
@@ -473,7 +474,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
|
||||
*/
|
||||
protected abstract Class getAnnotationType();
|
||||
protected abstract Class<? extends Annotation> getAnnotationType();
|
||||
|
||||
/**
|
||||
* Returns the fully-qualified {@link Class#getName() class name} of the cache application
|
||||
|
||||
@@ -235,7 +235,8 @@ public @interface CacheServerApplication {
|
||||
*
|
||||
* Defaults to {@literal SpringBasedCacheServerApplication}.
|
||||
*
|
||||
* Use {@literal spring.data.gemfire.cache.name} property in {@literal application.properties}.
|
||||
* Use either the {@literal spring.data.gemfire.name} or the {@literal spring.data.gemfire.cache.name} property
|
||||
* in {@literal application.properties}.
|
||||
*/
|
||||
String name() default CacheServerConfiguration.DEFAULT_NAME;
|
||||
|
||||
|
||||
@@ -195,7 +195,8 @@ public @interface ClientCacheApplication {
|
||||
*
|
||||
* Defaults to {@literal SpringBasedCacheClientApplication}.
|
||||
*
|
||||
* Use {@literal spring.data.gemfire.cache.name} property in {@literal application.properties}.
|
||||
* Use either the {@literal spring.data.gemfire.name} or the {@literal spring.data.gemfire.cache.name} property
|
||||
* in {@literal application.properties}.
|
||||
*/
|
||||
String name() default ClientCacheConfiguration.DEFAULT_NAME;
|
||||
|
||||
|
||||
@@ -142,7 +142,8 @@ public @interface PeerCacheApplication {
|
||||
*
|
||||
* Defaults to {@literal SpringBasedPeerCacheApplication}.
|
||||
*
|
||||
* Use {@literal spring.data.gemfire.cache.name} property in {@literal application.properties}.
|
||||
* Use either the {@literal spring.data.gemfire.name} or the {@literal spring.data.gemfire.cache.name} property
|
||||
* in {@literal application.properties}.
|
||||
*/
|
||||
String name() default PeerCacheConfiguration.DEFAULT_NAME;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -100,10 +101,12 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
Optional.of(this.getBeanFactory())
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, PeerCacheConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(PeerCacheConfigurer.class, true, true);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
})
|
||||
.orElseGet(Collections::emptyList)
|
||||
);
|
||||
@@ -140,31 +143,34 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
Map<String, Object> peerCacheApplicationAttributes =
|
||||
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
|
||||
|
||||
setEnableAutoReconnect(resolveProperty(cachePeerProperty("enable-auto-reconnect"),
|
||||
Boolean.TRUE.equals(peerCacheApplicationAttributes.get("enableAutoReconnect"))));
|
||||
if (peerCacheApplicationAttributes != null) {
|
||||
|
||||
setLockLease(resolveProperty(cachePeerProperty("lock-lease"),
|
||||
(Integer) peerCacheApplicationAttributes.get("lockLease")));
|
||||
setEnableAutoReconnect(resolveProperty(cachePeerProperty("enable-auto-reconnect"),
|
||||
Boolean.TRUE.equals(peerCacheApplicationAttributes.get("enableAutoReconnect"))));
|
||||
|
||||
setLockTimeout(resolveProperty(cachePeerProperty("lock-timeout"),
|
||||
(Integer) peerCacheApplicationAttributes.get("lockTimeout")));
|
||||
setLockLease(resolveProperty(cachePeerProperty("lock-lease"),
|
||||
(Integer) peerCacheApplicationAttributes.get("lockLease")));
|
||||
|
||||
setMessageSyncInterval(resolveProperty(cachePeerProperty("message-sync-interval"),
|
||||
(Integer) peerCacheApplicationAttributes.get("messageSyncInterval")));
|
||||
setLockTimeout(resolveProperty(cachePeerProperty("lock-timeout"),
|
||||
(Integer) peerCacheApplicationAttributes.get("lockTimeout")));
|
||||
|
||||
setSearchTimeout(resolveProperty(cachePeerProperty("search-timeout"),
|
||||
(Integer) peerCacheApplicationAttributes.get("searchTimeout")));
|
||||
setMessageSyncInterval(resolveProperty(cachePeerProperty("message-sync-interval"),
|
||||
(Integer) peerCacheApplicationAttributes.get("messageSyncInterval")));
|
||||
|
||||
setUseClusterConfiguration(resolveProperty(cachePeerProperty("use-cluster-configuration"),
|
||||
Boolean.TRUE.equals(peerCacheApplicationAttributes.get("useClusterConfiguration"))));
|
||||
setSearchTimeout(resolveProperty(cachePeerProperty("search-timeout"),
|
||||
(Integer) peerCacheApplicationAttributes.get("searchTimeout")));
|
||||
|
||||
Optional.ofNullable((String) peerCacheApplicationAttributes.get("locators"))
|
||||
.filter(PeerCacheConfiguration::hasValue)
|
||||
.ifPresent(this::setLocators);
|
||||
setUseClusterConfiguration(resolveProperty(cachePeerProperty("use-cluster-configuration"),
|
||||
Boolean.TRUE.equals(peerCacheApplicationAttributes.get("useClusterConfiguration"))));
|
||||
|
||||
Optional.ofNullable(resolveProperty(cachePeerProperty("locators"), (String) null))
|
||||
.filter(StringUtils::hasText)
|
||||
.ifPresent(this::setLocators);
|
||||
Optional.ofNullable((String) peerCacheApplicationAttributes.get("locators"))
|
||||
.filter(PeerCacheConfiguration::hasValue)
|
||||
.ifPresent(this::setLocators);
|
||||
|
||||
Optional.ofNullable(resolveProperty(cachePeerProperty("locators"), (String) null))
|
||||
.filter(StringUtils::hasText)
|
||||
.ifPresent(this::setLocators);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +178,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
protected Class<? extends Annotation> getAnnotationType() {
|
||||
return PeerCacheApplication.class;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user