SDAP-62 Fix No bean named 'pythonChainProcessor' available bug (#7)
authorfgreg <fgreguska+github@gmail.com>
Wed, 18 Apr 2018 16:57:55 +0000 (09:57 -0700)
committerGitHub <noreply@github.com>
Wed, 18 Apr 2018 16:57:55 +0000 (09:57 -0700)
Use the same `@ConditionalOnProperty` for processors in both `AppConfig` and `BatchConfig`

src/main/java/org/apache/sdap/ningester/configuration/AppConfig.java
src/main/java/org/apache/sdap/ningester/configuration/BatchConfig.java

index b4017e9..82eff4e 100644 (file)
@@ -34,7 +34,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.annotation.Order;
 import org.springframework.http.MediaType;
 import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.web.client.RestTemplate;
@@ -44,7 +43,6 @@ import java.util.Collections;
 import java.util.List;
 
 @Configuration
-@Order(1)
 @EnableConfigurationProperties({ApplicationProperties.class})
 public class AppConfig {
 
index 7b5249e..cc0b709 100644 (file)
@@ -34,17 +34,15 @@ import org.springframework.batch.item.ItemWriter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
-import org.springframework.core.annotation.Order;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
 
 @Configuration
-@Order(2)
 @EnableBatchProcessing
 @Import(AppConfig.class)
 public class BatchConfig {
@@ -108,31 +106,31 @@ public class BatchConfig {
      * Item Processor beans defined below
      */
     @Bean
-    @ConditionalOnBean(AddDatasetName.class)
+    @ConditionalOnProperty(prefix = "ningester.addDatasetName", name = "enabled")
     protected ItemProcessor<NexusTile, NexusTile> addDatasetName(AddDatasetName addDatasetNameBean) {
         return addDatasetNameBean::addDatasetName;
     }
 
     @Bean
-    @ConditionalOnBean(AddDayOfYearAttribute.class)
+    @ConditionalOnProperty(prefix = "ningester.addDayOfYearAttribute", name = "enabled")
     protected ItemProcessor<NexusTile, NexusTile> addDayOfYearAttribute(AddDayOfYearAttribute addDayOfYearAttributeBean) {
         return addDayOfYearAttributeBean::setDayOfYearFromGranuleName;
     }
 
     @Bean
-    @ConditionalOnBean(AddTimeFromGranuleName.class)
+    @ConditionalOnProperty(prefix = "ningester.addTimeFromGranuleName", name = "enabled")
     protected ItemProcessor<NexusTile, NexusTile> addTimeFromGranuleName(AddTimeFromGranuleName addTimeFromGranuleNameBean) {
         return addTimeFromGranuleNameBean::setTimeFromGranuleName;
     }
 
     @Bean
-    @ConditionalOnBean(GenerateTileId.class)
+    @ConditionalOnProperty(prefix = "ningester.generateTileId", name = "enabled")
     protected ItemProcessor<NexusTile, NexusTile> generateTileId(GenerateTileId generateTileIdBean) {
         return generateTileIdBean::addTileId;
     }
 
     @Bean
-    @ConditionalOnBean(PythonChainProcessor.class)
+    @ConditionalOnProperty(prefix = "ningester.pythonChainProcessor", name = "enabled")
     protected ItemProcessor<NexusTile, NexusTile> pythonChainProcessor(PythonChainProcessor pythonChainProcessorBean) {
         return pythonChainProcessorBean::nexusTileProcessor;
     }