Class ClassSerialisationConfig
This class manages two categories of data transfer objects (DTOs):
- Wrapped classes – classes whose JSON representation includes a root wrapper element.
- Unwrapped classes – classes whose JSON representation omits a root wrapper element.
The configuration is initialized with a default list of constant classes and may optionally include user-defined classes loaded from configuration properties:
yarn.http.webapp.custom.dao.classesyarn.http.webapp.custom.unwrapped.dao.classes
This configuration is primarily used to control JSON serialization behavior in MOXy providers when serializing REST API objects.
Example:
If we have a class like:
@XmlRootElement(name = "foo-class")
class Foo {
String a;
String b;
}
and the class is present in the wrapped classes list, it will be marshalled as:
{
"foo-class": {
"a": "...",
"b": "..."
}
}
or if the class is present in the unwrapped classes list, it will be marshalled as:
{
"a": "...",
"b": "..."
}
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ClassSerialisationConfig(org.apache.hadoop.conf.Configuration conf) Constructs a newClassSerialisationConfiginstance and initializes the sets of wrapped and unwrapped classes used for JSON serialization. -
Method Summary
Modifier and TypeMethodDescriptionReturns the set of classes whose JSON representation should omit the root element.Returns the set of classes whose JSON representation should include a root element.
-
Constructor Details
-
ClassSerialisationConfig
public ClassSerialisationConfig()Default constructor. -
ClassSerialisationConfig
@Inject public ClassSerialisationConfig(@Named("conf") org.apache.hadoop.conf.Configuration conf) Constructs a newClassSerialisationConfiginstance and initializes the sets of wrapped and unwrapped classes used for JSON serialization.- Parameters:
conf- the HadoopConfigurationinstance (typically injected via dependency injection) used to load optional custom class definitions
-
-
Method Details
-
getWrappedClasses
Returns the set of classes whose JSON representation should include a root element.These classes are used by MOXy JSON providers to determine which data transfer objects (DTOs) should be wrapped with a root element when serialized.
- Returns:
- an unmodifiable
Setof wrapped classes
-
getUnWrappedClasses
Returns the set of classes whose JSON representation should omit the root element.These classes are used by MOXy JSON providers to determine which data transfer objects (DTOs) should be serialized without a root element in the JSON output.
- Returns:
- an unmodifiable
Setof unwrapped classes
-