When enabling buffering, you can also control how the data being serialized will be buffered.
By default, an instance of CXF Cached Output Stream will be used.
The Apache CXF provides such a support in a form of Jsr Jsonp Provider provider distributed by Apache CXF JAX-RS Extensions Providers module (cxf-rt-rs-extension-providers).
Adding Jsr Jsonp Provider provider alone (or in a combination with other providers) allows JAX-RS resources to natively use Json Structure, Json Array, Json Object as input parameters or return values.
For JAXBElement Provider to support Moxy a custom Moxy-aware JAX-RS Context Provider implementation needs to be registered in jaxrs:providers. Use JAXBElement Provider "namespace Mapper Property Name" and "xml Pi Property Name" properties if you need to customize namespace prefixes or add XML processing instructions with Moxy.
Additionally it is possible to configure JAXBElement Provider or JSONProvider with contextual properties or Document Depth Properties: As per JAX-RS 2.0 specification, the support of JSR-353 Java API for JSON Processing is mandatory requirement and implies the presence of message body reader(s)/writer(s) for following types: Json Structure, Json Array and Json Object.The simplest way is to mark a given type with @Xml Root Element annotation.For example: Alternatively to using @Xml Root Element and Collection wrappers, one can provide an Object factory which will tell JAXB how to marshal a given type (in case of Collections - its template type).The request and response can be marshalled and unmarshalled to/from Java object using JAXB.There's a number of ways to tell to the JAXB provider how objects can be serialized.