Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for AbstractAddressingEndpointMapping to filter SmartEndpointInterceptors #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public final EndpointInvocationChain getEndpoint(MessageContext messageContext)
if (endpoint == null) {
return null;
}
return getEndpointInvocationChain(endpoint, version, requestMap);
return getEndpointInvocationChain(endpoint, version, requestMap, messageContext);
}
}
return null;
Expand All @@ -278,22 +278,30 @@ public final EndpointInvocationChain getEndpoint(MessageContext messageContext)
*/
private EndpointInvocationChain getEndpointInvocationChain(Object endpoint,
AddressingVersion version,
MessageAddressingProperties requestMap) {
MessageAddressingProperties requestMap,
MessageContext messageContext) {
URI responseAction = getResponseAction(endpoint, requestMap);
URI faultAction = getFaultAction(endpoint, requestMap);

WebServiceMessageSender[] messageSenders = getMessageSenders(endpoint);
MessageIdStrategy messageIdStrategy = getMessageIdStrategy(endpoint);

List<EndpointInterceptor> interceptors = new ArrayList<EndpointInterceptor>(preInterceptors.length + postInterceptors.length + smartInterceptors.length + 1);
AddressingEndpointInterceptor addressingInterceptor = new AddressingEndpointInterceptor(version, messageIdStrategy,
messageSenders, responseAction, faultAction);

interceptors.addAll(Arrays.asList(preInterceptors));
interceptors.add(addressingInterceptor);
interceptors.addAll(Arrays.asList(postInterceptors));
interceptors.addAll(Arrays.asList(smartInterceptors));

List<EndpointInterceptor> interceptors = new ArrayList<EndpointInterceptor>();
interceptors.addAll(Arrays.asList(preInterceptors));

AddressingEndpointInterceptor addressingInterceptor = new AddressingEndpointInterceptor(version, messageIdStrategy,
messageSenders, responseAction, faultAction);
interceptors.add(addressingInterceptor);
interceptors.addAll(Arrays.asList(postInterceptors));

if (this.smartInterceptors != null) {
for (SmartEndpointInterceptor smartInterceptor : smartInterceptors) {
if (smartInterceptor.shouldIntercept(messageContext, endpoint)) {
interceptors.add(smartInterceptor);
}
}
}

return new SoapEndpointInvocationChain(endpoint,
interceptors.toArray(new EndpointInterceptor[interceptors.size()]), actorsOrRoles, isUltimateReceiver);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void setUp() throws Exception {
applicationContext = new StaticApplicationContext();
applicationContext.registerSingleton("mapping", AnnotationActionEndpointMapping.class);
applicationContext.registerSingleton("interceptor", MyInterceptor.class);
applicationContext.registerSingleton("smartIntercepter", MySmartInterceptor.class);
applicationContext.registerSingleton("endpoint", MyEndpoint.class);
applicationContext.refresh();
mapping = (AnnotationActionEndpointMapping) applicationContext.getBean("mapping");
Expand Down Expand Up @@ -104,4 +105,15 @@ public MyInterceptor() {
super(new PayloadLoggingInterceptor());
}
}

private static class MySmartInterceptor extends DelegatingSmartEndpointInterceptor {

public MySmartInterceptor() {
super(new PayloadLoggingInterceptor());
}

public boolean shouldIntercept(MessageContext messageContext, Object endpoint) {
return false;
}
}
}