DATAGEODE-198 - Simplify the RegionConfigurer interface.
Change the class type paramter to ClientRegionFactoryBean. Remove the configure(:String, :ConfigurableRegionFactoryBean) method, which is causing ambiguity in Java method resolution during runtime/invocations, even with strongly-typed FactoryBeans (e.g. ClientRegionFactoryBean). #argh
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.data.gemfire.ConfigurableRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.PeerRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.config.annotation.support.AbstractLazyResolvingComposableConfigurer;
|
||||
@@ -35,7 +34,7 @@ import org.springframework.lang.Nullable;
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public class LazyResolvingComposableRegionConfigurer
|
||||
extends AbstractLazyResolvingComposableConfigurer<ConfigurableRegionFactoryBean<?, ?>, RegionConfigurer>
|
||||
extends AbstractLazyResolvingComposableConfigurer<ClientRegionFactoryBean<?, ?>, RegionConfigurer>
|
||||
implements RegionConfigurer {
|
||||
|
||||
public static LazyResolvingComposableRegionConfigurer create() {
|
||||
@@ -51,11 +50,6 @@ public class LazyResolvingComposableRegionConfigurer
|
||||
return RegionConfigurer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(String beanName, ClientRegionFactoryBean<?, ?> bean) {
|
||||
resolveConfigurers().forEach(configurer -> configurer.configure(beanName, bean));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(String beanName, PeerRegionFactoryBean<?, ?> peerRegionFactoryBean) {
|
||||
resolveConfigurers().forEach(configurer -> configurer.configure(beanName, peerRegionFactoryBean));
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.gemfire.config.annotation;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.gemfire.ConfigurableRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.PeerRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.config.annotation.support.Configurer;
|
||||
@@ -38,27 +37,7 @@ import org.springframework.data.gemfire.config.annotation.support.Configurer;
|
||||
* @see org.springframework.data.gemfire.config.annotation.support.CacheTypeAwareRegionFactoryBean
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public interface RegionConfigurer extends Configurer<ConfigurableRegionFactoryBean<?, ?>> {
|
||||
|
||||
/**
|
||||
* Applies additional user-defined configuration to the {@link ConfigurableRegionFactoryBean}.
|
||||
*
|
||||
* @param beanName {@link String} containing the name of the Spring bean (component).
|
||||
* @param bean Spring component used to construct, configure and initialize the Apache Geode or Pivotal GemFire
|
||||
* @see org.springframework.data.gemfire.ConfigurableRegionFactoryBean
|
||||
* @see #configure(String, ClientRegionFactoryBean)
|
||||
* @see #configure(String, PeerRegionFactoryBean)
|
||||
*/
|
||||
@Override
|
||||
default void configure(String beanName, ConfigurableRegionFactoryBean<?, ?> bean) {
|
||||
|
||||
if (bean instanceof ClientRegionFactoryBean) {
|
||||
configure(beanName, (ClientRegionFactoryBean<?, ?>) bean);
|
||||
}
|
||||
else {
|
||||
configure(beanName, (PeerRegionFactoryBean<?, ?>) bean);
|
||||
}
|
||||
}
|
||||
public interface RegionConfigurer extends Configurer<ClientRegionFactoryBean<?, ?>> {
|
||||
|
||||
/**
|
||||
* Configuration callback method providing a reference to a {@link ClientRegionFactoryBean} used to construct,
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -76,7 +77,7 @@ public abstract class AbstractLazyResolvingComposableConfigurer<T, C extends Con
|
||||
* @return the primary {@link Class} type of the {@link Configurer} composed by this {@link Configurer}.
|
||||
* @see java.lang.Class
|
||||
*/
|
||||
protected abstract Class<C> getConfigurerType();
|
||||
protected abstract @NonNull Class<C> getConfigurerType();
|
||||
|
||||
/**
|
||||
* Resolves the {@link Configurer Configurers} defined, declared and registered in the Spring application context.
|
||||
@@ -86,7 +87,7 @@ public abstract class AbstractLazyResolvingComposableConfigurer<T, C extends Con
|
||||
* @see org.springframework.data.gemfire.config.annotation.support.Configurer
|
||||
* @see java.util.stream.Stream
|
||||
*/
|
||||
protected Stream<C> resolveConfigurers() {
|
||||
protected @NonNull Stream<C> resolveConfigurers() {
|
||||
|
||||
return Optional.ofNullable(this.configurers)
|
||||
.filter(it -> !it.isEmpty())
|
||||
@@ -134,7 +135,7 @@ public abstract class AbstractLazyResolvingComposableConfigurer<T, C extends Con
|
||||
* @see #setBeanFactory(BeanFactory)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S extends AbstractLazyResolvingComposableConfigurer<T, C>> S with(BeanFactory beanFactory) {
|
||||
public <S extends AbstractLazyResolvingComposableConfigurer<T, C>> S with(@Nullable BeanFactory beanFactory) {
|
||||
|
||||
setBeanFactory(beanFactory);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user