java.lang.Object
org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
org.apache.hadoop.yarn.server.resourcemanager.webapp.jsonprovider.IncludeRootJSONProvider
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>

@Provider @Produces("application/json") @Consumes("application/json") public class IncludeRootJSONProvider extends org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
A custom JSON provider that extends MOXyJsonProvider to ensure that JSON marshalling and unmarshalling include the root element for configured classes.

This provider integrates with EclipseLink MOXy and the JAX-RS runtime (annotated with Provider), and it is configured to both produce and consume application/json content types. It uses a ClassSerialisationConfig to determine which classes should include their root elements when serialized or deserialized.

During marshalling and unmarshalling, this provider sets the MOXy-specific properties:
  • MarshallerProperties.JSON_INCLUDE_ROOT = true
  • MarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS = false
ensuring consistent JSON structure that includes the root element and omits empty collections.

This class also provides detailed trace logging to help debug compatibility and data binding behavior for registered entity types.

See Also:
  • Field Summary

    Fields inherited from class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider

    providers
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    IncludeRootJSONProvider(org.apache.hadoop.conf.Configuration conf)
    Constructs a new IncludeRootJSONProvider instance and initializes its ClassSerialisationConfig based on the provided application configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
    boolean
    isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
    protected void
    preReadFrom(Class<Object> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, javax.xml.bind.Unmarshaller unmarshaller)
    protected void
    preWriteTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, javax.xml.bind.Marshaller marshaller)

    Methods inherited from class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider

    getAttributePrefix, getDomainClass, getDomainClasses, getJAXBContext, getNamespacePrefixMapper, getNamespaceSeparator, getSize, getValueWrapper, isFormattedOutput, isIncludeRoot, isMarshalEmptyCollections, isWrapperAsArrayName, readFrom, setAttributePrefix, setFormattedOutput, setIncludeRoot, setMarshalEmptyCollections, setNamespacePrefixMapper, setNamespaceSeparator, setValueWrapper, setWrapperAsArrayName, supportsMediaType, writeTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IncludeRootJSONProvider

      public IncludeRootJSONProvider()
      Default constructor.
    • IncludeRootJSONProvider

      @Inject public IncludeRootJSONProvider(@Named("conf") org.apache.hadoop.conf.Configuration conf)
      Constructs a new IncludeRootJSONProvider instance and initializes its ClassSerialisationConfig based on the provided application configuration.

      This constructor is designed for dependency injection. The Configuration object is injected (qualified with @Named("conf")) and used to create a ClassSerialisationConfig instance, which controls how classes are serialized to JSON (e.g., whether to include root elements).

      Parameters:
      conf - the application Configuration instance injected by the framework; used to initialize serialization settings
  • Method Details

    • isReadable

      public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
      Specified by:
      isReadable in interface javax.ws.rs.ext.MessageBodyReader<Object>
      Overrides:
      isReadable in class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
    • isWriteable

      public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
      Specified by:
      isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<Object>
      Overrides:
      isWriteable in class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
    • preReadFrom

      protected void preReadFrom(Class<Object> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,String> httpHeaders, javax.xml.bind.Unmarshaller unmarshaller) throws javax.xml.bind.JAXBException
      Overrides:
      preReadFrom in class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
      Throws:
      javax.xml.bind.JAXBException
    • preWriteTo

      protected void preWriteTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, javax.xml.bind.Marshaller marshaller) throws javax.xml.bind.JAXBException
      Overrides:
      preWriteTo in class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
      Throws:
      javax.xml.bind.JAXBException