From f8cbd27957d712b86073eb996a92ab5ba4588efb Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sat, 2 Nov 2019 22:45:13 -0400 Subject: [PATCH 1/4] Fix startup issue --- .../searchparam/extractor/SearchParamExtractorDstu3.java | 8 +++++--- .../searchparam/extractor/SearchParamExtractorR4.java | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java index 235596aae03..4f1d2bfee61 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java @@ -66,6 +66,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen @Override protected IValueExtractor getPathValueExtractor(IBaseResource theResource, String theSinglePath) { + start(null); return () -> { List values = new ArrayList<>(); List allValues = myFhirPathEngine.evaluate((Base) theResource, theSinglePath); @@ -80,10 +81,11 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen @EventListener public void start(ContextRefreshedEvent theEvent) { if (myValidationSupport == null) { - myValidationSupport = myApplicationContext.getBean(IValidationSupport.class); + IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); + IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); + myFhirPathEngine = new FHIRPathEngine(worker); + myValidationSupport = support; } - IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); - myFhirPathEngine = new FHIRPathEngine(worker); } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java index a54e3c24789..1a4d67b5a16 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java @@ -71,11 +71,12 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements @PostConstruct public void initFhirPath() { if (myValidationSupport == null) { - myValidationSupport = myApplicationContext.getBean(IValidationSupport.class); + IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); + IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); + myFhirPathEngine = new FHIRPathEngine(worker); + myFhirPathEngine.setHostServices(new SearchParamExtractorR4HostServices()); + myValidationSupport = support; } - IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); - myFhirPathEngine = new FHIRPathEngine(worker); - myFhirPathEngine.setHostServices(new SearchParamExtractorR4HostServices()); } From 49b8083e1591fe8fbd507e2413b7c13562d5e36a Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sat, 2 Nov 2019 22:47:11 -0400 Subject: [PATCH 2/4] One more startup attempt --- .../searchparam/extractor/SearchParamExtractorDstu3.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java index 4f1d2bfee61..3d3300c7fac 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java @@ -31,21 +31,15 @@ import org.hl7.fhir.dstu3.model.Base; import org.hl7.fhir.dstu3.utils.FHIRPathEngine; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; import java.util.ArrayList; import java.util.List; -import static org.apache.commons.lang3.StringUtils.trim; - public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implements ISearchParamExtractor { - @Autowired private org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport myValidationSupport; - - private HapiWorkerContext myWorkerContext; private FHIRPathEngine myFhirPathEngine; /** @@ -82,7 +76,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen public void start(ContextRefreshedEvent theEvent) { if (myValidationSupport == null) { IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); - IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); + IWorkerContext worker = new HapiWorkerContext(getContext(), support); myFhirPathEngine = new FHIRPathEngine(worker); myValidationSupport = support; } From b8837e810d26f00f774e652f0d5d5f0065201d72 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sat, 2 Nov 2019 23:17:02 -0400 Subject: [PATCH 3/4] One more startup fix --- .../fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java index 1a4d67b5a16..5c705b880b7 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java @@ -72,7 +72,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements public void initFhirPath() { if (myValidationSupport == null) { IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); - IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); + IWorkerContext worker = new HapiWorkerContext(getContext(), support); myFhirPathEngine = new FHIRPathEngine(worker); myFhirPathEngine.setHostServices(new SearchParamExtractorR4HostServices()); myValidationSupport = support; From ac51098cb3793e8b1cca9f85b35b94f644186a75 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sat, 2 Nov 2019 23:48:14 -0400 Subject: [PATCH 4/4] Version bump H2 --- .../extractor/SearchParamExtractorDstu3.java | 9 +++++---- .../extractor/SearchParamExtractorR4.java | 10 ++++++---- .../extractor/SearchParamExtractorR5.java | 16 +++++++++------- pom.xml | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java index 3d3300c7fac..7886b4f01ed 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java @@ -39,7 +39,6 @@ import java.util.List; public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implements ISearchParamExtractor { - private org.hl7.fhir.dstu3.hapi.ctx.IValidationSupport myValidationSupport; private FHIRPathEngine myFhirPathEngine; /** @@ -53,7 +52,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen @VisibleForTesting public SearchParamExtractorDstu3(ModelConfig theModelConfig, FhirContext theCtx, IValidationSupport theValidationSupport, ISearchParamRegistry theSearchParamRegistry) { super(theCtx, theSearchParamRegistry); - myValidationSupport = theValidationSupport; start(null); start(); } @@ -72,13 +70,16 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen }; } + + + + @EventListener public void start(ContextRefreshedEvent theEvent) { - if (myValidationSupport == null) { + if (myFhirPathEngine == null) { IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); IWorkerContext worker = new HapiWorkerContext(getContext(), support); myFhirPathEngine = new FHIRPathEngine(worker); - myValidationSupport = support; } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java index 5c705b880b7..3776b926700 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java @@ -41,7 +41,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements ISearchParamExtractor { - private IValidationSupport myValidationSupport; private FHIRPathEngine myFhirPathEngine; /** @@ -55,7 +54,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements @VisibleForTesting public SearchParamExtractorR4(ModelConfig theModelConfig, FhirContext theCtx, IValidationSupport theValidationSupport, ISearchParamRegistry theSearchParamRegistry) { super(theCtx, theSearchParamRegistry); - myValidationSupport = theValidationSupport; initFhirPath(); start(); } @@ -68,14 +66,18 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements }; } + + + + + @PostConstruct public void initFhirPath() { - if (myValidationSupport == null) { + if (myFhirPathEngine == null) { IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); IWorkerContext worker = new HapiWorkerContext(getContext(), support); myFhirPathEngine = new FHIRPathEngine(worker); myFhirPathEngine.setHostServices(new SearchParamExtractorR4HostServices()); - myValidationSupport = support; } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java index 6af6e523965..a30a5140786 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java @@ -26,8 +26,8 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.context.IWorkerContext; -import org.hl7.fhir.r5.hapi.ctx.DefaultProfileValidationSupport; import org.hl7.fhir.r5.hapi.ctx.HapiWorkerContext; +import org.hl7.fhir.r5.hapi.ctx.DefaultProfileValidationSupport; import org.hl7.fhir.r5.hapi.ctx.IValidationSupport; import org.hl7.fhir.r5.model.*; import org.hl7.fhir.r5.utils.FHIRPathEngine; @@ -57,16 +57,18 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements public SearchParamExtractorR5(FhirContext theCtx, DefaultProfileValidationSupport theDefaultProfileValidationSupport, ISearchParamRegistry theSearchParamRegistry) { super(theCtx, theSearchParamRegistry); myValidationSupport = theDefaultProfileValidationSupport; + initFhirPath(); start(); } - @Override @PostConstruct - public void start() { - super.start(); - IWorkerContext worker = new HapiWorkerContext(getContext(), myValidationSupport); - myFhirPathEngine = new FHIRPathEngine(worker); - myFhirPathEngine.setHostServices(new SearchParamExtractorR5HostServices()); + public void initFhirPath() { + if (myFhirPathEngine == null) { + IValidationSupport support = myApplicationContext.getBean(IValidationSupport.class); + IWorkerContext worker = new HapiWorkerContext(getContext(), support); + myFhirPathEngine = new FHIRPathEngine(worker); + myFhirPathEngine.setHostServices(new SearchParamExtractorR5HostServices()); + } } @Override diff --git a/pom.xml b/pom.xml index abbef3f58ca..e2efd915463 100755 --- a/pom.xml +++ b/pom.xml @@ -746,7 +746,7 @@ com.h2database h2 - 1.4.199 + 1.4.200 com.helger