Example usage for org.springframework.oxm.jaxb Jaxb2Marshaller getJaxbContext

List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller getJaxbContext

Introduction

In this page you can find the example usage for org.springframework.oxm.jaxb Jaxb2Marshaller getJaxbContext.

Prototype

public JAXBContext getJaxbContext() 

Source Link

Document

Return the JAXBContext used by this marshaller, lazily building it if necessary.

Usage

From source file:no.digipost.api.xml.Marshalling.java

public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final Node node, final Class<T> clazz) {
    try {/*w w w. j av a  2  s.  com*/
        JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller().unmarshal(node,
                clazz);
        return jaxbElement.getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:no.digipost.api.xml.Marshalling.java

public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final SoapBody body,
        final Class<T> clazz) {
    try {/*www .j av a  2 s.c  om*/
        JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller()
                .unmarshal(body.getPayloadSource(), clazz);
        return jaxbElement.getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:no.digipost.api.xml.Marshalling.java

public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final InputStream is,
        final Class<T> clazz) {
    try {/*from   ww  w  .j  a va  2 s  .  c om*/
        JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller()
                .unmarshal(new StreamSource(is), clazz);
        return jaxbElement.getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:no.digipost.api.xml.Marshalling.java

public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final SoapHeaderElement header,
        final Class<T> clazz) {
    try {//from   w ww . j  a  v a  2 s.  com
        JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller()
                .unmarshal(header.getSource(), clazz);
        return jaxbElement.getValue();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:no.digipost.api.xml.Marshalling.java

public static void marshal(final Jaxb2Marshaller jaxb2Marshaller, final Object element,
        final Result payloadResult) {
    try {//from  w  w  w  . j a  va2  s .  c o  m
        JAXBSource jaxbSource = new JAXBSource(jaxb2Marshaller.getJaxbContext().createMarshaller(), element);
        TransformerUtil.transform(jaxbSource, payloadResult);
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}