Package com.tangosol.coherence.rest.io
Class MarshallerRegistry
- java.lang.Object
-
- com.tangosol.coherence.rest.io.MarshallerRegistry
-
public class MarshallerRegistry extends Object
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
Constructors Constructor Description MarshallerRegistry()
Construct a MarshallerRegistry instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Marshaller
createDefaultMarshaller(Class clzRoot, String sMediaType)
Create default marshaller for the specified class and media type.protected String
createKey(Class clzRoot, String sMediaType)
Create a key for the marshallers map.protected Marshaller
createMarshaller(Class<?> clzRoot, String sMediaType, Class<?> clzMarshaller)
Create marshaller instance.Marshaller
getMarshaller(Class clzRoot, String sMediaType)
Return the marshaller for the specified root class and media type.Marshaller
getMarshaller(Class clzRoot, javax.ws.rs.core.MediaType mediaType)
Return the 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
registerMarshaller(Class clzRoot, javax.ws.rs.core.MediaType mediaType, Marshaller marshaller)
Register a marshaller for the specified root class and media type.void
registerMarshaller(Class clzRoot, javax.ws.rs.core.MediaType mediaType, Class clzMarshaller)
Register a marshaller for the specified root class and media type.void
setDefaultMarshaller(String sMediaType, Class clzMarshaller)
Configure the default marshaller class for the specified media type.void
setDefaultMarshaller(javax.ws.rs.core.MediaType mediaType, 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 Detail
-
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 Detail
-
getMarshaller
public Marshaller getMarshaller(Class clzRoot, javax.ws.rs.core.MediaType mediaType)
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
public Marshaller getMarshaller(Class clzRoot, String sMediaType)
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, javax.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
public void registerMarshaller(Class clzRoot, String sMediaType, Class clzMarshaller)
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, javax.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
public void registerMarshaller(Class clzRoot, String sMediaType, Marshaller marshaller)
Register a marshaller for the specified root class and media type.- Parameters:
clzRoot
- root object classsMediaType
- media typemarshaller
- marshaller to register
-
setDefaultMarshaller
public void setDefaultMarshaller(javax.ws.rs.core.MediaType mediaType, Class clzMarshaller)
Configure the default marshaller class for the specified media type.- Parameters:
mediaType
- media type to set default marshaller forclzMarshaller
- default marshaller class
-
setDefaultMarshaller
public void setDefaultMarshaller(String sMediaType, Class clzMarshaller)
Configure the default marshaller class for the specified media type.- Parameters:
sMediaType
- media type to set default marshaller forclzMarshaller
- default marshaller class
-
setDefaultMarshallers
public void setDefaultMarshallers(Map<String,Class> mapMarshallers)
Configure the default marshaller classes for the corresponding media types.- Parameters:
mapMarshallers
- a map of REST marshaller classes keyed by media type
-
createKey
protected String createKey(Class clzRoot, String sMediaType)
Create a key for the marshallers map.- Parameters:
clzRoot
- root object classsMediaType
- media type- Returns:
- key for the marshallers cache
-
createDefaultMarshaller
protected Marshaller createDefaultMarshaller(Class clzRoot, String sMediaType)
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
protected Marshaller createMarshaller(Class<?> clzRoot, String sMediaType, Class<?> clzMarshaller)
Create marshaller instance.- Parameters:
clzRoot
- root object classsMediaType
- media typeclzMarshaller
- marshaller class- Returns:
- marshaller instance
-
-