int count = interceptors == null ? 0 : interceptors.size();
if (count == 0)
return core;
InterceptorStackImpl stack = new InterceptorStackImpl(_log, _servicePoint, core);
// They are sorted into runtime execution order. Since we build from the
// core service impl outwarads, we have to reverse the runtime execution
// order to get the build order.
// That is, if user expects interceptors in order A B C (perhaps using
// the rules: A before B, C after B).
// Then that's the order for interceptors list: A B C
// To get that runtime execution order, we wrap C around the core,
// wrap B around C, and wrap A around B.
for (int i = count - 1; i >= 0; i--)
{
ServiceInterceptorContribution ic =
(ServiceInterceptorContribution) interceptors.get(i);
stack.process(ic);
}
// Whatever's on top is the final service.
return stack.peek();
}