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
ConstructorDescriptionStreamingOutputMarshaller
(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.Marshaller
createMarshaller
(PersistenceContext context, jakarta.ws.rs.core.MediaType mediaType) static jakarta.ws.rs.core.MediaType
getResponseMediaType
(jakarta.ws.rs.core.HttpHeaders headers) static jakarta.ws.rs.core.MediaType
Identify the preferredMediaType
from the list provided.void
write
(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:
write
in interfacejakarta.ws.rs.core.StreamingOutput
- Throws:
IOException
jakarta.ws.rs.WebApplicationException
-
mediaType
Identify the preferredMediaType
from the list provided. This will check for JSON string orMediaType
first then XML.- Parameters:
types
- List ofMediaType
values;- 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)
-