KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > remoting > caucho > Hessian2SkeletonInvoker


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
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, SerializerFactory serializerFactory) {
40         super(skeleton, serializerFactory);
41     }
42
43     public void invoke(InputStream JavaDoc inputStream, OutputStream JavaDoc outputStream) throws Throwable JavaDoc {
44         Hessian2Input in = new Hessian2Input(inputStream);
45         if (this.serializerFactory != null) {
46             in.setSerializerFactory(this.serializerFactory);
47         }
48
49         int code = in.read();
50         if (code != 'c') {
51             throw new IOException JavaDoc("expected 'c' in hessian input at " + code);
52         }
53
54         AbstractHessianOutput out = null;
55         int major = in.read();
56         int minor = in.read();
57         if (major >= 2) {
58             out = new Hessian2Output(outputStream);
59         }
60         else {
61             out = new HessianOutput(outputStream);
62         }
63         if (this.serializerFactory != null) {
64             out.setSerializerFactory(this.serializerFactory);
65         }
66
67         this.skeleton.invoke(in, out);
68     }
69
70 }
71
Popular Tags