KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.caucho.hessian.io.Deserializer;
12 import com.caucho.hessian.io.Serializer;
13 import com.caucho.hessian.io.SerializerFactory;
14
15 /**
16  * @version $Revision: 1.4 $
17  */

18 public class JMXSerializerFactory extends SerializerFactory
19 {
20    protected Serializer getDefaultSerializer(Class JavaDoc cls)
21    {
22       if (!cls.getName().startsWith("javax.management.")) return super.getDefaultSerializer(cls);
23       return new JMXSerializer();
24    }
25
26    protected Deserializer getDefaultDeserializer(Class JavaDoc cls)
27    {
28       if (!cls.getName().startsWith("javax.management.")) return super.getDefaultDeserializer(cls);
29       // A bug in the Hessian protocol requires JMX exception to be treated as normal objects
30
if (Throwable JavaDoc.class.isAssignableFrom(cls)) return super.getDefaultDeserializer(cls);
31       return new JMXDeserializer(cls);
32    }
33 }
34
Popular Tags