Search in sources :

Example 1 with BadgerFishXMLOutputFactory

use of org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory in project cxf by apache.

the class BadgerFishProvider method writeTo.

public void writeTo(Object obj, Class<?> clazz, Type genericType, Annotation[] annotations, MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) {
    try {
        if (!new Locale("badgerFishLanguage").equals(requestHeaders.getLanguage())) {
            throw new RuntimeException();
        }
        JAXBContext context = getJAXBContext(obj.getClass());
        Marshaller marshaller = context.createMarshaller();
        XMLOutputFactory factory = new BadgerFishXMLOutputFactory();
        XMLStreamWriter xsw = factory.createXMLStreamWriter(os);
        marshaller.marshal(obj, xsw);
        xsw.close();
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
}
Also used : Locale(java.util.Locale) Marshaller(javax.xml.bind.Marshaller) XMLOutputFactory(javax.xml.stream.XMLOutputFactory) BadgerFishXMLOutputFactory(org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory) XMLStreamException(javax.xml.stream.XMLStreamException) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) BadgerFishXMLOutputFactory(org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory)

Aggregations

Locale (java.util.Locale)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 BadgerFishXMLOutputFactory (org.codehaus.jettison.badgerfish.BadgerFishXMLOutputFactory)1