Class StreamingOutputMarshaller
java.lang.Object
org.eclipse.persistence.jpa.rs.util.StreamingOutputMarshaller
- All Implemented Interfaces:
jakarta.ws.rs.core.StreamingOutput
Simple
StreamingOutput implementation that uses the provided
JAXBContext to marshal the result when requested to either XML or
JSON based on the accept media provided.- Author:
- dclarke
-
Constructor Summary
ConstructorsConstructorDescriptionStreamingOutputMarshaller(PersistenceContext context, Object result, jakarta.ws.rs.core.MediaType acceptedType) StreamingOutputMarshaller(PersistenceContext context, Object result, List<jakarta.ws.rs.core.MediaType> acceptedTypes) Creates a new StreamingOutputMarshaller.StreamingOutputMarshaller(PersistenceContext context, Object result, List<jakarta.ws.rs.core.MediaType> acceptedTypes, FieldsFilter filter) This constructor is used for fields filtering. -
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.xml.bind.MarshallercreateMarshaller(PersistenceContext context, jakarta.ws.rs.core.MediaType mediaType) static jakarta.ws.rs.core.MediaTypegetResponseMediaType(jakarta.ws.rs.core.HttpHeaders headers) static jakarta.ws.rs.core.MediaTypeIdentify the preferredMediaTypefrom the list provided.voidwrite(OutputStream output)
-
Constructor Details
-
StreamingOutputMarshaller
public StreamingOutputMarshaller(PersistenceContext context, Object result, jakarta.ws.rs.core.MediaType acceptedType) -
StreamingOutputMarshaller
public StreamingOutputMarshaller(PersistenceContext context, Object result, List<jakarta.ws.rs.core.MediaType> acceptedTypes, FieldsFilter filter) This constructor is used for fields filtering. Only attributes included in fields parameter are marshalled.- Parameters:
context- persistence context.result- entity to process.acceptedTypes- accepted media types.filter- containing a list of fields to filter out from the response.
-
StreamingOutputMarshaller
public StreamingOutputMarshaller(PersistenceContext context, Object result, List<jakarta.ws.rs.core.MediaType> acceptedTypes) Creates a new StreamingOutputMarshaller.- Parameters:
context- persistence context.result- entity to process.acceptedTypes- accepted media types.
-
-
Method Details
-
write
- Specified by:
writein interfacejakarta.ws.rs.core.StreamingOutput- Throws:
IOExceptionjakarta.ws.rs.WebApplicationException
-
mediaType
Identify the preferredMediaTypefrom the list provided. This will check for JSON string orMediaTypefirst then XML.- Parameters:
types- List ofMediaTypevalues;- Returns:
- selected
MediaType
-
createMarshaller
public static jakarta.xml.bind.Marshaller createMarshaller(PersistenceContext context, jakarta.ws.rs.core.MediaType mediaType) throws jakarta.xml.bind.JAXBException - Throws:
jakarta.xml.bind.JAXBException
-
getResponseMediaType
public static jakarta.ws.rs.core.MediaType getResponseMediaType(jakarta.ws.rs.core.HttpHeaders headers)
-