Class IncludeRootJSONProvider
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.
MarshallerProperties.JSON_INCLUDE_ROOT = trueMarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS = false
This class also provides detailed trace logging to help debug compatibility and data binding behavior for registered entity types.
- See Also:
-
MOXyJsonProviderMarshallerPropertiesClassSerialisationConfigConfiguration
-
Field Summary
Fields inherited from class org.eclipse.persistence.jaxb.rs.MOXyJsonProvider
providers -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.IncludeRootJSONProvider(org.apache.hadoop.conf.Configuration conf) Constructs a newIncludeRootJSONProviderinstance and initializes itsClassSerialisationConfigbased on the provided application configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisReadable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) booleanisWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) protected voidpreReadFrom(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 voidpreWriteTo(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
-
Constructor Details
-
IncludeRootJSONProvider
public IncludeRootJSONProvider()Default constructor. -
IncludeRootJSONProvider
@Inject public IncludeRootJSONProvider(@Named("conf") org.apache.hadoop.conf.Configuration conf) Constructs a newIncludeRootJSONProviderinstance and initializes itsClassSerialisationConfigbased on the provided application configuration.This constructor is designed for dependency injection. The
Configurationobject is injected (qualified with@Named("conf")) and used to create aClassSerialisationConfiginstance, which controls how classes are serialized to JSON (e.g., whether to include root elements).- Parameters:
conf- the applicationConfigurationinstance 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:
isReadablein interfacejavax.ws.rs.ext.MessageBodyReader<Object>- Overrides:
isReadablein classorg.eclipse.persistence.jaxb.rs.MOXyJsonProvider
-
isWriteable
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType) - Specified by:
isWriteablein interfacejavax.ws.rs.ext.MessageBodyWriter<Object>- Overrides:
isWriteablein classorg.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:
preReadFromin classorg.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:
preWriteToin classorg.eclipse.persistence.jaxb.rs.MOXyJsonProvider- Throws:
javax.xml.bind.JAXBException
-