mx4j/src/tools/mx4j/tools/remote/caucho/serialization JMXDeserializer.java,NONE,1.1 JMXSerializer.java,NONE,1.1 JMXSerializerFactory.java,NONE,1.1
Simone Bordet <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/caucho/serialization In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24799/src/tools/mx4j/tools/remote/caucho/serialization Added Files: JMXDeserializer.java JMXSerializer.java JMXSerializerFactory.java Log Message: Implementation of the JSR 160 JMXConnector and JMXConnectorServer over Caucho's Hessian and Burlap protocols --- NEW FILE: JMXSerializer.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.caucho.serialization; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import com.caucho.hessian.io.AbstractHessianOutput; import com.caucho.hessian.io.Serializer; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ class JMXSerializer extends Serializer { public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { out.writeMapBegin(obj.getClass().getName()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(obj); oos.close(); out.writeBytes(baos.toByteArray()); } } --- NEW FILE: JMXSerializerFactory.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.caucho.serialization; import com.caucho.hessian.io.Deserializer; import com.caucho.hessian.io.Serializer; import com.caucho.hessian.io.SerializerFactory; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ public class JMXSerializerFactory extends SerializerFactory { protected Serializer getDefaultSerializer(Class cls) { if (!cls.getName().startsWith("javax.management.")) return super.getDefaultSerializer(cls); return new JMXSerializer(); } protected Deserializer getDefaultDeserializer(Class cls) { if (!cls.getName().startsWith("javax.management.")) return super.getDefaultDeserializer(cls); // A bug in the Hessian protocol requires JMX exception to be treated as normal objects if (Throwable.class.isAssignableFrom(cls)) return super.getDefaultDeserializer(cls); return new JMXDeserializer(); } } --- NEW FILE: JMXDeserializer.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.caucho.serialization; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import com.caucho.hessian.io.AbstractHessianInput; import com.caucho.hessian.io.Deserializer; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $ */ class JMXDeserializer extends Deserializer { public Object readMap(AbstractHessianInput in) throws IOException { try { byte[] bytes = in.readBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); Object result = ois.readObject(); ois.close(); return result; } catch (ClassNotFoundException x) { throw new IOException(x.toString()); } } } ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285