Package com.tangosol.coherence.rest.io
Class MarshallerRegistry
java.lang.Object
com.tangosol.coherence.rest.io.MarshallerRegistry
Registry for marshaller instances.
This class allows marshaller lookup based on root object class and media type, and attempts to create new marshallers for a given class and media type combination.
- Author:
- as 2011.07.10
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Marshaller
createDefaultMarshaller
(Class clzRoot, String sMediaType) Create default marshaller for the specified class and media type.protected String
Create a key for the marshallers map.protected Marshaller
createMarshaller
(Class<?> clzRoot, String sMediaType, Class<?> clzMarshaller) Create marshaller instance.getMarshaller
(Class clzRoot, jakarta.ws.rs.core.MediaType mediaType) Return the marshaller for the specified root class and media type.getMarshaller
(Class clzRoot, String sMediaType) Return the marshaller for the specified root class and media type.void
registerMarshaller
(Class clzRoot, jakarta.ws.rs.core.MediaType mediaType, Marshaller marshaller) Register a marshaller for the specified root class and media type.void
registerMarshaller
(Class clzRoot, jakarta.ws.rs.core.MediaType mediaType, Class clzMarshaller) Register a marshaller for the specified root class and media type.void
registerMarshaller
(Class clzRoot, String sMediaType, Marshaller marshaller) Register a marshaller for the specified root class and media type.void
registerMarshaller
(Class clzRoot, String sMediaType, Class clzMarshaller) Register a marshaller for the specified root class and media type.void
setDefaultMarshaller
(jakarta.ws.rs.core.MediaType mediaType, Class clzMarshaller) Configure the default marshaller class for the specified media type.void
setDefaultMarshaller
(String sMediaType, Class clzMarshaller) Configure the default marshaller class for the specified media type.void
setDefaultMarshallers
(Map<String, Class> mapMarshallers) Configure the default marshaller classes for the corresponding media types.
-
Constructor Details
-
MarshallerRegistry
public MarshallerRegistry()Construct a MarshallerRegistry instance.By default, a
JacksonJsonMarshaller
will be used for JSON marshalling and aJaxbXmlMarshaller
for XML marshalling. You can override this behavior by calling thesetDefaultMarshaller(MediaType, Class)
method.
-
-
Method Details
-
getMarshaller
Return the marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classmediaType
- media type- Returns:
- marshaller for the specified root class and media type
-
getMarshaller
Return the marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classsMediaType
- media type- Returns:
- marshaller for the specified root class and media type
-
registerMarshaller
public void registerMarshaller(Class clzRoot, jakarta.ws.rs.core.MediaType mediaType, Class clzMarshaller) Register a marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classmediaType
- media typeclzMarshaller
- marshaller class
-
registerMarshaller
Register a marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classsMediaType
- media typeclzMarshaller
- marshaller class
-
registerMarshaller
public void registerMarshaller(Class clzRoot, jakarta.ws.rs.core.MediaType mediaType, Marshaller marshaller) Register a marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classmediaType
- media typemarshaller
- marshaller to register
-
registerMarshaller
Register a marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classsMediaType
- media typemarshaller
- marshaller to register
-
setDefaultMarshaller
Configure the default marshaller class for the specified media type.- Parameters:
mediaType
- media type to set default marshaller forclzMarshaller
- default marshaller class
-
setDefaultMarshaller
Configure the default marshaller class for the specified media type.- Parameters:
sMediaType
- media type to set default marshaller forclzMarshaller
- default marshaller class
-
setDefaultMarshallers
Configure the default marshaller classes for the corresponding media types.- Parameters:
mapMarshallers
- a map of REST marshaller classes keyed by media type
-
createKey
Create a key for the marshallers map.- Parameters:
clzRoot
- root object classsMediaType
- media type- Returns:
- key for the marshallers cache
-
createDefaultMarshaller
Create default marshaller for the specified class and media type.- Parameters:
clzRoot
- root object classsMediaType
- media type- Returns:
- default marshaller for the specified class and media type
-
createMarshaller
Create marshaller instance.- Parameters:
clzRoot
- root object classsMediaType
- media typeclzMarshaller
- marshaller class- Returns:
- marshaller instance
-