DATAGEODE-121 - Do not allow eager init when getting beans by type to resolve Configurers for Annotation configuration.
This commit is contained in:
@@ -193,7 +193,7 @@ public class AddCacheServerConfiguration extends AbstractAnnotationConfigSupport
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
Map<String, CacheServerConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(CacheServerConfigurer.class, true, true);
|
||||
.getBeansOfType(CacheServerConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
})
|
||||
|
||||
@@ -198,7 +198,6 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
registry.registerBeanDefinition(poolName, poolFactoryBean.getBeanDefinition());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private List<PoolConfigurer> resolvePoolConfigurers() {
|
||||
|
||||
return Optional.ofNullable(this.poolConfigurers)
|
||||
@@ -208,7 +207,7 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
Map<String, PoolConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(PoolConfigurer.class, true, true);
|
||||
.getBeansOfType(PoolConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
})
|
||||
@@ -243,7 +242,6 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
return poolFactoryBean;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected BeanDefinitionBuilder configurePoolLocators(String poolName, Map<String, Object> enablePoolAttributes,
|
||||
BeanDefinitionBuilder poolFactoryBean) {
|
||||
|
||||
@@ -261,7 +259,6 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
return poolFactoryBean;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected BeanDefinitionBuilder configurePoolServers(String poolName, Map<String, Object> enablePoolAttributes,
|
||||
BeanDefinitionBuilder poolFactoryBean) {
|
||||
|
||||
@@ -279,7 +276,6 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
return poolFactoryBean;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected ConnectionEndpointList parseConnectionEndpoints(Map<String, Object> enablePoolAttributes,
|
||||
String arrayAttributeName, String stringAttributeName, int defaultPort) {
|
||||
|
||||
@@ -301,12 +297,10 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
return connectionEndpoints;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected ConnectionEndpoint newConnectionEndpoint(String host, Integer port) {
|
||||
return new ConnectionEndpoint(host, port);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
return EnablePool.class;
|
||||
|
||||
@@ -141,7 +141,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return gemfireCacheServer;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private List<CacheServerConfigurer> resolveCacheServerConfigurers() {
|
||||
|
||||
return Optional.ofNullable(this.cacheServerConfigurers)
|
||||
@@ -153,7 +152,7 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, CacheServerConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(CacheServerConfigurer.class, true, true);
|
||||
.getBeansOfType(CacheServerConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, ClientCacheConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(ClientCacheConfigurer.class, true, true);
|
||||
.getBeansOfType(ClientCacheConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ public class ContinuousQueryConfiguration extends AbstractAnnotationConfigSuppor
|
||||
|
||||
Map<String, ContinuousQueryListenerContainerConfigurer> beansOfType =
|
||||
((ListableBeanFactory) beanFactory).getBeansOfType(ContinuousQueryListenerContainerConfigurer.class,
|
||||
true, true);
|
||||
true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ public class DiskStoreConfiguration extends AbstractAnnotationConfigSupport
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, DiskStoreConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(DiskStoreConfigurer.class, true, true);
|
||||
.getBeansOfType(DiskStoreConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@ public class EntityDefinedRegionsConfiguration extends AbstractAnnotationConfigS
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, RegionConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(RegionConfigurer.class, true, true);
|
||||
.getBeansOfType(RegionConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -308,7 +308,7 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
Map<String, IndexConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(IndexConfigurer.class, true, true);
|
||||
.getBeansOfType(IndexConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
})
|
||||
|
||||
@@ -101,7 +101,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return gemfireCache;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private List<PeerCacheConfigurer> resolvePeerCacheConfigurers() {
|
||||
|
||||
return Optional.ofNullable(this.peerCacheConfigurers)
|
||||
@@ -113,7 +112,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
.map(beanFactory -> {
|
||||
|
||||
Map<String, PeerCacheConfigurer> beansOfType = ((ListableBeanFactory) beanFactory)
|
||||
.getBeansOfType(PeerCacheConfigurer.class, true, true);
|
||||
.getBeansOfType(PeerCacheConfigurer.class, true, false);
|
||||
|
||||
return nullSafeMap(beansOfType).values().stream().collect(Collectors.toList());
|
||||
|
||||
|
||||
@@ -74,23 +74,19 @@ public class ClientServerIntegrationTestsSupport {
|
||||
protected static final String SYSTEM_PROPERTIES_LOG_FILE = "system-properties.log";
|
||||
protected static final String TEST_GEMFIRE_LOG_LEVEL = "error";
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String asApplicationName(Class<?> type) {
|
||||
return type.getSimpleName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String asDirectoryName(Class<?> type) {
|
||||
return String.format("%1$s-%2$s", asApplicationName(type),
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-hh-mm-ss")));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static File createDirectory(String pathname) {
|
||||
return createDirectory(new File(pathname));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static File createDirectory(File directory) {
|
||||
|
||||
assertThat(directory.isDirectory() || directory.mkdirs())
|
||||
@@ -103,7 +99,6 @@ public class ClientServerIntegrationTestsSupport {
|
||||
return directory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int findAvailablePort() throws IOException {
|
||||
|
||||
ServerSocket serverSocket = null;
|
||||
@@ -117,110 +112,89 @@ public class ClientServerIntegrationTestsSupport {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getClassNameAsPath(Class type) {
|
||||
return type.getName().replaceAll("\\.", "/");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getClassNameAsPath(Object obj) {
|
||||
return getClassNameAsPath(obj.getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getPackageNameAsPath(Class type) {
|
||||
return type.getPackage().getName().replaceAll("\\.", "/");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getPackageNameAsPath(Object obj) {
|
||||
return getPackageNameAsPath(obj.getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getContextXmlFileLocation(Class type) {
|
||||
return getClassNameAsPath(type).concat("-context.xml");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getServerContextXmlFileLocation(Class type) {
|
||||
return getClassNameAsPath(type).concat("-server-context.xml");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isDeleteDirectoryOnExit() {
|
||||
return Boolean.valueOf(System.getProperty(DIRECTORY_DELETE_ON_EXIT_PROPERTY, Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int intValue(Number number) {
|
||||
return (number != null ? number.intValue() : 0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logFile() {
|
||||
return logFile(GEMFIRE_LOG_FILE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logFile(String defaultLogFilePathname) {
|
||||
return System.getProperty(GEMFIRE_LOG_FILE_PROPERTY, defaultLogFilePathname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logLevel() {
|
||||
return logLevel(GEMFIRE_LOG_LEVEL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logLevel(String defaultLogLevel) {
|
||||
return System.getProperty(GEMFIRE_LOG_LEVEL_PROPERTY, defaultLogLevel);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static void logSystemProperties() throws IOException {
|
||||
FileUtils.write(new File(SYSTEM_PROPERTIES_LOG_FILE),
|
||||
String.format("%s", CollectionUtils.toString(System.getProperties())));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(Class<?> type, String... arguments) throws IOException {
|
||||
return run(createDirectory(asDirectoryName(type)), type, arguments);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(File workingDirectory, Class<?> type, String... arguments) throws IOException {
|
||||
return (isProcessRunAuto() ? launch(createDirectory(workingDirectory), type, arguments) : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(String classpath, Class<?> type, String... arguments) throws IOException {
|
||||
return run(createDirectory(asDirectoryName(type)), classpath, type, arguments);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(File workingDirectory, String classpath, Class<?> type, String... arguments)
|
||||
throws IOException {
|
||||
|
||||
return (isProcessRunAuto() ? launch(createDirectory(workingDirectory), classpath, type, arguments) : null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isProcessRunAuto() {
|
||||
return !isProcessRunManual();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isProcessRunManual() {
|
||||
return Boolean.getBoolean(PROCESS_RUN_MANUAL_PROPERTY);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static AnnotationConfigApplicationContext runSpringApplication(Class<?> annotatedClass, String... args) {
|
||||
return runSpringApplication(asArray(annotatedClass), args);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static AnnotationConfigApplicationContext runSpringApplication(Class<?>[] annotatedClasses,
|
||||
String... args) {
|
||||
|
||||
@@ -232,12 +206,10 @@ public class ClientServerIntegrationTestsSupport {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean stop(ProcessWrapper process) {
|
||||
return stop(process, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean stop(ProcessWrapper process, long duration) {
|
||||
|
||||
return Optional.ofNullable(process)
|
||||
@@ -254,22 +226,18 @@ public class ClientServerIntegrationTestsSupport {
|
||||
.orElse(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer) {
|
||||
return waitForServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer, long duration) {
|
||||
return waitForServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), duration);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForServerToStart(String host, int port) {
|
||||
return waitForServerToStart(host, port, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForServerToStart(final String host, final int port, long duration) {
|
||||
|
||||
return ThreadUtils.timedWait(duration, DEFAULT_WAIT_INTERVAL, new ThreadUtils.WaitCondition() {
|
||||
@@ -313,13 +281,14 @@ public class ClientServerIntegrationTestsSupport {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException cause) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
return condition.evaluate();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface Condition {
|
||||
boolean evaluate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user