1 8 9 package mx4j.tools.remote.caucho.hessian; 10 11 import java.io.IOException ; 12 import java.io.OutputStream ; 13 14 import com.caucho.hessian.io.HessianOutput; 15 import mx4j.tools.remote.caucho.CauchoOutput; 16 import mx4j.tools.remote.caucho.serialization.JMXSerializerFactory; 17 18 21 class HessianCauchoOutput implements CauchoOutput 22 { 23 private final OutputStream stream; 24 private final HessianOutput output; 25 26 HessianCauchoOutput(OutputStream stream) 27 { 28 this.stream = stream; 29 this.output = new HessianOutput(); 30 output.setSerializerFactory(new JMXSerializerFactory()); 31 output.init(stream); 32 } 33 34 public void startReply() throws IOException 35 { 36 output.startReply(); 37 } 38 39 public void completeReply() throws IOException 40 { 41 output.completeReply(); 42 } 43 44 51 public void startCall() throws IOException 52 { 53 stream.write(99); 54 stream.write(0); 55 stream.write(1); 56 } 57 58 public void completeCall() throws IOException 59 { 60 output.completeCall(); 61 } 62 63 public void writeHeader(String header) throws IOException 64 { 65 output.writeHeader(header); 66 } 67 68 71 public void writeMethod(String methodName) throws IOException 72 { 73 stream.write(109); 74 int len = methodName.length(); 75 stream.write(len >> 8); 76 stream.write(len); 77 output.printString(methodName, 0, len); 78 } 79 80 public void writeObject(Object object) throws IOException 81 { 82 output.writeObject(object); 83 } 84 85 public void writeFault(Throwable fault) throws IOException 86 { 87 output.writeFault(fault.getClass().getName(), fault.getMessage(), fault); 88 } 89 } 90 | Popular Tags |