I ended up extending the DefaultMethodEndpointAdapter, creating SpecificEndpointAdapter. I only need to override one method, the implementation is as follows:
public class SpecificEndpointAdapter extends DefaultMethodEndpointAdapter {
private List<Object> acceptedEndpoints;
public void setAcceptedEndpoints(List<Object> acceptedEndpoints) {
this.acceptedEndpoints = acceptedEndpoints;
}
@Override
protected boolean supportsInternal(MethodEndpoint methodEndpoint) {
if(acceptedEndpoints.contains(methodEndpoint.getBean()))
return super.supportsInternal(methodEndpoint);
return false;
}
}
In my context file, this allows me to restrict an endpoint adapter to a specific endpoint, thus having a specific marshaller:
<bean id="serviceAEndpointAdapter" class="my.package.SpecificEndpointAdapter">
<property name="acceptedEndpoints">
<list>
<ref bean="serviceAEndpoint"/>
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="serviceA.marshallingPayloadMethodProcessor"/>
</list>
</property>
<property name="methodArgumentResolvers">
<list>
<ref bean="serviceA.marshallingPayloadMethodProcessor"/>
</list>
</property>
</bean>
<bean id="serviceBEndpointAdapter" class="my.package.SpecificEndpointAdapter">
<property name="acceptedEndpoints">
<list>
<ref bean="serviceBEndpoint"/>
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="serviceB.marshallingPayloadMethodProcessor"/>
</list>
</property>
<property name="methodArgumentResolvers">
<list>
<ref bean="serviceB.marshallingPayloadMethodProcessor"/>
</list>
</property>
</bean>
In my MarhsallingPayloadProcessor I can now declare which marshaller to use. Note that I ended up using the bean id as the SpecificEndpointAdapter reference, so if you are using annotations, you will need to figure out the bean id of that endpoint.
I hope this helps anyone who was facing the same issue, let me know if the answer requires more clarification.