01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.remoting.caucho;
18:
19: import java.io.IOException;
20: import java.io.InputStream;
21: import java.io.OutputStream;
22:
23: import com.caucho.hessian.io.AbstractHessianOutput;
24: import com.caucho.hessian.io.Hessian2Input;
25: import com.caucho.hessian.io.Hessian2Output;
26: import com.caucho.hessian.io.HessianOutput;
27: import com.caucho.hessian.io.SerializerFactory;
28: import com.caucho.hessian.server.HessianSkeleton;
29:
30: /**
31: * Concrete HessianSkeletonInvoker for the Hessian 2 protocol
32: * (version 3.0.20 or higher).
33: *
34: * @author Juergen Hoeller
35: * @since 2.0
36: */
37: class Hessian2SkeletonInvoker extends HessianSkeletonInvoker {
38:
39: public Hessian2SkeletonInvoker(HessianSkeleton skeleton,
40: SerializerFactory serializerFactory) {
41: super (skeleton, serializerFactory);
42: }
43:
44: public void invoke(InputStream inputStream,
45: OutputStream outputStream) throws Throwable {
46: Hessian2Input in = new Hessian2Input(inputStream);
47: if (this .serializerFactory != null) {
48: in.setSerializerFactory(this .serializerFactory);
49: }
50:
51: int code = in.read();
52: if (code != 'c') {
53: throw new IOException("expected 'c' in hessian input at "
54: + code);
55: }
56:
57: AbstractHessianOutput out = null;
58: int major = in.read();
59: int minor = in.read();
60: if (major >= 2) {
61: out = new Hessian2Output(outputStream);
62: } else {
63: out = new HessianOutput(outputStream);
64: }
65: if (this.serializerFactory != null) {
66: out.setSerializerFactory(this.serializerFactory);
67: }
68:
69: this.skeleton.invoke(in, out);
70: }
71:
72: }
|