public interface MarshallerRegistry
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)
and
deregister(Class)
.
All marshallers are provided with injected properties.
You can get a Writer
using:
getWriter(RenderingContext, Class, MediaType)
A Writer
which manage the given class and mimetype
getWriter(RenderingContext, Class, Type, MediaType)
A Writer
which manage the given class and
mimetype, plus the checks the given generic type.getAllWriters(RenderingContext, Class, Type, MediaType)
All Writer
which manage the given class
and mimetype, plus the checks the given generic type.getInstance(RenderingContext, Class)
An instance of the given Writer
class.
You can get a Reader
using:
getReader(RenderingContext, Class, MediaType)
A Reader
which manage the given class and mimetype
getReader(RenderingContext, Class, Type, MediaType)
A Reader
which manage the given class and
mimetype, plus the checks the given generic type.getAllReaders(RenderingContext, Class, Type, MediaType)
All Reader
which manage the given class
and mimetype, plus the checks the given generic type.getInstance(RenderingContext, Class)
An instance of the given Reader
class.If several marshaller matches a demand of the single instance, the registry use the following rules to choose one:
Instantiations.SINGLETON
are preferred to
Instantiations.PER_THREAD
to Instantiations.EACH_TIME
Modifier and Type | Method and 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 all
Reader 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 all
Writer 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,
javax.ws.rs.core.MediaType mediatype)
|
<T> Reader<T> |
getReader(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Reader instance to manage marshalling of a mimetype in a Java Type. |
<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 a
Reader 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 a
Writer 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)
|
<T> Writer<T> |
getWriter(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Writer instance to manage marshalling of the given Java Type and mimetype. |
void |
register(Class<?> marshaller)
Makes a marshaller class available.
|
void clear()
void register(Class<?> marshaller) throws MarshallingException
marshaller
- The marshaller class.MarshallingException
- If marshaller class is null or if it's not a valid marshaller.void deregister(Class<?> marshaller) throws MarshallingException
marshaller
- The marshaller class.MarshallingException
- If marshaller class is null or if it's not a valid marshaller.<T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Writer
instance to manage marshalling of the given Java Type and mimetype.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.<T> Writer<T> getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Writer
instance to manage marshalling of the given Java Type and mimetype. It creates a new
instance even for Instantiations.SINGLETON
marshallers.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.<T> Collection<Writer<T>> getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Writer
instance that manage marshalling of the given Java Type and mimetype.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.<T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
<T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Reader
instance to manage marshalling of a mimetype in a Java Type.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.<T> Reader<T> getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Reader
instance to manage marshalling of a mimetype in a Java Type. It creates a new instance
even for Instantiations.SINGLETON
marshallers.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.<T> Collection<Reader<T>> getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Reader
instance that manage marshalling of a mimetype in a Java Type.ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.<T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
<T> T getInstance(RenderingContext ctx, Class<T> marshallerClass)
ctx
- The marshalling context (see RenderingContext
).marshallerClass
- A valid marshaller instance.<T> T getUniqueInstance(RenderingContext ctx, Class<T> marshallerClass)
Instantiations.SINGLETON
marshallers.ctx
- The marshalling context (see RenderingContext
).marshallerClass
- A valid marshaller instance.Copyright © 2018 Nuxeo. All rights reserved.