Class StreamingOutputMarshaller

java.lang.Object
org.eclipse.persistence.jpa.rs.util.StreamingOutputMarshaller
All Implemented Interfaces:
jakarta.ws.rs.core.StreamingOutput

public class StreamingOutputMarshaller extends Object implements 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 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

      public void write(OutputStream output) throws IOException, jakarta.ws.rs.WebApplicationException
      Specified by:
      write in interface jakarta.ws.rs.core.StreamingOutput
      Throws:
      IOException
      jakarta.ws.rs.WebApplicationException
    • mediaType

      public static jakarta.ws.rs.core.MediaType mediaType(List<jakarta.ws.rs.core.MediaType> types)
      Identify the preferred MediaType from the list provided. This will check for JSON string or MediaType first then XML.
      Parameters:
      types - List of MediaType 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)