|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -108,24 +108,21 @@ public class GenericMessageEndpointFactory extends AbstractMessageEndpointFactor |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object invoke(MethodInvocation methodInvocation) throws Throwable { |
|
|
|
public Object invoke(MethodInvocation methodInvocation) throws Throwable { |
|
|
|
|
|
|
|
Throwable endpointEx = null; |
|
|
|
boolean applyDeliveryCalls = !hasBeforeDeliveryBeenCalled(); |
|
|
|
boolean applyDeliveryCalls = !hasBeforeDeliveryBeenCalled(); |
|
|
|
if (applyDeliveryCalls) { |
|
|
|
if (applyDeliveryCalls) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
beforeDelivery(null); |
|
|
|
beforeDelivery(null); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
if (ReflectionUtils.declaresException(methodInvocation.getMethod(), ex.getClass())) { |
|
|
|
throw adaptExceptionIfNecessary(methodInvocation, ex); |
|
|
|
throw ex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
throw new InternalResourceException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
return methodInvocation.proceed(); |
|
|
|
return methodInvocation.proceed(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Throwable ex) { |
|
|
|
catch (Throwable ex) { |
|
|
|
|
|
|
|
endpointEx = ex; |
|
|
|
onEndpointException(ex); |
|
|
|
onEndpointException(ex); |
|
|
|
throw ex; |
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -135,17 +132,23 @@ public class GenericMessageEndpointFactory extends AbstractMessageEndpointFactor |
|
|
|
afterDelivery(); |
|
|
|
afterDelivery(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (ResourceException ex) { |
|
|
|
catch (ResourceException ex) { |
|
|
|
if (ReflectionUtils.declaresException(methodInvocation.getMethod(), ex.getClass())) { |
|
|
|
if (endpointEx == null) { |
|
|
|
throw ex; |
|
|
|
throw adaptExceptionIfNecessary(methodInvocation, ex); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
throw new InternalResourceException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Exception adaptExceptionIfNecessary(MethodInvocation methodInvocation, ResourceException ex) { |
|
|
|
|
|
|
|
if (ReflectionUtils.declaresException(methodInvocation.getMethod(), ex.getClass())) { |
|
|
|
|
|
|
|
return ex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return new InternalResourceException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected ClassLoader getEndpointClassLoader() { |
|
|
|
protected ClassLoader getEndpointClassLoader() { |
|
|
|
return getMessageListener().getClass().getClassLoader(); |
|
|
|
return getMessageListener().getClass().getClassLoader(); |
|
|
|
@ -164,7 +167,7 @@ public class GenericMessageEndpointFactory extends AbstractMessageEndpointFactor |
|
|
|
@SuppressWarnings("serial") |
|
|
|
@SuppressWarnings("serial") |
|
|
|
public static class InternalResourceException extends RuntimeException { |
|
|
|
public static class InternalResourceException extends RuntimeException { |
|
|
|
|
|
|
|
|
|
|
|
protected InternalResourceException(ResourceException cause) { |
|
|
|
public InternalResourceException(ResourceException cause) { |
|
|
|
super(cause); |
|
|
|
super(cause); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|