Class StreamingOutputMarshaller

  • All Implemented Interfaces:
    javax.ws.rs.core.StreamingOutput

    public class StreamingOutputMarshaller
    extends java.lang.Object
    implements javax.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
    Since:
    EclipseLink 2.4.0
    • Constructor Detail

      • StreamingOutputMarshaller

        public StreamingOutputMarshaller​(PersistenceContext context,
                                         java.lang.Object result,
                                         javax.ws.rs.core.MediaType acceptedType)
      • StreamingOutputMarshaller

        public StreamingOutputMarshaller​(PersistenceContext context,
                                         java.lang.Object result,
                                         java.util.List<javax.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,
                                         java.lang.Object result,
                                         java.util.List<javax.ws.rs.core.MediaType> acceptedTypes)
        Creates a new StreamingOutputMarshaller.
        Parameters:
        context - persistence context.
        result - entity to process.
        acceptedTypes - accepted media types.
    • Method Detail

      • write

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

        public static javax.ws.rs.core.MediaType mediaType​(java.util.List<javax.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
      • getResponseMediaType

        public static javax.ws.rs.core.MediaType getResponseMediaType​(javax.ws.rs.core.HttpHeaders headers)