1 package org.objectweb.celtix.bus.jaxws.io; 2 3 import javax.xml.namespace.QName ; 4 5 import org.w3c.dom.Node ; 6 7 import org.objectweb.celtix.bindings.DataWriter; 8 import org.objectweb.celtix.bus.jaxws.JAXBDataBindingCallback; 9 import org.objectweb.celtix.bus.jaxws.JAXBEncoderDecoder; 10 import org.objectweb.celtix.context.ObjectMessageContext; 11 12 public class NodeDataWriter<T> implements DataWriter<T> { 13 final JAXBDataBindingCallback callback; 14 15 public NodeDataWriter(JAXBDataBindingCallback cb) { 16 callback = cb; 17 } 18 public void write(Object obj, T output) { 19 write(obj, null, output); 20 } 21 public void write(Object obj, QName elName, T output) { 22 if (obj != null) { 23 JAXBEncoderDecoder.marshall(callback.getJAXBContext(), 24 callback.getSchema(), obj, elName, (Node )output); 25 } 26 } 27 public void writeWrapper(ObjectMessageContext objCtx, boolean isOutBound, T output) { 28 Object obj = callback.createWrapperType(objCtx, isOutBound); 29 QName elName = isOutBound ? callback.getResponseWrapperQName() 30 : callback.getRequestWrapperQName(); 31 write(obj, elName, output); 32 } 33 } 34 | Popular Tags |