DATAGEODE-271 - Cannot enable the BeanFactoryLocator for a ClientCache instance using SDG property.

This commit is contained in:
John Blum
2019-11-11 19:55:13 -08:00
parent ad4a683afc
commit fb4b03d910
11 changed files with 297 additions and 62 deletions

View File

@@ -351,6 +351,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
gemfireCache.setProperties(gemfireProperties());
gemfireCache.setTransactionListeners(getTransactionListeners());
gemfireCache.setTransactionWriter(getTransactionWriter());
gemfireCache.setUseBeanFactoryLocator(useBeanFactoryLocator());
return gemfireCache;
}

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.config.annotation;
import org.springframework.beans.BeansException;
@@ -21,6 +20,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
import org.springframework.data.gemfire.support.GemfireBeanFactoryLocator;
/**
@@ -33,6 +33,9 @@ import org.springframework.data.gemfire.support.GemfireBeanFactoryLocator;
* @see org.springframework.context.annotation.Bean
* @see org.springframework.context.annotation.Configuration
* @see org.springframework.data.gemfire.CacheFactoryBean
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
* @see org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer
* @see org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer
* @see org.springframework.data.gemfire.config.annotation.EnableBeanFactoryLocator
* @see org.springframework.data.gemfire.support.GemfireBeanFactoryLocator
* @since 2.0.0
@@ -42,19 +45,19 @@ import org.springframework.data.gemfire.support.GemfireBeanFactoryLocator;
public class BeanFactoryLocatorConfiguration {
/**
* Declares and registers a Spring {@link BeanPostProcessor} and post processes a Spring Data GemFire/Geode
* {@link CacheFactoryBean} by setting the {@literal useBeanFactoryLocator} property to {@literal true}.
* Declares and registers a Spring {@link BeanPostProcessor} bean to post process a Spring Data Geode
* {@link CacheFactoryBean} or {@link ClientCacheFactoryBean} by setting the {@literal useBeanFactoryLocator}
* property to {@literal true}.
*
* @return a Spring {@link BeanPostProcessor} used to post process the SDG {@link CacheFactoryBean}.
* @return a Spring {@link BeanPostProcessor} used to post process an SDG {@link CacheFactoryBean}.
* @see org.springframework.beans.factory.config.BeanPostProcessor
*/
@Bean
public BeanPostProcessor cacheFactoryBeanPostProcessor() {
public BeanPostProcessor useBeanFactoryLocatorBeanPostProcessor() {
return new BeanPostProcessor() {
@Override
@SuppressWarnings("all")
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof CacheFactoryBean) {
@@ -65,4 +68,30 @@ public class BeanFactoryLocatorConfiguration {
}
};
}
/**
* Declares and registers a {@link ClientCacheConfigurer} bean to configure a {@link ClientCacheFactoryBean}
* by setting the {@literal useBeanFactoryLocator} property to {@literal true}.
*
* @return a {@link ClientCacheConfigurer} used to configure and set the SDG {@link ClientCacheFactoryBean}'s
* {@literal useBeanFactoryLocator} property to {@literal true}.
* @see org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer
*/
@Bean
public ClientCacheConfigurer useBeanFactoryLocatorClientCacheConfigurer() {
return (beanName, bean) -> bean.setUseBeanFactoryLocator(true);
}
/**
* Declares and registers a {@link PeerCacheConfigurer} bean to configure a {@link CacheFactoryBean}
* by setting the {@literal useBeanFactoryLocator} property to {@literal true}.
*
* @return a {@link PeerCacheConfigurer} used to configure and set the SDG {@link CacheFactoryBean}'s
* {@literal useBeanFactoryLocator} property to {@literal true}.
* @see org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer
*/
@Bean
public PeerCacheConfigurer useBeanFactoryLocatorPeerCacheConfigurer() {
return (beanName, bean) -> bean.setUseBeanFactoryLocator(true);
}
}

View File

@@ -14,7 +14,6 @@
* limitations under the License.
*
*/
package org.springframework.data.gemfire.config.annotation;
import java.lang.annotation.Documented;

View File

@@ -90,7 +90,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
gemfireCache.setMessageSyncInterval(messageSyncInterval());
gemfireCache.setPeerCacheConfigurers(resolvePeerCacheConfigurers());
gemfireCache.setSearchTimeout(searchTimeout());
gemfireCache.setUseBeanFactoryLocator(useBeanFactoryLocator());
gemfireCache.setUseClusterConfiguration(useClusterConfiguration());
return gemfireCache;

View File

@@ -105,7 +105,6 @@ public class CacheServerFactoryBean extends AbstractFactoryBeanSupport<CacheServ
* {@inheritDoc}
*/
@Override
@SuppressWarnings("deprecation")
public void afterPropertiesSet() throws IOException {
applyCacheServerConfigurers();