Package org.nuxeo.ecm.core.io.registry
Class MarshallerRegistryImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.core.io.registry.MarshallerRegistryImpl
- All Implemented Interfaces:
MarshallerRegistry
,Adaptable
,Component
,Extensible
,TimestampedService
Implementation of
MarshallerRegistry
.
This implementation is based on MarshallerInspector
class which is able to create marshaller instance and
inject properties. This class also manage marshaller's priorities.
- Since:
- 7.2
-
Field Summary
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Be careful !!!void
deactivate
(ComponentContext context) Deactivates the component.void
deregister
(Class<?> marshaller) Remove a marshaller from the registry.<T> Collection<Marshaller<T>>
getAllMarshallers
(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards) Returns the marshallers, in fact always enrichers, in their reverse priority order.<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> Marshaller<T>
getMarshaller
(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards, boolean forceInstantiation) <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
Makes a marshaller class available.protected boolean
register
(String xp, Descriptor descriptor) protected boolean
unregister
(String xp, Descriptor descriptor) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregisterContribution, unregisterExtension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
XP_MARSHALLERS
- Since:
- 10.3
- See Also:
-
-
Constructor Details
-
MarshallerRegistryImpl
public MarshallerRegistryImpl()
-
-
Method Details
-
deactivate
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
register
- Overrides:
register
in classDefaultComponent
-
unregister
- Overrides:
unregister
in classDefaultComponent
-
register
Description copied from interface:MarshallerRegistry
Makes a marshaller class available.- Specified by:
register
in interfaceMarshallerRegistry
- Parameters:
marshaller
- The marshaller class.
-
deregister
Description copied from interface:MarshallerRegistry
Remove a marshaller from the registry.- Specified by:
deregister
in interfaceMarshallerRegistry
- Parameters:
marshaller
- The marshaller class.
-
getWriter
public <T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype.- Specified by:
getWriter
in interfaceMarshallerRegistry
- 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.
-
getUniqueWriter
public <T> Writer<T> getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides aWriter
instance to manage marshalling of the given Java Type and mimetype. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Specified by:
getUniqueWriter
in interfaceMarshallerRegistry
- 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.
-
getAllWriters
public <T> Collection<Writer<T>> getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides allWriter
instance that manage marshalling of the given Java Type and mimetype.- Specified by:
getAllWriters
in interfaceMarshallerRegistry
- 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.
-
getWriter
public <T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
- Specified by:
getWriter
in interfaceMarshallerRegistry
-
getReader
public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides aReader
instance to manage marshalling of a mimetype in a Java Type.- Specified by:
getReader
in interfaceMarshallerRegistry
- 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.
-
getUniqueReader
public <T> Reader<T> getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides aReader
instance to manage marshalling of a mimetype in a Java Type. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Specified by:
getUniqueReader
in interfaceMarshallerRegistry
- 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.
-
getAllReaders
public <T> Collection<Reader<T>> getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
Provides allReader
instance that manage marshalling of a mimetype in a Java Type.- Specified by:
getAllReaders
in interfaceMarshallerRegistry
- 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.
-
getReader
public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype) Description copied from interface:MarshallerRegistry
- Specified by:
getReader
in interfaceMarshallerRegistry
-
getMarshaller
public <T> Marshaller<T> getMarshaller(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards, boolean forceInstantiation) -
getAllMarshallers
public <T> Collection<Marshaller<T>> getAllMarshallers(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards) Returns the marshallers, in fact always enrichers, in their reverse priority order.The
customs
andwildcards
sets come sorted with higher priorities first, e.g.: [3000, 2000], seeMarshallerInspector.compareTo(MarshallerInspector)
. The enrichers with higher priority need to be processed last, e.g.: [2000, 3000], to make sure they override any enricher with the same name and lower priority, see ExtensibleEntityJsonWriter#write(EntityType entity, JsonGenerator jg). -
getInstance
Description copied from interface:MarshallerRegistry
Provides an instance of a given marshaller class.- Specified by:
getInstance
in interfaceMarshallerRegistry
- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshallerClass
- A valid marshaller instance.- Returns:
- A valid marshaller instance.
-
getUniqueInstance
Description copied from interface:MarshallerRegistry
Provides an instance of the given marshaller class. It creates a new instance even forInstantiations.SINGLETON
marshallers.- Specified by:
getUniqueInstance
in interfaceMarshallerRegistry
- Parameters:
ctx
- The marshalling context (seeRenderingContext
).marshallerClass
- A valid marshaller instance.- Returns:
- A valid marshaller instance.
-
clear
public void clear()Description copied from interface:MarshallerRegistry
Be careful !!! That's deregister all marshallers.- Specified by:
clear
in interfaceMarshallerRegistry
-