1 55 56 package org.apache.axis.encoding.ser.castor; 57 58 import org.apache.axis.Constants; 59 import org.apache.axis.components.logger.LogFactory; 60 import org.apache.axis.encoding.SerializationContext; 61 import org.apache.axis.encoding.Serializer; 62 import org.apache.axis.utils.Messages; 63 import org.apache.axis.wsdl.fromJava.Types; 64 import org.apache.commons.logging.Log; 65 import org.exolab.castor.xml.MarshalException; 66 import org.exolab.castor.xml.Marshaller; 67 import org.exolab.castor.xml.ValidationException; 68 import org.w3c.dom.Element ; 69 import org.xml.sax.Attributes ; 70 71 import javax.xml.namespace.QName ; 72 import java.io.IOException ; 73 74 81 public class CastorSerializer implements Serializer { 82 83 protected static Log log = 84 LogFactory.getLog(CastorSerializer.class.getName()); 85 86 96 public void serialize(QName name, 97 Attributes attributes, 98 Object value, 99 SerializationContext context) 100 throws IOException { 101 try { 102 AxisContentHandler hand = new AxisContentHandler(context); 103 Marshaller marshaller = new Marshaller(hand); 104 105 marshaller.setMarshalAsDocument(false); 109 marshaller.setRootElement(name.getLocalPart()); 110 111 marshaller.marshal(value); 113 } catch (MarshalException me) { 114 log.error(Messages.getMessage("castorMarshalException00"), me); 115 throw new IOException (Messages.getMessage( 116 "castorMarshalException00") 117 + me.getLocalizedMessage()); 118 } catch (ValidationException ve) { 119 log.error(Messages.getMessage("castorValidationException00"), ve); 120 throw new IOException (Messages.getMessage( 121 "castorValidationException00") 122 + ve.getLocation() + ": " + ve.getLocalizedMessage()); 123 } 124 } 125 126 public String getMechanismType() { 127 return Constants.AXIS_SAX; 128 } 129 130 141 public Element writeSchema(Class javaType, Types types) throws Exception { 142 return null; 143 } 144 } 145 | Popular Tags |