// TODO Auto-generated method stub
}
public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
Type type = databinding.getType(part);
if (type == null) {
throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG));
}
Map<String, Object> props = (Endpoint)getProperty(ENDPOINT);
if (props == null) {
props = new HashMap<String, Object>();
}
Context context = new Context(props);
// I'm not sure that this is the right type mapping
context.setTypeMapping(type.getTypeMapping());
context.setOverrideTypes(CastUtils.cast(databinding.getOverrideTypes(), String.class));
context.setAttachments(attachments);
Object val = databinding.getService().get(AegisDatabinding.WRITE_XSI_TYPE_KEY);
if ("true".equals(val) || Boolean.TRUE.equals(val)) {
context.setWriteXsiTypes(true);
}
type = TypeUtil.getWriteType(context, obj, type);
try {
if (obj == null) {
if (part.getXmlSchema() instanceof XmlSchemaElement
&& ((XmlSchemaElement)part.getXmlSchema()).getMinOccurs() == 0) {
//skip writing minOccurs=0 stuff if obj is null
return;
} else if (type.isNillable() && type.isWriteOuter()) {
ElementWriter writer = new ElementWriter(output);
MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
w2.writeXsiNil();
w2.close();
return;
}
}
ElementWriter writer = new ElementWriter(output);
MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
type.writeObject(obj, w2, context);
w2.close();
} catch (DatabindingException e) {
throw new RuntimeException(e);
}
}