Fix bug in GemFireComponentClassTypeScanner caused by component class resolution.
We now supply the ClassLoader used to resolve GemFire/Geode entities to the Spring ClassPathScanningCandidateComponentProvider allowing entity classes to be resolved in all contexts (e.g. Spring Boot generated JARs). Additionally, SDG now provides configuration via a hidden property (spring.data.gemfire.classpath.scan.parallel) to tune the classpath scanning function (Stream). The default value for parallizing the Stream used during classpath scanning is now false. Closes #657
This commit is contained in:
@@ -33,6 +33,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -56,6 +57,9 @@ import org.slf4j.LoggerFactory;
|
||||
@SuppressWarnings("unused")
|
||||
public class GemFireComponentClassTypeScanner implements Iterable<String> {
|
||||
|
||||
protected static final String GEMFIRE_COMPONENT_CLASSPATH_SCAN_PARALLEL_PROPERTY =
|
||||
"spring.data.gemfire.classpath.scan.parallel";
|
||||
|
||||
/**
|
||||
* Factory method to construct an instance of the {@link GemFireComponentClassTypeScanner} initialized with
|
||||
* the given array of base packages to scan.
|
||||
@@ -208,7 +212,10 @@ public class GemFireComponentClassTypeScanner implements Iterable<String> {
|
||||
ClassPathScanningCandidateComponentProvider componentProvider =
|
||||
newClassPathScanningCandidateComponentProvider();
|
||||
|
||||
stream(this.spliterator(), true)
|
||||
boolean streamInParallel = getEnvironment()
|
||||
.getProperty(GEMFIRE_COMPONENT_CLASSPATH_SCAN_PARALLEL_PROPERTY, Boolean.class, Boolean.FALSE);
|
||||
|
||||
stream(this.spliterator(), streamInParallel)
|
||||
.flatMap(packageName -> componentProvider.findCandidateComponents(packageName).stream())
|
||||
.forEach(beanDefinition ->
|
||||
Optional.ofNullable(beanDefinition.getBeanClassName())
|
||||
@@ -258,6 +265,8 @@ public class GemFireComponentClassTypeScanner implements Iterable<String> {
|
||||
this.excludes.forEach(componentProvider::addExcludeFilter);
|
||||
this.includes.forEach(componentProvider::addIncludeFilter);
|
||||
|
||||
componentProvider.setResourceLoader(new DefaultResourceLoader(getEntityClassLoader()));
|
||||
|
||||
return componentProvider;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user