Merge branch 'master' into windows-fixes

This commit is contained in:
Ken Stevens 2019-01-21 11:06:42 -05:00
commit 29f483d7b4
6 changed files with 39 additions and 12 deletions

View File

@ -92,6 +92,11 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>

View File

@ -0,0 +1,25 @@
package example.interceptor;
import ca.uhn.fhir.jpa.model.interceptor.api.Hook;
import ca.uhn.fhir.jpa.model.interceptor.api.Interceptor;
import ca.uhn.fhir.jpa.model.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage;
/**
* Interceptor class
*/
@Interceptor
public class MyTestInterceptor {
@Hook(Pointcut.SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY)
public boolean beforeRestHookDelivery(ResourceDeliveryMessage theDeliveryMessage, CanonicalSubscription theSubscription) {
String header = "Authorization: Bearer 1234567";
theSubscription.addHeader(header);
return true;
}
}

View File

@ -26,7 +26,6 @@ import static org.junit.Assert.*;
@ContextConfiguration(classes = {InterceptorRegistryTest.InterceptorRegistryTestCtxConfig.class}) @ContextConfiguration(classes = {InterceptorRegistryTest.InterceptorRegistryTestCtxConfig.class})
public class InterceptorRegistryTest { public class InterceptorRegistryTest {
private static boolean ourNext_beforeRestHookDelivery_Return2;
private static boolean ourNext_beforeRestHookDelivery_Return1; private static boolean ourNext_beforeRestHookDelivery_Return1;
private static List<String> ourInvocations = new ArrayList<>(); private static List<String> ourInvocations = new ArrayList<>();
private static CanonicalSubscription ourLastCanonicalSubscription; private static CanonicalSubscription ourLastCanonicalSubscription;
@ -88,7 +87,6 @@ public class InterceptorRegistryTest {
@Before @Before
public void before() { public void before() {
ourNext_beforeRestHookDelivery_Return1 = true; ourNext_beforeRestHookDelivery_Return1 = true;
ourNext_beforeRestHookDelivery_Return2 = true;
ourLastCanonicalSubscription = null; ourLastCanonicalSubscription = null;
ourLastResourceDeliveryMessage0 = null; ourLastResourceDeliveryMessage0 = null;
ourLastResourceDeliveryMessage1 = null; ourLastResourceDeliveryMessage1 = null;
@ -140,11 +138,10 @@ public class InterceptorRegistryTest {
@Order(200) @Order(200)
public static class MyTestInterceptorTwo { public static class MyTestInterceptorTwo {
@Hook(Pointcut.SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY) @Hook(Pointcut.SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY)
public boolean beforeRestHookDelivery(ResourceDeliveryMessage theResourceDeliveryMessage0, ResourceDeliveryMessage theResourceDeliveryMessage1) { public void beforeRestHookDelivery(ResourceDeliveryMessage theResourceDeliveryMessage0, ResourceDeliveryMessage theResourceDeliveryMessage1) {
ourLastResourceDeliveryMessage0 = theResourceDeliveryMessage0; ourLastResourceDeliveryMessage0 = theResourceDeliveryMessage0;
ourLastResourceDeliveryMessage1 = theResourceDeliveryMessage1; ourLastResourceDeliveryMessage1 = theResourceDeliveryMessage1;
ourInvocations.add("MyTestInterceptorTwo.beforeRestHookDelivery"); ourInvocations.add("MyTestInterceptorTwo.beforeRestHookDelivery");
return ourNext_beforeRestHookDelivery_Return2;
} }
} }

View File

@ -254,10 +254,10 @@ public class InterceptorRegistry implements IInterceptorRegistry, ApplicationCon
myMethod = theHookMethod; myMethod = theHookMethod;
Class<?> returnType = theHookMethod.getReturnType(); Class<?> returnType = theHookMethod.getReturnType();
if (returnType.equals(boolean.class) || returnType.equals(Boolean.class)) { if (returnType.equals(boolean.class)) {
myReturnsBoolean = true; myReturnsBoolean = true;
} else { } else {
Validate.isTrue(Void.class.equals(returnType), "Method does not return boolean or void: %s", theHookMethod); Validate.isTrue(void.class.equals(returnType), "Method does not return boolean or void: %s", theHookMethod);
myReturnsBoolean = false; myReturnsBoolean = false;
} }