Refactor framework infrastructure classes.

This commit is contained in:
John Blum
2021-04-15 13:33:13 -07:00
parent 1d1270f8a9
commit ba2e73e70c
3 changed files with 116 additions and 102 deletions

View File

@@ -54,6 +54,8 @@ import org.springframework.expression.EvaluationContext;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeConverter;
import org.springframework.expression.spel.support.StandardTypeLocator;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -76,8 +78,6 @@ import org.slf4j.LoggerFactory;
* @see org.springframework.beans.factory.support.AbstractBeanDefinition
* @see org.springframework.beans.factory.support.BeanDefinitionRegistry
* @see org.springframework.context.EnvironmentAware
* @see org.springframework.context.expression.BeanFactoryAccessor
* @see org.springframework.context.expression.EnvironmentAccessor
* @see org.springframework.core.annotation.AnnotationAttributes
* @see org.springframework.core.env.Environment
* @see org.springframework.core.type.AnnotationMetadata
@@ -113,7 +113,7 @@ public abstract class AbstractAnnotationConfigSupport
* @param value {@link Number} to evaluate.
* @return a boolean value indicating whether the given {@link Number} has value.
*/
protected static boolean hasValue(Number value) {
protected static boolean hasValue(@Nullable Number value) {
return Optional.ofNullable(value).filter(it -> it.doubleValue() != 0.0d).isPresent();
}
@@ -124,7 +124,7 @@ public abstract class AbstractAnnotationConfigSupport
* @param value {@link Object} to evaluate.
* @return a boolean value indicating whether the given {@link Object} has value.
*/
protected static boolean hasValue(Object value) {
protected static boolean hasValue(@Nullable Object value) {
return value != null;
}
@@ -135,7 +135,7 @@ public abstract class AbstractAnnotationConfigSupport
* @param value {@link String} to evaluate.
* @return a boolean value indicating whether the given {@link String} is valuable.
*/
protected static boolean hasValue(String value) {
protected static boolean hasValue(@Nullable String value) {
return StringUtils.hasText(value);
}
@@ -155,7 +155,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.beans.factory.BeanFactory
* @see #newEvaluationContext(BeanFactory)
*/
public AbstractAnnotationConfigSupport(BeanFactory beanFactory) {
public AbstractAnnotationConfigSupport(@Nullable BeanFactory beanFactory) {
this.evaluationContext = newEvaluationContext(beanFactory);
this.log = newLog();
@@ -170,7 +170,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.expression.EvaluationContext
* @see #getBeanFactory()
*/
protected EvaluationContext newEvaluationContext(BeanFactory beanFactory) {
protected EvaluationContext newEvaluationContext(@Nullable BeanFactory beanFactory) {
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
@@ -184,18 +184,19 @@ public abstract class AbstractAnnotationConfigSupport
return evaluationContext;
}
private void configureTypeConverter(EvaluationContext evaluationContext, BeanFactory beanFactory) {
private void configureTypeConverter(@Nullable EvaluationContext evaluationContext,
@Nullable BeanFactory beanFactory) {
Optional.ofNullable(evaluationContext)
.filter(evalContext -> evalContext instanceof StandardEvaluationContext)
.filter(StandardEvaluationContext.class::isInstance)
.map(StandardEvaluationContext.class::cast)
.ifPresent(evalContext ->
Optional.ofNullable(beanFactory)
.filter(it -> it instanceof ConfigurableBeanFactory)
.map(it -> ((ConfigurableBeanFactory) it).getConversionService())
.filter(ConfigurableBeanFactory.class::isInstance)
.map(ConfigurableBeanFactory.class::cast)
.map(ConfigurableBeanFactory::getConversionService)
.ifPresent(conversionService ->
((StandardEvaluationContext) evalContext).setTypeConverter(
new StandardTypeConverter(conversionService)))
);
evalContext.setTypeConverter(new StandardTypeConverter(conversionService))));
}
/**
@@ -220,7 +221,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see #getAnnotationTypeName()
* @see org.springframework.core.type.AnnotationMetadata
*/
protected boolean isAnnotationPresent(AnnotationMetadata importingClassMetadata) {
protected boolean isAnnotationPresent(@NonNull AnnotationMetadata importingClassMetadata) {
return isAnnotationPresent(importingClassMetadata, getAnnotationTypeName());
}
@@ -234,7 +235,9 @@ public abstract class AbstractAnnotationConfigSupport
* the given {@link Annotation} defined by {@link String name}.
* @see org.springframework.core.type.AnnotationMetadata
*/
protected boolean isAnnotationPresent(AnnotationMetadata importingClassMetadata, String annotationName) {
protected boolean isAnnotationPresent(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull String annotationName) {
return importingClassMetadata.hasAnnotation(annotationName);
}
@@ -246,7 +249,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.core.annotation.AnnotationAttributes
* @see java.lang.annotation.Annotation
*/
protected AnnotationAttributes getAnnotationAttributes(Annotation annotation) {
protected @NonNull AnnotationAttributes getAnnotationAttributes(@NonNull Annotation annotation) {
return AnnotationAttributes.fromMap(AnnotationUtils.getAnnotationAttributes(annotation));
}
@@ -260,7 +263,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see #getAnnotationAttributes(AnnotationMetadata, String)
* @see #getAnnotationTypeName()
*/
protected AnnotationAttributes getAnnotationAttributes(AnnotationMetadata importingClassMetadata) {
protected @NonNull AnnotationAttributes getAnnotationAttributes(@NonNull AnnotationMetadata importingClassMetadata) {
return getAnnotationAttributes(importingClassMetadata, getAnnotationTypeName());
}
@@ -274,8 +277,8 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.core.annotation.AnnotationAttributes
* @see org.springframework.core.type.AnnotationMetadata
*/
protected AnnotationAttributes getAnnotationAttributes(AnnotationMetadata importingClassMetadata,
String annotationName) {
protected @NonNull AnnotationAttributes getAnnotationAttributes(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull String annotationName) {
return AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(annotationName));
}
@@ -285,7 +288,7 @@ public abstract class AbstractAnnotationConfigSupport
*
* @return the cache application {@link java.lang.annotation.Annotation} type used by this application.
*/
protected abstract Class<? extends Annotation> getAnnotationType();
protected abstract @NonNull Class<? extends Annotation> getAnnotationType();
/**
* Returns the fully-qualified {@link Class#getName() class name} of the cache application
@@ -296,7 +299,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see java.lang.Class#getName()
* @see #getAnnotationType()
*/
protected String getAnnotationTypeName() {
protected @NonNull String getAnnotationTypeName() {
return getAnnotationType().getName();
}
@@ -309,7 +312,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see java.lang.Class#getSimpleName()
* @see #getAnnotationType()
*/
protected String getAnnotationTypeSimpleName() {
protected @NonNull String getAnnotationTypeSimpleName() {
return getAnnotationType().getSimpleName();
}
@@ -321,12 +324,13 @@ public abstract class AbstractAnnotationConfigSupport
* @return {@literal true} iff the {@link Object bean} is not a Spring container infrastructure bean.
* @see #isNotInfrastructureClass(String)
*/
protected boolean isNotInfrastructureBean(Object bean) {
protected boolean isNotInfrastructureBean(@Nullable Object bean) {
return Optional.ofNullable(bean)
.map(Object::getClass)
.map(Class::getName)
.filter(this::isNotInfrastructureClass).isPresent();
.filter(this::isNotInfrastructureClass)
.isPresent();
}
/**
@@ -340,8 +344,8 @@ public abstract class AbstractAnnotationConfigSupport
* @see #isNotInfrastructureClass(BeanDefinition)
* @see #isNotInfrastructureRole(BeanDefinition)
*/
protected boolean isNotInfrastructureBean(BeanDefinition beanDefinition) {
return (isNotInfrastructureRole(beanDefinition) && isNotInfrastructureClass(beanDefinition));
protected boolean isNotInfrastructureBean(@Nullable BeanDefinition beanDefinition) {
return isNotInfrastructureRole(beanDefinition) && isNotInfrastructureClass(beanDefinition);
}
/**
@@ -355,8 +359,11 @@ public abstract class AbstractAnnotationConfigSupport
* @see #resolveBeanClassName(BeanDefinition)
* @see #isNotInfrastructureClass(String)
*/
protected boolean isNotInfrastructureClass(BeanDefinition beanDefinition) {
return resolveBeanClassName(beanDefinition).filter(this::isNotInfrastructureClass).isPresent();
protected boolean isNotInfrastructureClass(@Nullable BeanDefinition beanDefinition) {
return resolveBeanClassName(beanDefinition)
.filter(this::isNotInfrastructureClass)
.isPresent();
}
/**
@@ -370,9 +377,9 @@ public abstract class AbstractAnnotationConfigSupport
* @return {@literal true} iff the given {@link Class#getName() class type name} is not considered a
* Spring container infrastructure type.
*/
protected boolean isNotInfrastructureClass(String className) {
return (className.startsWith(ORG_SPRINGFRAMEWORK_DATA_GEMFIRE_PACKAGE)
|| !className.startsWith(ORG_SPRINGFRAMEWORK_PACKAGE));
protected boolean isNotInfrastructureClass(@NonNull String className) {
return className.startsWith(ORG_SPRINGFRAMEWORK_DATA_GEMFIRE_PACKAGE)
|| !className.startsWith(ORG_SPRINGFRAMEWORK_PACKAGE);
}
/**
@@ -384,7 +391,7 @@ public abstract class AbstractAnnotationConfigSupport
* infrastructure bean.
* @see org.springframework.beans.factory.config.BeanDefinition
*/
protected boolean isNotInfrastructureRole(BeanDefinition beanDefinition) {
protected boolean isNotInfrastructureRole(@Nullable BeanDefinition beanDefinition) {
return Optional.ofNullable(beanDefinition)
.map(BeanDefinition::getRole)
@@ -403,7 +410,7 @@ public abstract class AbstractAnnotationConfigSupport
* @return a boolean value indicating whether the {@link Method} was declared/defined by the user.
* @see java.lang.reflect.Method
*/
protected boolean isUserLevelMethod(Method method) {
protected boolean isUserLevelMethod(@Nullable Method method) {
return Optional.ofNullable(method)
.filter(ClassUtils::isUserLevelMethod)
@@ -415,7 +422,7 @@ public abstract class AbstractAnnotationConfigSupport
* {@inheritDoc}
*/
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader;
}
@@ -426,7 +433,7 @@ public abstract class AbstractAnnotationConfigSupport
* @return the {@link ClassLoader} used by the Spring {@link BeanFactory} to load classes for bean definitions.
* @see #setBeanClassLoader(ClassLoader)
*/
protected ClassLoader getBeanClassLoader() {
protected @Nullable ClassLoader getBeanClassLoader() {
return this.beanClassLoader;
}
@@ -439,7 +446,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see java.lang.Thread#getContextClassLoader()
* @see #getBeanClassLoader()
*/
protected ClassLoader resolveBeanClassLoader() {
protected @NonNull ClassLoader resolveBeanClassLoader() {
return Optional.ofNullable(getBeanClassLoader())
.orElseGet(() -> Thread.currentThread().getContextClassLoader());
}
@@ -448,7 +455,7 @@ public abstract class AbstractAnnotationConfigSupport
* {@inheritDoc}
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(@Nullable BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
configureTypeConverter(getEvaluationContext(), beanFactory);
}
@@ -460,7 +467,7 @@ public abstract class AbstractAnnotationConfigSupport
* @throws IllegalStateException if the Spring {@link BeanFactory} was not properly configured.
* @see org.springframework.beans.factory.BeanFactory
*/
protected BeanFactory getBeanFactory() {
protected @NonNull BeanFactory getBeanFactory() {
return Optional.ofNullable(this.beanFactory)
.orElseThrow(() -> newIllegalStateException("BeanFactory is required"));
}
@@ -473,7 +480,7 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.core.env.Environment
*/
@Override
public void setEnvironment(Environment environment) {
public void setEnvironment(@Nullable Environment environment) {
this.environment = environment;
}
@@ -483,7 +490,7 @@ public abstract class AbstractAnnotationConfigSupport
* @return a reference to the Spring {@link Environment}.
* @see org.springframework.core.env.Environment
*/
protected Environment getEnvironment() {
protected @Nullable Environment getEnvironment() {
return this.environment;
}
@@ -493,7 +500,7 @@ public abstract class AbstractAnnotationConfigSupport
* @return a reference to the {@link EvaluationContext} used to evaluate SpEL expressions.
* @see org.springframework.expression.EvaluationContext
*/
protected EvaluationContext getEvaluationContext() {
protected @NonNull EvaluationContext getEvaluationContext() {
return this.evaluationContext;
}
@@ -503,7 +510,7 @@ public abstract class AbstractAnnotationConfigSupport
* @return a reference to the {@link Logger} used by this class to log {@link String messages}.
* @see org.apache.commons.logging.Log
*/
protected Logger getLog() {
protected @NonNull Logger getLog() {
return this.log;
}
@@ -603,7 +610,7 @@ public abstract class AbstractAnnotationConfigSupport
*/
protected void logError(Supplier<String> message) {
Optional.ofNullable(getLog())
.filter(Logger::isWarnEnabled)
.filter(Logger::isErrorEnabled)
.ifPresent(log -> log.info(message.get()));
}
@@ -618,13 +625,13 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.beans.factory.support.BeanDefinitionReaderUtils#registerWithGeneratedName(AbstractBeanDefinition, BeanDefinitionRegistry)
* @see #getBeanFactory()
*/
protected AbstractBeanDefinition register(AbstractBeanDefinition beanDefinition) {
protected @NonNull AbstractBeanDefinition register(@NonNull AbstractBeanDefinition beanDefinition) {
BeanFactory beanFactory = getBeanFactory();
return (beanFactory instanceof BeanDefinitionRegistry
return beanFactory instanceof BeanDefinitionRegistry
? register(beanDefinition, (BeanDefinitionRegistry) beanFactory)
: beanDefinition);
: beanDefinition;
}
/**
@@ -637,7 +644,8 @@ public abstract class AbstractAnnotationConfigSupport
* @see org.springframework.beans.factory.support.BeanDefinitionRegistry
* @see org.springframework.beans.factory.support.BeanDefinitionReaderUtils#registerWithGeneratedName(AbstractBeanDefinition, BeanDefinitionRegistry)
*/
protected AbstractBeanDefinition register(AbstractBeanDefinition beanDefinition, BeanDefinitionRegistry registry) {
protected @NonNull AbstractBeanDefinition register(@NonNull AbstractBeanDefinition beanDefinition,
@Nullable BeanDefinitionRegistry registry) {
Optional.ofNullable(registry).ifPresent(it ->
BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, it)
@@ -929,7 +937,7 @@ public abstract class AbstractAnnotationConfigSupport
* by the given {@link BeanDefinition}.
* @see org.springframework.beans.factory.config.BeanDefinition#getBeanClassName()
*/
protected Optional<String> resolveBeanClassName(BeanDefinition beanDefinition) {
protected Optional<String> resolveBeanClassName(@Nullable BeanDefinition beanDefinition) {
Optional<String> beanClassName = Optional.ofNullable(beanDefinition)
.map(BeanDefinition::getBeanClassName)
@@ -937,7 +945,7 @@ public abstract class AbstractAnnotationConfigSupport
if (!beanClassName.isPresent()) {
beanClassName = Optional.ofNullable(beanDefinition)
.filter(it -> it instanceof AnnotatedBeanDefinition)
.filter(AnnotatedBeanDefinition.class::isInstance)
.filter(it -> StringUtils.hasText(it.getFactoryMethodName()))
.map(it -> ((AnnotatedBeanDefinition) it).getFactoryMethodMetadata())
.map(MethodMetadata::getReturnTypeName);
@@ -1090,11 +1098,11 @@ public abstract class AbstractAnnotationConfigSupport
}
/**
* {@link TypeResolver} is a {@link FunctionalInterface} defining a contract to encapsulated the logic
* to resolve a particular {@link Class type}.
* {@link TypeResolver} is a {@link FunctionalInterface} defining a contract to encapsulate logic
* used to resolve a particular {@link Class type}.
*
* Implementations are free to decide on how a {@link Class type} gets resolved, such as
* with {@link Class#forName(String)} or perhaps using {@link ClassLoader#defineClass(String, byte[], int, int)}.
* with {@link Class#forName(String)} or perhaps by using {@link ClassLoader#defineClass(String, byte[], int, int)}.
*
* @param <T> {@link Class} of the type to resolve.
*/

View File

@@ -43,6 +43,8 @@ import org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer;
import org.springframework.data.gemfire.config.annotation.LocatorConfigurer;
import org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -87,15 +89,15 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
* @see org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration
*/
@SuppressWarnings("unchecked")
protected <T extends AbstractCacheConfiguration> T getCacheConfiguration() {
protected @NonNull <T extends AbstractCacheConfiguration> T getCacheConfiguration() {
return Optional.ofNullable((T) this.cacheConfiguration)
.orElseThrow(() -> newIllegalStateException("AbstractCacheConfiguration is required"));
}
@Override
public final void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
public final void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull BeanDefinitionRegistry registry) {
if (isAnnotationPresent(importingClassMetadata)) {
@@ -106,14 +108,19 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
}
}
@SuppressWarnings("unused")
protected void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
Map<String, Object> annotationAttributes, BeanDefinitionRegistry registry) {
protected void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull AnnotationAttributes annotationAttributes, @NonNull BeanDefinitionRegistry registry) {
registerBeanDefinitions(importingClassMetadata, (Map<String, Object>) annotationAttributes, registry);
}
protected void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull Map<String, Object> annotationAttributes, @NonNull BeanDefinitionRegistry registry) {
}
protected void setGemFireProperties(AnnotationMetadata importingClassMetadata,
AnnotationAttributes annotationAttributes, BeanDefinitionRegistry registry) {
protected void setGemFireProperties(@NonNull AnnotationMetadata importingClassMetadata,
@NonNull AnnotationAttributes annotationAttributes, @NonNull BeanDefinitionRegistry registry) {
Properties gemfireProperties = toGemFireProperties(annotationAttributes);
@@ -129,27 +136,28 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
}
}
protected abstract Properties toGemFireProperties(Map<String, Object> annotationAttributes);
protected abstract @Nullable Properties toGemFireProperties(@NonNull Map<String, Object> annotationAttributes);
protected boolean hasProperties(Properties properties) {
protected boolean hasProperties(@Nullable Properties properties) {
return !CollectionUtils.isEmpty(properties);
}
protected void registerGemFirePropertiesBeanPostProcessor(BeanDefinitionRegistry registry,
protected void registerGemFirePropertiesBeanPostProcessor(@NonNull BeanDefinitionRegistry registry,
Properties gemFireProperties) {
registerBeanDefinition(registry, GemFirePropertiesBeanPostProcessor.class, gemFireProperties);
}
protected void registerGemFirePropertiesConfigurer(BeanDefinitionRegistry registry, Properties gemfireProperties) {
protected void registerGemFirePropertiesConfigurer(@NonNull BeanDefinitionRegistry registry,
Properties gemfireProperties) {
registerClientGemFirePropertiesConfigurer(registry, gemfireProperties);
registerLocatorGemFirePropertiesConfigurer(registry, gemfireProperties);
registerPeerGemFirePropertiesConfigurer(registry, gemfireProperties);
}
private void registerBeanDefinition(BeanDefinitionRegistry registry, Class<?> beanType,
Properties gemfireProperties) {
private void registerBeanDefinition(@NonNull BeanDefinitionRegistry registry, @NonNull Class<?> beanType,
@NonNull Properties gemfireProperties) {
BeanDefinitionBuilder builder =
BeanDefinitionBuilder.genericBeanDefinition(beanType);
@@ -231,39 +239,34 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
}
}
protected String resolveHost(String hostname) {
protected @Nullable String resolveHost(@Nullable String hostname) {
return resolveHost(hostname, DEFAULT_HOST);
}
protected String resolveHost(String hostname, String defaultHostname) {
return Optional.ofNullable(hostname)
.filter(StringUtils::hasText)
.orElse(defaultHostname);
protected @Nullable String resolveHost(@Nullable String hostname, @Nullable String defaultHostname) {
return StringUtils.hasText(hostname) ? hostname : defaultHostname;
}
protected Integer resolvePort(Integer port) {
protected @Nullable Integer resolvePort(@Nullable Integer port) {
return resolvePort(port, DEFAULT_PORT);
}
protected Integer resolvePort(Integer port, Integer defaultPort) {
return Optional.ofNullable(port)
.orElse(defaultPort);
protected @Nullable Integer resolvePort(@Nullable Integer port, @Nullable Integer defaultPort) {
return port != null ? port : defaultPort;
}
protected static class AbstractGemFirePropertiesConfigurer {
private final Properties gemfireProperties;
protected AbstractGemFirePropertiesConfigurer(Properties gemfireProperties) {
protected AbstractGemFirePropertiesConfigurer(@NonNull Properties gemfireProperties) {
Assert.notEmpty(gemfireProperties, "GemFire Properties are required");
Assert.notEmpty(gemfireProperties, "GemFire Properties must not be null");
this.gemfireProperties = gemfireProperties;
}
protected void configureGemFireProperties(CacheFactoryBean bean) {
protected void configureGemFireProperties(@NonNull CacheFactoryBean bean) {
bean.getProperties().putAll(this.gemfireProperties);
}
}
@@ -271,12 +274,12 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
protected static class ClientGemFirePropertiesConfigurer extends AbstractGemFirePropertiesConfigurer
implements ClientCacheConfigurer {
protected ClientGemFirePropertiesConfigurer(Properties gemfireProperties) {
protected ClientGemFirePropertiesConfigurer(@NonNull Properties gemfireProperties) {
super(gemfireProperties);
}
@Override
public void configure(String beanName, ClientCacheFactoryBean bean) {
public void configure(@Nullable String beanName, @NonNull ClientCacheFactoryBean bean) {
configureGemFireProperties(bean);
}
}
@@ -285,15 +288,15 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
private final Properties gemfireProperties;
public LocatorGemFirePropertiesConfigurer(Properties gemfireProperties) {
public LocatorGemFirePropertiesConfigurer(@NonNull Properties gemfireProperties) {
Assert.notEmpty(gemfireProperties, "GemFire Properties are required");
Assert.notEmpty(gemfireProperties, "GemFire Properties must not be null");
this.gemfireProperties = gemfireProperties;
}
@Override
public void configure(String beanName, LocatorFactoryBean bean) {
public void configure(@Nullable String beanName, @NonNull LocatorFactoryBean bean) {
Properties gemfireProperties = bean.getGemFireProperties();
@@ -306,12 +309,12 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
protected static class PeerGemFirePropertiesConfigurer extends AbstractGemFirePropertiesConfigurer
implements PeerCacheConfigurer {
protected PeerGemFirePropertiesConfigurer(Properties gemfireProperties) {
protected PeerGemFirePropertiesConfigurer(@NonNull Properties gemfireProperties) {
super(gemfireProperties);
}
@Override
public void configure(String beanName, CacheFactoryBean bean) {
public void configure(@Nullable String beanName, @NonNull CacheFactoryBean bean) {
configureGemFireProperties(bean);
}
}
@@ -336,9 +339,9 @@ public abstract class EmbeddedServiceConfigurationSupport extends AbstractAnnota
* @throws IllegalArgumentException if {@link Properties} are {@literal null} or empty.
* @see java.util.Properties
*/
protected GemFirePropertiesBeanPostProcessor(Properties gemfireProperties) {
protected GemFirePropertiesBeanPostProcessor(@NonNull Properties gemfireProperties) {
Assert.notEmpty(gemfireProperties, "GemFire Properties are required");
Assert.notEmpty(gemfireProperties, "GemFire Properties must not be null");
this.gemfireProperties = gemfireProperties;
}

View File

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.lang.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +58,7 @@ public abstract class AbstractFactoryBeanSupport<T>
private String beanName;
/**
* Constructs a new instance of {@link AbstractFactoryBeanSupport} and initialized the logger.
* Constructs a new instance of {@link AbstractFactoryBeanSupport} initializing an object instance {@link Logger}.
*
* @see #newLog()
*/
@@ -77,25 +78,27 @@ public abstract class AbstractFactoryBeanSupport<T>
}
/**
* Sets a reference to the {@link ClassLoader} used by the Spring container to load and create bean classes.
* Sets a reference to the {@link ClassLoader} used by the Spring container to load bean {@link Class classes}.
*
* @param classLoader {@link ClassLoader} used by the Spring container to load and create bean classes.
* @param classLoader {@link ClassLoader} used by the Spring container to load bean {@link Class classes}.
* @see org.springframework.beans.factory.BeanClassLoaderAware#setBeanClassLoader(ClassLoader)
* @see java.lang.ClassLoader
* @see java.lang.Class
*/
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
/**
* Returns a reference to the {@link ClassLoader} used by the Spring container to load and create bean classes.
* Returns a reference to the {@link ClassLoader} used by the Spring container to load bean {@link Class classes}.
*
* @return the {@link ClassLoader} used by the Spring container to load and create bean classes.
* @return the {@link ClassLoader} used by the Spring container to load bean {@link Class classes}.
* @see org.springframework.beans.factory.BeanClassLoaderAware#setBeanClassLoader(ClassLoader)
* @see java.lang.ClassLoader
* @see java.lang.Class
*/
public ClassLoader getBeanClassLoader() {
public @Nullable ClassLoader getBeanClassLoader() {
return this.beanClassLoader;
}
@@ -107,7 +110,7 @@ public abstract class AbstractFactoryBeanSupport<T>
* @see org.springframework.beans.factory.BeanFactory
*/
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(@Nullable BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@@ -118,7 +121,7 @@ public abstract class AbstractFactoryBeanSupport<T>
* @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(BeanFactory)
* @see org.springframework.beans.factory.BeanFactory
*/
public BeanFactory getBeanFactory() {
public @Nullable BeanFactory getBeanFactory() {
return this.beanFactory;
}
@@ -130,7 +133,7 @@ public abstract class AbstractFactoryBeanSupport<T>
* @see java.lang.String
*/
@Override
public void setBeanName(String name) {
public void setBeanName(@Nullable String name) {
this.beanName = name;
}
@@ -141,7 +144,7 @@ public abstract class AbstractFactoryBeanSupport<T>
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(String)
* @see java.lang.String
*/
public String getBeanName() {
public @Nullable String getBeanName() {
return this.beanName;
}
@@ -151,7 +154,7 @@ public abstract class AbstractFactoryBeanSupport<T>
* @return a reference to the {@link Logger} used by this {@link FactoryBean} to log {@link String messages}.
* @see org.apache.commons.logging.Log
*/
protected Logger getLog() {
protected @Nullable Logger getLog() {
return this.log;
}