KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > caucho > burlap > BurlapCauchoInput


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.burlap;
10
11 import java.io.IOException JavaDoc;
12 import java.io.InputStream JavaDoc;
13
14 import com.caucho.burlap.io.BurlapInput;
15 import mx4j.tools.remote.caucho.CauchoInput;
16 import mx4j.tools.remote.caucho.serialization.JMXSerializerFactory;
17
18 /**
19  * @version $Revision: 1.4 $
20  */

21 class BurlapCauchoInput implements CauchoInput
22 {
23    private final BurlapInput input;
24
25    BurlapCauchoInput(InputStream JavaDoc stream)
26    {
27       this.input = new BurlapInput();
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       } catch (Throwable JavaDoc x)
48       {
49          if (x instanceof Exception JavaDoc) throw (Exception JavaDoc) x;
50          throw (Error JavaDoc) x;
51       }
52    }
53
54    public void completeReply() throws IOException JavaDoc
55    {
56       input.completeReply();
57    }
58
59    public String JavaDoc readHeader() throws IOException JavaDoc
60    {
61       return input.readHeader();
62    }
63
64    public String JavaDoc readMethod() throws IOException JavaDoc
65    {
66       return input.readMethod();
67    }
68
69    public Object JavaDoc readObject(Class JavaDoc cls) throws IOException JavaDoc
70    {
71       if (cls == null || cls == Object JavaDoc.class) return input.readObject();
72       return input.readObject(cls);
73    }
74 }
75
Popular Tags