Hi: CXF Chain Interceptor is simple and good mechanism for protocol interpret;
But sometimes it seem "Chain Interceptor " mechanism is not very suitable for things such as system resource release; To illustrate this, following is a sample: 1) Recently I am using CXF to expose an existing system as a webservice; When asking for data from the existing system , it will generate a temporary file and return it as a result; That's to say: when I expose it as a webservice, the temporary file must be deleted after the webservice response is sent over(no mattacher successfully or fault); At first, I think the it's simple and easy by using a interceptor to delete the temporary file; and configure it in Out & FaultOut Chains; But actually, things is not some simple. Because what I really want is some mechanism which is like "try{interceptor-chains}finally {do-some-system-resource-release}" ; Chain Interceptors may be aborted by some internal failure (and it should be so because it's designed for protocol interpret) . So if I use interceptor to delete the temporary file, sometimes the temporary file cannot be deleted (for example: network break down while sending soap-response, the Out Chain will be aborted, and temporary file cannot be deleted); So I wonderring if CXF support mechanism suitable for such a usage beside just using interceptors ? 2) Maybe following is another sample: Recently while I looking into CXF's source, it seems some interceptor of CXF also do something which like system-resource release. If so , I guess, sometimes this will also cause issues. For example: OutgoingChainInterceptor.handleMessage(){ if (null != bin && null != bin.getOperationInfo() && bin.getOperationInfo().isOneWay()) { closeInput(message); return; } } OutgoingChainInterceptor will release system resources relate to input stream for one-way operation, but it's not always be guaranteed invoked; For example if the one-way business logical throw a runtime-exception , it will breaked the interceptor chain, and OutgoingChainInterceptor will not be called. So the input stream's underly system resource may not be released; (I have show a real problem relate to OutgoingChainInterceptor in another issue CXF-3750's comments).