}
private static void doSerialize(OutputStream outputStream, Document document, Map options) throws IOException
{
JAXPPool jaxpPool = null;
JAXPConfiguration config = null;
String encoding = null;
if (options != null)
{
jaxpPool = (JAXPPool)options.get(WSDL_JAXP_POOL);
config = (JAXPConfiguration)options.get(WSDL_JAXP_CONFIG);
encoding = (String)options.get(WSDL_ENCODING);
}
if (jaxpPool == null)
{
if (config == null)
{
doSerialize(outputStream, document, encoding);
}
else
{
try
{
Transformer transformer = config.createTransformer(encoding);
// Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null.
encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding);
transformer.transform(new DOMSource(document), new StreamResult(writer));
}