Quilleash, Michael (IT) wrote:
> I would need to have:
>
> In Interceptor - start timing
> Out/InFault/OutFault interceptors - stop timing
>
> To catch all the possible code paths. Is there any easier way of
> doing this?
A trick used in a number of CXF built-in interceptors is to have a main
interceptor which is added to the chain explicitly, but then have that
interceptor add others to the relevant chains for that exchange during
its handleMessage. For example (pseudo-code):
class TimingInterceptor {
private Interceptor stopTiming = new StopTimingInterceptor();
handleMessage(Message m) {
Exchange ex = m.getExchange();
ex.put("startTime", System.currentTimeMillis());
ex.getOutMessage().getInterceptorChain().add(stopTiming);
ex.getOutFaultMessage().getInterceptorChain().add(stopTiming);
}
static class StopTimingInterceptor {
handleMessage(Message m) {
Exchange ex = m.getExchange();
long startTime = ex.get("startTime");
// ...
}
}
}
You only need to add the TimingInterceptor to your input chain and it
will manage the rest for you.
Ian
--
Ian Roberts | Department of Computer Science
[EMAIL PROTECTED] | University of Sheffield, UK