1 16 17 package org.springframework.remoting.caucho; 18 19 import java.io.InputStream ; 20 import java.io.OutputStream ; 21 import java.lang.reflect.Method ; 22 23 import com.caucho.hessian.io.HessianInput; 24 import com.caucho.hessian.io.HessianOutput; 25 import com.caucho.hessian.io.SerializerFactory; 26 import com.caucho.hessian.server.HessianSkeleton; 27 28 import org.springframework.util.ClassUtils; 29 30 37 class Hessian1SkeletonInvoker extends HessianSkeletonInvoker { 38 39 private static final Method invokeMethod; 40 41 private static final boolean applySerializerFactoryToOutput; 42 43 static { 44 invokeMethod = ClassUtils.getMethodIfAvailable( 45 HessianSkeleton.class, "invoke", new Class [] {HessianInput.class, HessianOutput.class}); 46 applySerializerFactoryToOutput = 47 ClassUtils.hasMethod(HessianOutput.class, "setSerializerFactory", new Class [] {SerializerFactory.class}); 48 } 49 50 51 public Hessian1SkeletonInvoker(HessianSkeleton skeleton, SerializerFactory serializerFactory) { 52 super(skeleton, serializerFactory); 53 if (invokeMethod == null) { 54 throw new IllegalStateException ("Hessian 1 (version 3.0.19-) not present"); 55 } 56 } 57 58 public void invoke(InputStream inputStream, OutputStream outputStream) throws Throwable { 59 HessianInput in = new HessianInput(inputStream); 60 HessianOutput out = new HessianOutput(outputStream); 61 if (this.serializerFactory != null) { 62 in.setSerializerFactory(this.serializerFactory); 63 if (applySerializerFactoryToOutput) { 64 out.setSerializerFactory(this.serializerFactory); 65 } 66 } 67 invokeMethod.invoke(this.skeleton, new Object [] {in, out}); 68 } 69 70 } 71 | Popular Tags |