public JAXRSOutInterceptor() {
super(Phase.MARSHAL);
}
public void handleMessage(Message message) {
ServerProviderFactory providerFactory = ServerProviderFactory.getInstance(message);
try {
processResponse(providerFactory, message);
} catch (Exception ex) {
message.put("jaxrs.out.fault", Boolean.TRUE);
} finally {
Object rootInstance = message.getExchange().remove(JAXRSUtils.ROOT_INSTANCE);
Object rootProvider = message.getExchange().remove(JAXRSUtils.ROOT_PROVIDER);
if (rootInstance != null && rootProvider != null) {
try {
((ResourceProvider)rootProvider).releaseInstance(message, rootInstance);
} catch (Throwable tex) {
LOG.warning("Exception occurred during releasing the service instance, "
+ tex.getMessage());
}
}
providerFactory.clearThreadLocalProxies();
ClassResourceInfo cri =
(ClassResourceInfo)message.getExchange().get(JAXRSUtils.ROOT_RESOURCE_CLASS);
if (cri != null) {
cri.clearThreadLocalProxies();
}