KickJava   Java API By Example, From Geeks To Geeks.

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


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.ByteArrayOutputStream JavaDoc;
12 import java.io.IOException JavaDoc;
13 import java.io.ObjectOutputStream JavaDoc;
14
15 import com.caucho.hessian.io.AbstractHessianOutput;
16 import com.caucho.hessian.io.Serializer;
17
18 /**
19  * @version $Revision: 1.3 $
20  */

21 class JMXSerializer extends Serializer
22 {
23    public void writeObject(Object JavaDoc obj, AbstractHessianOutput out) throws IOException JavaDoc
24    {
25       out.writeMapBegin(obj.getClass().getName());
26       ByteArrayOutputStream JavaDoc baos = new ByteArrayOutputStream JavaDoc();
27       ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(baos);
28       oos.writeObject(obj);
29       oos.close();
30       out.writeBytes(baos.toByteArray());
31    }
32 }
33
Popular Tags