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

2014-11-24 03:00:31 · 作者: · 浏览: 2
dos; } if (!isToUse.markSupported()) { isToUse = new BufferedInputStream(isToUse); isToUse.mark(1); } int code = isToUse.read(); int major; int minor; AbstractHessianInput in; AbstractHessianOutput out; //根据客户端不同的Hessian版本,设置不同的Hessian抽象输入/输出 //Hessian2.0 if (code == 'H') { major = isToUse.read(); minor = isToUse.read(); if (major != 0x02) { throw new IOException("Version " + major + "." + minor + " is not understood"); } in = new Hessian2Input(isToUse); out = new Hessian2Output(osToUse); in.readCall(); } //Hessian2.0 else if (code == 'C') { isToUse.reset(); in = new Hessian2Input(isToUse); out = new Hessian2Output(osToUse); in.readCall(); } //Hessian1.0 else if (code == 'c') { major = isToUse.read(); minor = isToUse.read(); in = new HessianInput(isToUse); if (major >= 2) { out = new Hessian2Output(osToUse); } else { out = new HessianOutput(osToUse); } } else { throw new IOException("Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code); } //设置Hessian序列化工厂 if (this.serializerFactory != null) { in.setSerializerFactory(this.serializerFactory); out.setSerializerFactory(this.serializerFactory); } try { //通过服务端远程对象的Hessian框架处理远程调用 skeleton.invoke(in, out); } finally { try { in.close(); isToUse.close(); } catch (IOException ex) { } try { out.close(); osToUse.close(); } catch (IOException ex) { } } } //重置类加载器 finally { resetThreadContextClassLoader(originalClassLoader); } } }