protected XMLStreamWriter getStreamWriter(Object obj, OutputStream os, MediaType mt) { XMLStreamWriter writer = null; MessageContext mc = getContext(); if (mc != null) { writer = mc.getContent(XMLStreamWriter.class); if (writer == null) { XMLOutputFactory factory = (XMLOutputFactory)mc.get(XMLOutputFactory.class.getName()); if (factory != null) { try { writer = factory.createXMLStreamWriter(os); } catch (XMLStreamException e) { throw ExceptionUtils.toInternalServerErrorException( new RuntimeException("Cant' create XMLStreamWriter", e), null); } } } if (writer == null && getEnableStreaming()) { writer = StaxUtils.createXMLStreamWriter(os); } } if (writer == null && os == null) { writer = getStreamHandlerFromCurrentMessage(XMLStreamWriter.class); } return createTransformWriterIfNeeded(writer, os, true); }
protected XMLStreamWriter getStreamWriter(Object obj, OutputStream os, MediaType mt) { XMLStreamWriter writer = null; MessageContext mc = getContext(); if (mc != null) { writer = mc.getContent(XMLStreamWriter.class); if (writer == null) { XMLOutputFactory factory = (XMLOutputFactory)mc.get(XMLOutputFactory.class.getName()); if (factory != null) { try { writer = factory.createXMLStreamWriter(os); } catch (XMLStreamException e) { throw ExceptionUtils.toInternalServerErrorException( new RuntimeException("Cant' create XMLStreamWriter", e), null); } } } if (writer == null && getEnableStreaming()) { writer = StaxUtils.createXMLStreamWriter(os); } } if (writer == null && os == null) { writer = getStreamHandlerFromCurrentMessage(XMLStreamWriter.class); } return createTransformWriterIfNeeded(writer, os, true); }