-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
The root cause of the issue was that I wanted to intercept the /$mdm-merge-golden-resources
operation and perform some custom operations after that. Therefore, I implemented an interceptor in the hapi-fhir-jpa-server. However, I found that the interceptor was not actually invoked. After in-depth debugging, I discovered that the RestfulServer
was constructed in the StarterJpaConfig
, and the specific code is as follows:
hapi-fhir-jpaserver-starter/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java
Line 338 in cf00333
RestfulServer fhirServer = new RestfulServer(fhirSystemDao.getContext()); |
The code inside the constructor of this RestfulServer is as follows:
the hapi-fhir link is:
https://github.com/hapifhir/hapi-fhir/blob/76163efbb8dee90a37d945c44b94e74fa12a775d/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java#L191-L198
the hapi-fhir code is:
public RestfulServer(FhirContext theCtx) {
this(theCtx, new InterceptorService());
}
You will find that the constructor creates a new InterceptorService
. In fact, this class has already been instantiated in Spring. Please refer to the specific code for details:
the hapi-fhir link is:
https://github.com/hapifhir/hapi-fhir/blob/76163efbb8dee90a37d945c44b94e74fa12a775d/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java#L518-L521
the hapi-fhir code is:
@Bean
public IInterceptorService jpaInterceptorService() {
return new InterceptorService();
}
And in other places, this InterceptorService
is injected as well.
Was there any consideration when constructing the RestfulServer without obtaining it from the Spring Beans?