01: package org.objectweb.celtix.bus.jaxws.io;
02:
03: import javax.xml.namespace.QName;
04:
05: import org.w3c.dom.Node;
06:
07: import org.objectweb.celtix.bindings.DataWriter;
08: import org.objectweb.celtix.bus.jaxws.JAXBDataBindingCallback;
09: 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:
19: public void write(Object obj, T output) {
20: write(obj, null, output);
21: }
22:
23: public void write(Object obj, QName elName, T output) {
24: if (obj != null) {
25: JAXBEncoderDecoder.marshall(callback.getJAXBContext(),
26: callback.getSchema(), obj, elName, (Node) output);
27: }
28: }
29:
30: public void writeWrapper(ObjectMessageContext objCtx,
31: boolean isOutBound, T output) {
32: Object obj = callback.createWrapperType(objCtx, isOutBound);
33: QName elName = isOutBound ? callback.getResponseWrapperQName()
34: : callback.getRequestWrapperQName();
35: write(obj, elName, output);
36: }
37: }
|