throws Exception {
for (Map.Entry<String, Object> entry : mProperties.entrySet()) {
ms.setProperty(entry.getKey(), entry.getValue());
}
MessageContext mc = getContext();
if (mc != null) {
// check Marshaller properties which might've been set earlier on,
// they'll overwrite statically configured ones
for (String key : MARSHALLER_PROPERTIES) {
Object value = mc.get(key);
if (value != null) {
ms.setProperty(key, value);
}
}
}
XMLStreamWriter writer = getStreamWriter(obj, os, mt);
if (writer != null) {
if (mc != null) {
if (mc.getContent(XMLStreamWriter.class) != null) {
ms.setProperty(Marshaller.JAXB_FRAGMENT, true);
}
mc.put(XMLStreamWriter.class.getName(), writer);
}
marshalToWriter(ms, obj, writer, mt);
if (mc != null && mc.getContent(XMLStreamWriter.class) != null) {
writer.writeEndDocument();
writer.flush();
writer.close();
}
} else {