Spring框架学习[Spring使用Hessian实现远程调用](四)

2014-11-24 03:00:31 · 作者: · 浏览: 3
(UndeclaredThrowableException) targetEx; throw convertHessianAccessException(utex.getUndeclaredThrowable()); } else { throw targetEx; } } catch (Throwable ex) { throw new RemoteProxyFailureException( "Failed to invoke Hessian proxy for remote service [" + getServiceUrl() + "]", ex); } //重置类加载器 finally { resetThreadContextClassLoader(originalClassLoader); } } //将Hessian异常转换为Spring远程调用异常 protected RemoteAccessException convertHessianAccessException(Throwable ex) { if (ex instanceof HessianConnectionException || ex instanceof ConnectException) { return new RemoteConnectFailureException( "Cannot connect to Hessian remote service at [" + getServiceUrl() + "]", ex); } else { return new RemoteAccessException( "Cannot access Hessian remote service at [" + getServiceUrl() + "]", ex); } } }