use of org.jibx.runtime.IMarshallingContext in project camel by apache.
the class JibxDataFormat method marshal.
public void marshal(Exchange exchange, Object body, OutputStream stream) throws Exception {
IBindingFactory bindingFactory = createBindingFactory(body.getClass(), bindingName);
IMarshallingContext marshallingContext = bindingFactory.createMarshallingContext();
marshallingContext.marshalDocument(body, null, null, stream);
if (contentTypeHeader) {
if (exchange.hasOut()) {
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/xml");
} else {
exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/xml");
}
}
}
use of org.jibx.runtime.IMarshallingContext in project spring-framework by spring-projects.
the class JibxMarshaller method createMarshallingContext.
/**
* Create a new {@code IMarshallingContext}, configured with the correct indentation.
* @return the created marshalling context
* @throws JiBXException in case of errors
*/
protected IMarshallingContext createMarshallingContext() throws JiBXException {
IMarshallingContext marshallingContext = this.bindingFactory.createMarshallingContext();
marshallingContext.setIndent(this.indent);
return marshallingContext;
}
use of org.jibx.runtime.IMarshallingContext in project RESTdoclet by IG-Group.
the class JiBXUtils method marshallController.
/**
* Static method for marshalling a controller.
*
* @param controller the controller to be marshalled.
* @param file the file the controller has to be marshalled to.
* @throws JiBXException if JiBX fails.
* @throws IOException if an input- or output-exception occurs.
*/
public static void marshallController(final Controller controller, final File file) throws JiBXException, IOException {
final Writer writer = new FileWriter(file);
final IBindingFactory factory = BindingDirectory.getFactory(Controller.class);
final IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(INDENT);
context.setOutput(writer);
context.marshalDocument(controller, ENCODING, null);
}
use of org.jibx.runtime.IMarshallingContext in project RESTdoclet by IG-Group.
the class JiBXUtils method marshallService.
/**
* Static method for marshalling a service.
*
* @param service the service to be marshalled.
* @param file the file the service has to be marshalled to.
* @throws JiBXException if JiBX fails.
* @throws IOException if an input- or output-exception occurs.
*/
public static void marshallService(final Service service, final File file) throws JiBXException, IOException {
final Writer writer = new FileWriter(file);
final IBindingFactory factory = BindingDirectory.getFactory(Service.class);
final IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(INDENT);
context.setOutput(writer);
context.marshalDocument(service, ENCODING, null);
}
use of org.jibx.runtime.IMarshallingContext in project spring-framework by spring-projects.
the class JibxMarshaller method marshalOutputStream.
// Supported marshalling
@Override
protected void marshalOutputStream(Object graph, OutputStream outputStream) throws XmlMappingException, IOException {
try {
IMarshallingContext marshallingContext = createMarshallingContext();
marshallingContext.startDocument(this.encoding, this.standalone, outputStream);
marshalDocument(marshallingContext, graph);
} catch (JiBXException ex) {
throw convertJibxException(ex, true);
}
}
Aggregations