Package org.nuxeo.ecm.core.io.registry
Interface MarshallerRegistry
-
- All Known Implementing Classes:
MarshallerRegistryImpl
public interface MarshallerRegistry
Service to get specialize marshaller.This service provides an extension point to register/deregister marshallers.
<extension target="org.nuxeo.ecm.core.io.MarshallerRegistry" point="marshallers"> <register class="org.nuxeo.ecm.core.io.marshallers.json.validation.ConstraintWriter" enable="true" /> <register class="org.nuxeo.ecm.core.io.marshallers.json.validation.DocumentValidationReportWriter" enable="true" /> </extension>
You can also register/deregister your marshaller programmatically by calling
register(Class)
andderegister(Class)
.All marshallers are provided with injected properties.
You can get a
Writer
using:getWriter(RenderingContext, Class, MediaType)
AWriter
which manage the given class and mimetypegetWriter(RenderingContext, Class, Type, MediaType)
AWriter
which manage the given class and mimetype, plus the checks the given generic type.getAllWriters(RenderingContext, Class, Type, MediaType)
AllWriter
which manage the given class and mimetype, plus the checks the given generic type.getInstance(RenderingContext, Class)
An instance of the givenWriter
class.
You can get a
Reader
using:getReader(RenderingContext, Class, MediaType)
AReader
which manage the given class and mimetypegetReader(RenderingContext, Class, Type, MediaType)
AReader
which manage the given class and mimetype, plus the checks the given generic type.getAllReaders(RenderingContext, Class, Type, MediaType)
AllReader
which manage the given class and mimetype, plus the checks the given generic type.getInstance(RenderingContext, Class)
An instance of the givenReader
class.
If several marshaller matches a demand of the single instance, the registry use the following rules to choose one:
- The marshaller with the greatest priority is choosen.
- Then, Less instance is better:
Instantiations.SINGLETON
are preferred toInstantiations.PER_THREAD
toInstantiations.EACH_TIME
- Then, Expert is better: A marshaller which manage a subclass is prefered.
- Then, references works: A subclass of an existing marshaller is not choosen. You have to specify an higher priority.
- Since:
- 7.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Be careful !!! That's deregister all marshallers.void
deregister(Class<?> marshaller)
Remove a marshaller from the registry.<T> Collection<Reader<T>>
getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides allReader
instance that manage marshalling of a mimetype in a Java Type.<T> Collection<Writer<T>>
getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides allWriter
instance that manage marshalling of the given Java Type and mimetype.<T> T
getInstance(RenderingContext ctx, Class<T> marshallerClass)
Provides an instance of a given marshaller class.<T> Reader<T>
getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aReader
instance to manage marshalling of a mimetype in a Java Type.<T> Reader<T>
getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
<T> T
getUniqueInstance(RenderingContext ctx, Class<T> marshallerClass)
Provides an instance of the given marshaller class.<T> Reader<T>
getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aReader
instance to manage marshalling of a mimetype in a Java Type.<T> Writer<T>
getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype.<T> Writer<T>
getWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype.<T> Writer<T>
getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
void
register(Class<?> marshaller)
Makes a marshaller class available.
-
-
-
Method Detail
-
clear
void clear()
Be careful !!! That's deregister all marshallers.- Since:
- 7.2
-
register
void register(Class<?> marshaller) throws MarshallingException
Makes a marshaller class available.- Parameters:
marshaller
- The marshaller class.- Throws:
MarshallingException
- If marshaller class is null or if it's not a valid marshaller.- Since:
- 7.2
-
deregister
void deregister(Class<?> marshaller) throws MarshallingException
Remove a marshaller from the registry.- Parameters:
marshaller
- The marshaller class.- Throws:
MarshallingException
- If marshaller class is null or if it's not a valid marshaller.- Since:
- 7.2
-
getWriter
<T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A valid
Writer
instance. - Since:
- 7.2
-
getUniqueWriter
<T> Writer<T> getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A valid
Writer
instance. - Since:
- 7.2
-
getAllWriters
<T> Collection<Writer<T>> getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides allWriter
instance that manage marshalling of the given Java Type and mimetype.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A list of valid
Writer
instance. - Since:
- 7.2
-
getWriter
<T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
-
getReader
<T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aReader
instance to manage marshalling of a mimetype in a Java Type.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A valid
Reader
instance. - Since:
- 7.2
-
getUniqueReader
<T> Reader<T> getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides aReader
instance to manage marshalling of a mimetype in a Java Type. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A valid
Reader
instance. - Since:
- 7.2
-
getAllReaders
<T> Collection<Reader<T>> getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Provides allReader
instance that manage marshalling of a mimetype in a Java Type.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.- Returns:
- A list of valid
Reader
instance. - Since:
- 7.2
-
getReader
<T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
-
getInstance
<T> T getInstance(RenderingContext ctx, Class<T> marshallerClass)
Provides an instance of a given marshaller class.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshallerClass
- A valid marshaller instance.- Returns:
- A valid marshaller instance.
- Since:
- 7.2
-
getUniqueInstance
<T> T getUniqueInstance(RenderingContext ctx, Class<T> marshallerClass)
Provides an instance of the given marshaller class. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshallerClass
- A valid marshaller instance.- Returns:
- A valid marshaller instance.
- Since:
- 7.2
-
-