From 513bc387e9166c7a2dbfd1f84b3f947808988582 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Fri, 27 Aug 2021 13:20:29 -0400 Subject: [PATCH] Remove essentially duplicate bean definition --- .../ca/uhn/fhir/jpa/batch/CommonBatchJobConfig.java | 7 +++++++ .../jpa/reindex/job/ReindexEverythingJobConfig.java | 10 +++------- .../ca/uhn/fhir/jpa/reindex/job/ReindexJobConfig.java | 10 +++------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/CommonBatchJobConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/CommonBatchJobConfig.java index dc0ec59b1ff..a681e7e6bbb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/CommonBatchJobConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch/CommonBatchJobConfig.java @@ -22,6 +22,7 @@ package ca.uhn.fhir.jpa.batch; import ca.uhn.fhir.jpa.batch.processor.GoldenResourceAnnotatingProcessor; import ca.uhn.fhir.jpa.batch.processor.PidToIBaseResourceProcessor; +import ca.uhn.fhir.jpa.reindex.job.ReindexWriter; import org.springframework.batch.core.configuration.annotation.StepScope; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -41,4 +42,10 @@ public class CommonBatchJobConfig { return new GoldenResourceAnnotatingProcessor(); } + @Bean + @StepScope + public ReindexWriter reindexWriter() { + return new ReindexWriter(); + } + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexEverythingJobConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexEverythingJobConfig.java index b0a0b77a642..ec66e2a3e0d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexEverythingJobConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexEverythingJobConfig.java @@ -49,6 +49,8 @@ public class ReindexEverythingJobConfig { private StepBuilderFactory myStepBuilderFactory; @Autowired private JobBuilderFactory myJobBuilderFactory; + @Autowired + private ReindexWriter myReindexWriter; @Bean(name = REINDEX_EVERYTHING_JOB_NAME) @Lazy @@ -63,7 +65,7 @@ public class ReindexEverythingJobConfig { return myStepBuilderFactory.get(REINDEX_EVERYTHING_STEP_NAME) ., List>chunk(1) .reader(cronologicalBatchAllResourcePidReader()) - .writer(reindexWriter()) + .writer(myReindexWriter) .listener(reindexEverythingPidCountRecorderListener()) .listener(reindexEverythingPromotionListener()) .build(); @@ -75,12 +77,6 @@ public class ReindexEverythingJobConfig { return new CronologicalBatchAllResourcePidReader(); } - @Bean - @StepScope - public ReindexWriter reindexWriter() { - return new ReindexWriter(); - } - @Bean @StepScope public PidReaderCounterListener reindexEverythingPidCountRecorderListener() { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexJobConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexJobConfig.java index 9b5bf617332..ee62e9a0d93 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexJobConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/job/ReindexJobConfig.java @@ -51,6 +51,8 @@ public class ReindexJobConfig extends MultiUrlProcessorJobConfig { private StepBuilderFactory myStepBuilderFactory; @Autowired private JobBuilderFactory myJobBuilderFactory; + @Autowired + private ReindexWriter myReindexWriter; @Bean(name = REINDEX_JOB_NAME) @Lazy @@ -66,18 +68,12 @@ public class ReindexJobConfig extends MultiUrlProcessorJobConfig { return myStepBuilderFactory.get(REINDEX_URL_LIST_STEP_NAME) ., List>chunk(1) .reader(reverseCronologicalBatchResourcePidReader()) - .writer(reindexWriter()) + .writer(myReindexWriter) .listener(pidCountRecorderListener()) .listener(reindexPromotionListener()) .build(); } - @Bean - @StepScope - public ReindexWriter reindexWriter() { - return new ReindexWriter(); - } - @Bean public ExecutionContextPromotionListener reindexPromotionListener() { ExecutionContextPromotionListener listener = new ExecutionContextPromotionListener();