Object entityToMarshal = getEntityToMarshal(t, type);
// Use an OutputStream directly instead of a Writer for performance.
XMLStreamWriter xsw = null;
if (isBadgerFishConventionUsed) {
xsw = new BadgerFishXMLStreamWriter(new OutputStreamWriter(entityStream));
} else {
MappedNamespaceConvention con = new MappedNamespaceConvention(outputConfiguration);
xsw = new MappedXMLStreamWriter(con, new OutputStreamWriter(entityStream));
}
marshaller.marshal(entityToMarshal, xsw);