KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > caucho > serialization > JMXDeserializer


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.serialization;
10
11 import java.io.ByteArrayInputStream JavaDoc;
12 import java.io.IOException JavaDoc;
13 import java.io.ObjectInputStream JavaDoc;
14
15 import com.caucho.hessian.io.AbstractHessianInput;
16 import com.caucho.hessian.io.Deserializer;
17
18 /**
19  * @version $
20  */

21 class JMXDeserializer extends Deserializer
22 {
23    private Class JavaDoc type;
24
25    JMXDeserializer(Class JavaDoc type)
26    {
27       this.type = type;
28    }
29
30    public Class JavaDoc getType()
31    {
32       return type;
33    }
34
35    public Object JavaDoc readMap(AbstractHessianInput in) throws IOException JavaDoc
36    {
37       try
38       {
39          byte[] bytes = in.readBytes();
40          ByteArrayInputStream JavaDoc bais = new ByteArrayInputStream JavaDoc(bytes);
41          ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(bais);
42          Object JavaDoc result = ois.readObject();
43          ois.close();
44          return result;
45       }
46       catch (ClassNotFoundException JavaDoc x)
47       {
48          throw new IOException JavaDoc(x.toString());
49       }
50    }
51 }
52
Popular Tags