Polish.
This commit is contained in:
@@ -241,15 +241,6 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean value used to determine whether the cache will be closed on shutdown of the Spring application.
|
||||
*
|
||||
* @return a boolean value used to determine whether the cache will be closed on shutdown of the Spring application.
|
||||
*/
|
||||
public boolean isClose() {
|
||||
return this.close;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a boolean value used to determine whether the cache should be closed on shutdown of the Spring application.
|
||||
*
|
||||
@@ -260,6 +251,15 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean value used to determine whether the cache will be closed on shutdown of the Spring application.
|
||||
*
|
||||
* @return a boolean value used to determine whether the cache will be closed on shutdown of the Spring application.
|
||||
*/
|
||||
public boolean isClose() {
|
||||
return this.close;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link GemFireCache#getCopyOnRead()} property of the {@link GemFireCache cache}.
|
||||
*
|
||||
@@ -444,16 +444,6 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the {@link GemfireBeanFactoryLocator} has been enabled.
|
||||
*
|
||||
* @return a boolean value indicating whether the {@link GemfireBeanFactoryLocator} has been enabled.
|
||||
* @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
|
||||
*/
|
||||
public boolean isUseBeanFactoryLocator() {
|
||||
return this.useBeanFactoryLocator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a boolean value used to determine whether to enable the {@link GemfireBeanFactoryLocator}.
|
||||
*
|
||||
@@ -464,6 +454,16 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
this.useBeanFactoryLocator = use;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the {@link GemfireBeanFactoryLocator} has been enabled.
|
||||
*
|
||||
* @return a boolean value indicating whether the {@link GemfireBeanFactoryLocator} has been enabled.
|
||||
* @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
|
||||
*/
|
||||
public boolean isUseBeanFactoryLocator() {
|
||||
return this.useBeanFactoryLocator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this cache {@link FactoryBean} after all properties for this cache bean have been set
|
||||
* by the Spring container.
|
||||
@@ -540,16 +540,18 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
|
||||
Optional.ofNullable(getCriticalHeapPercentage()).ifPresent(criticalHeapPercentage -> {
|
||||
|
||||
Assert.isTrue(isHeapPercentageValid(criticalHeapPercentage), String.format(
|
||||
"criticalHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0", criticalHeapPercentage));
|
||||
Assert.isTrue(isHeapPercentageValid(criticalHeapPercentage),
|
||||
() -> String.format("criticalHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0",
|
||||
criticalHeapPercentage));
|
||||
|
||||
cache.getResourceManager().setCriticalHeapPercentage(criticalHeapPercentage);
|
||||
});
|
||||
|
||||
Optional.ofNullable(getEvictionHeapPercentage()).ifPresent(evictionHeapPercentage -> {
|
||||
|
||||
Assert.isTrue(isHeapPercentageValid(evictionHeapPercentage), String.format(
|
||||
"evictionHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0", evictionHeapPercentage));
|
||||
Assert.isTrue(isHeapPercentageValid(evictionHeapPercentage),
|
||||
() -> String.format("evictionHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0",
|
||||
evictionHeapPercentage));
|
||||
|
||||
cache.getResourceManager().setEvictionHeapPercentage(evictionHeapPercentage);
|
||||
});
|
||||
@@ -561,16 +563,18 @@ public abstract class AbstractBasicCacheFactoryBean extends AbstractFactoryBeanS
|
||||
|
||||
Optional.ofNullable(getCriticalOffHeapPercentage()).ifPresent(criticalOffHeapPercentage -> {
|
||||
|
||||
Assert.isTrue(isHeapPercentageValid(criticalOffHeapPercentage), String.format(
|
||||
"criticalOffHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0", criticalOffHeapPercentage));
|
||||
Assert.isTrue(isHeapPercentageValid(criticalOffHeapPercentage),
|
||||
() -> String.format("criticalOffHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0",
|
||||
criticalOffHeapPercentage));
|
||||
|
||||
cache.getResourceManager().setCriticalOffHeapPercentage(criticalOffHeapPercentage);
|
||||
});
|
||||
|
||||
Optional.ofNullable(getEvictionOffHeapPercentage()).ifPresent(evictionOffHeapPercentage -> {
|
||||
|
||||
Assert.isTrue(isHeapPercentageValid(evictionOffHeapPercentage), String.format(
|
||||
"evictionOffHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0", evictionOffHeapPercentage));
|
||||
Assert.isTrue(isHeapPercentageValid(evictionOffHeapPercentage),
|
||||
() -> String.format("evictionOffHeapPercentage [%s] is not valid; must be >= 0.0 and <= 100.0",
|
||||
evictionOffHeapPercentage));
|
||||
|
||||
cache.getResourceManager().setEvictionOffHeapPercentage(evictionOffHeapPercentage);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.gemfire;
|
||||
import static org.springframework.data.gemfire.GemfireUtils.apacheGeodeProductName;
|
||||
import static org.springframework.data.gemfire.GemfireUtils.apacheGeodeVersion;
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeCollection;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newRuntimeException;
|
||||
|
||||
@@ -297,7 +296,7 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
* @return the given {@link CacheFactory}.
|
||||
* @see org.apache.geode.cache.CacheFactory
|
||||
*/
|
||||
private @NonNull CacheFactory configureSecurity(@NonNull CacheFactory cacheFactory) {
|
||||
protected @NonNull CacheFactory configureSecurity(@NonNull CacheFactory cacheFactory) {
|
||||
|
||||
org.apache.geode.security.SecurityManager securityManager = getSecurityManager();
|
||||
|
||||
@@ -347,6 +346,7 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
* @see #registerTransactionListeners(org.apache.geode.cache.GemFireCache)
|
||||
* @see #registerTransactionWriter(org.apache.geode.cache.GemFireCache)
|
||||
*/
|
||||
// TODO: Refactor this garbage!
|
||||
protected @NonNull <T extends GemFireCache> T postProcess(@NonNull T cache) {
|
||||
|
||||
loadCacheXml(cache);
|
||||
@@ -354,11 +354,14 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
Optional.ofNullable(getCopyOnRead()).ifPresent(cache::setCopyOnRead);
|
||||
|
||||
if (cache instanceof Cache) {
|
||||
Optional.ofNullable(getGatewayConflictResolver()).ifPresent(((Cache) cache)::setGatewayConflictResolver);
|
||||
Optional.ofNullable(getLockLease()).ifPresent(((Cache) cache)::setLockLease);
|
||||
Optional.ofNullable(getLockTimeout()).ifPresent(((Cache) cache)::setLockTimeout);
|
||||
Optional.ofNullable(getMessageSyncInterval()).ifPresent(((Cache) cache)::setMessageSyncInterval);
|
||||
Optional.ofNullable(getSearchTimeout()).ifPresent(((Cache) cache)::setSearchTimeout);
|
||||
|
||||
Cache peerCache = (Cache) cache;
|
||||
|
||||
Optional.ofNullable(getGatewayConflictResolver()).ifPresent(peerCache::setGatewayConflictResolver);
|
||||
Optional.ofNullable(getLockLease()).ifPresent(peerCache::setLockLease);
|
||||
Optional.ofNullable(getLockTimeout()).ifPresent(peerCache::setLockTimeout);
|
||||
Optional.ofNullable(getMessageSyncInterval()).ifPresent(peerCache::setMessageSyncInterval);
|
||||
Optional.ofNullable(getSearchTimeout()).ifPresent(peerCache::setSearchTimeout);
|
||||
}
|
||||
|
||||
configureHeapPercentages(cache);
|
||||
@@ -372,7 +375,7 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
|
||||
private GemFireCache registerJndiDataSources(GemFireCache cache) {
|
||||
|
||||
nullSafeCollection(getJndiDataSources()).forEach(jndiDataSource -> {
|
||||
CollectionUtils.nullSafeCollection(getJndiDataSources()).forEach(jndiDataSource -> {
|
||||
|
||||
String type = jndiDataSource.getAttributes().get("type");
|
||||
|
||||
@@ -393,7 +396,7 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
|
||||
private GemFireCache registerTransactionListeners(GemFireCache cache) {
|
||||
|
||||
nullSafeCollection(getTransactionListeners())
|
||||
CollectionUtils.nullSafeCollection(getTransactionListeners())
|
||||
.forEach(transactionListener -> cache.getCacheTransactionManager().addListener(transactionListener));
|
||||
|
||||
return cache;
|
||||
@@ -401,7 +404,8 @@ public class CacheFactoryBean extends AbstractPdxConfigurableCacheFactoryBean {
|
||||
|
||||
private GemFireCache registerTransactionWriter(GemFireCache cache) {
|
||||
|
||||
Optional.ofNullable(getTransactionWriter()).ifPresent(it -> cache.getCacheTransactionManager().setWriter(it));
|
||||
Optional.ofNullable(getTransactionWriter())
|
||||
.ifPresent(transactionWriter -> cache.getCacheTransactionManager().setWriter(transactionWriter));
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class ConfigurableRegionFactoryBean<K, V> extends ResolvableRegi
|
||||
|
||||
private List<RegionConfigurer> regionConfigurers = Collections.emptyList();
|
||||
|
||||
private RegionConfigurer compositeRegionConfigurer = new RegionConfigurer() {
|
||||
private final RegionConfigurer compositeRegionConfigurer = new RegionConfigurer() {
|
||||
|
||||
@Override
|
||||
public void configure(String beanName, ClientRegionFactoryBean<?, ?> bean) {
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.gemfire;
|
||||
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeIterable;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -33,6 +32,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.data.gemfire.config.annotation.LocatorConfigurer;
|
||||
import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -62,12 +62,12 @@ public class LocatorFactoryBean extends AbstractFactoryBeanSupport<Locator> impl
|
||||
|
||||
private Integer port = DEFAULT_PORT;
|
||||
|
||||
private List<LocatorConfigurer> locatorConfigurers = new ArrayList<>();
|
||||
private final List<LocatorConfigurer> locatorConfigurers = new ArrayList<>();
|
||||
|
||||
private Locator locator;
|
||||
|
||||
private LocatorConfigurer compositeLocatorConfigurer = (beanName, bean) ->
|
||||
nullSafeList(this.locatorConfigurers).forEach(locatorConfigurer ->
|
||||
private final LocatorConfigurer compositeLocatorConfigurer = (beanName, bean) ->
|
||||
CollectionUtils.nullSafeList(this.locatorConfigurers).forEach(locatorConfigurer ->
|
||||
locatorConfigurer.configure(beanName, bean));
|
||||
|
||||
private LocatorLauncher locatorLauncher;
|
||||
|
||||
@@ -139,10 +139,10 @@ public abstract class PeerRegionFactoryBean<K, V> extends ConfigurableRegionFact
|
||||
private ExpirationAttributes regionIdleTimeout;
|
||||
private ExpirationAttributes regionTimeToLive;
|
||||
|
||||
private List<AsyncEventQueue> asyncEventQueues = new ArrayList<>();
|
||||
private List<GatewaySender> gatewaySenders = new ArrayList<>();
|
||||
private List<String> asyncEventQueueIds = new ArrayList<>();
|
||||
private List<String> gatewaySenderIds = new ArrayList<>();
|
||||
private final List<AsyncEventQueue> asyncEventQueues = new ArrayList<>();
|
||||
private final List<GatewaySender> gatewaySenders = new ArrayList<>();
|
||||
private final List<String> asyncEventQueueIds = new ArrayList<>();
|
||||
private final List<String> gatewaySenderIds = new ArrayList<>();
|
||||
|
||||
private RegionAttributes<K, V> attributes;
|
||||
|
||||
@@ -1173,7 +1173,6 @@ public abstract class PeerRegionFactoryBean<K, V> extends ConfigurableRegionFact
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void stop() {
|
||||
|
||||
if (!this.gatewaySenders.isEmpty()) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.apache.geode.cache.RegionAttributes;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
// TODO: Refactor RegionAttributesFactoryBean to no longer directly extend AttributesFactory
|
||||
public class RegionAttributesFactoryBean<K, V> extends AttributesFactory<K, V>
|
||||
implements FactoryBean<RegionAttributes<K, V>>, InitializingBean {
|
||||
|
||||
@@ -66,7 +68,7 @@ public class RegionAttributesFactoryBean<K, V> extends AttributesFactory<K, V>
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAsyncEventQueueIds(String[] asyncEventQueueIds) {
|
||||
public void setAsyncEventQueueIds(@NonNull String[] asyncEventQueueIds) {
|
||||
|
||||
Arrays.stream(ArrayUtils.nullSafeArray(asyncEventQueueIds, String.class))
|
||||
.filter(StringUtils::hasText)
|
||||
@@ -74,11 +76,11 @@ public class RegionAttributesFactoryBean<K, V> extends AttributesFactory<K, V>
|
||||
.forEach(this::addAsyncEventQueueId);
|
||||
}
|
||||
|
||||
public void setIndexUpdateType(IndexMaintenancePolicyType indexUpdateType) {
|
||||
public void setIndexUpdateType(@NonNull IndexMaintenancePolicyType indexUpdateType) {
|
||||
indexUpdateType.setIndexMaintenance(this);
|
||||
}
|
||||
|
||||
public void setGatewaySenderIds(String[] gatewaySenderIds) {
|
||||
public void setGatewaySenderIds(@NonNull String[] gatewaySenderIds) {
|
||||
|
||||
Arrays.stream(ArrayUtils.nullSafeArray(gatewaySenderIds, String.class))
|
||||
.filter(StringUtils::hasText)
|
||||
|
||||
@@ -198,7 +198,7 @@ public abstract class ResolvableRegionFactoryBean<K, V> extends AbstractFactoryB
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Class<?> getObjectType() {
|
||||
return Optional.ofNullable(getRegion()).map(Region::getClass).orElse((Class) Region.class);
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ import org.springframework.util.StringUtils;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
// TODO: Refactor this class to no longer extend CacheFactoryBean
|
||||
public class ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
protected static final PoolResolver DEFAULT_POOL_RESOLVER = new PoolManagerPoolResolver();
|
||||
|
||||
@@ -83,6 +83,7 @@ public class LocatorApplicationConfiguration extends AbstractAnnotationConfigSup
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@Autowired(required = false)
|
||||
private List<LocatorConfigurer> locatorConfigurers = Collections.emptyList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user