KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > caucho > hessian > HessianCauchoInput


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.caucho.hessian;
10
11 import java.io.IOException JavaDoc;
12 import java.io.InputStream JavaDoc;
13
14 import com.caucho.hessian.io.HessianInput;
15 import mx4j.tools.remote.caucho.CauchoInput;
16 import mx4j.tools.remote.caucho.serialization.JMXSerializerFactory;
17
18 /**
19  * @version $Revision: 1.3 $
20  */

21 class HessianCauchoInput implements CauchoInput
22 {
23    private final HessianInput input;
24
25    HessianCauchoInput(InputStream JavaDoc stream)
26    {
27       this.input = new HessianInput();
28       input.setSerializerFactory(new JMXSerializerFactory());
29       input.init(stream);
30    }
31
32    public void startCall() throws IOException JavaDoc
33    {
34       input.readCall();
35    }
36
37    public void completeCall() throws IOException JavaDoc
38    {
39       input.completeCall();
40    }
41
42    public void startReply() throws Exception JavaDoc
43    {
44       try
45       {
46          input.startReply();
47       }
48       catch (Throwable JavaDoc x)
49       {
50          if (x instanceof Exception JavaDoc) throw (Exception JavaDoc)x;
51          throw (Error JavaDoc)x;
52       }
53    }
54
55    public void completeReply() throws IOException JavaDoc
56    {
57       input.completeReply();
58    }
59
60    public String JavaDoc readHeader() throws IOException JavaDoc
61    {
62       return input.readHeader();
63    }
64
65    public String JavaDoc readMethod() throws IOException JavaDoc
66    {
67       return input.readMethod();
68    }
69
70    public Object JavaDoc readObject(Class JavaDoc cls) throws IOException JavaDoc
71    {
72       return cls == null ? input.readObject() : input.readObject(cls);
73    }
74 }
75
Popular Tags