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
public class MarshallerRegistryImpl extends DefaultComponent implements MarshallerRegistry
Implementation ofMarshallerRegistry.This implementation is based on
MarshallerInspectorclass which is able to create marshaller instance and inject properties. This class also manage marshaller's priorities.- Since:
- 7.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringXP_MARSHALLERS-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description MarshallerRegistryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Be careful !!! That's deregister all marshallers.voiddeactivate(ComponentContext context)Deactivates the component.voidderegister(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 allReaderinstance 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 allWriterinstance that manage marshalling of the given Java Type and mimetype.<T> TgetInstance(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 aReaderinstance 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> TgetUniqueInstance(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 aReaderinstance 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 aWriterinstance 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 aWriterinstance 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)voidregister(Class<?> marshaller)Makes a marshaller class available.protected booleanregister(String xp, Descriptor descriptor)protected booleanunregister(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
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
XP_MARSHALLERS
public static final String XP_MARSHALLERS
- Since:
- 10.3
- See Also:
- Constant Field Values
-
-
Method Detail
-
deactivate
public void deactivate(ComponentContext context)
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
register
protected boolean register(String xp, Descriptor descriptor)
- Overrides:
registerin classDefaultComponent
-
unregister
protected boolean unregister(String xp, Descriptor descriptor)
- Overrides:
unregisterin classDefaultComponent
-
register
public void register(Class<?> marshaller)
Description copied from interface:MarshallerRegistryMakes a marshaller class available.- Specified by:
registerin interfaceMarshallerRegistry- Parameters:
marshaller- The marshaller class.
-
deregister
public void deregister(Class<?> marshaller)
Description copied from interface:MarshallerRegistryRemove a marshaller from the registry.- Specified by:
deregisterin 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:MarshallerRegistryProvides aWriterinstance to manage marshalling of the given Java Type and mimetype.- Specified by:
getWriterin 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
Writerinstance.
-
getUniqueWriter
public <T> Writer<T> getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistryProvides aWriterinstance to manage marshalling of the given Java Type and mimetype. It creates a new instance even forInstantiations.SINGLETONmarshallers.- Specified by:
getUniqueWriterin 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
Writerinstance.
-
getAllWriters
public <T> Collection<Writer<T>> getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistryProvides allWriterinstance that manage marshalling of the given Java Type and mimetype.- Specified by:
getAllWritersin 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
Writerinstance.
-
getWriter
public <T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistry- Specified by:
getWriterin interfaceMarshallerRegistry
-
getReader
public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistryProvides aReaderinstance to manage marshalling of a mimetype in a Java Type.- Specified by:
getReaderin 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
Readerinstance.
-
getUniqueReader
public <T> Reader<T> getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistryProvides aReaderinstance to manage marshalling of a mimetype in a Java Type. It creates a new instance even forInstantiations.SINGLETONmarshallers.- Specified by:
getUniqueReaderin 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
Readerinstance.
-
getAllReaders
public <T> Collection<Reader<T>> getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistryProvides allReaderinstance that manage marshalling of a mimetype in a Java Type.- Specified by:
getAllReadersin 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
Readerinstance.
-
getReader
public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
Description copied from interface:MarshallerRegistry- Specified by:
getReaderin 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
customsandwildcardssets 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
public <T> T getInstance(RenderingContext ctx, Class<T> marshallerClass)
Description copied from interface:MarshallerRegistryProvides an instance of a given marshaller class.- Specified by:
getInstancein interfaceMarshallerRegistry- Parameters:
ctx- The marshalling context (seeRenderingContext).marshallerClass- A valid marshaller instance.- Returns:
- A valid marshaller instance.
-
getUniqueInstance
public <T> T getUniqueInstance(RenderingContext ctx, Class<T> marshallerClass)
Description copied from interface:MarshallerRegistryProvides an instance of the given marshaller class. It creates a new instance even forInstantiations.SINGLETONmarshallers.- Specified by:
getUniqueInstancein 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:MarshallerRegistryBe careful !!! That's deregister all marshallers.- Specified by:
clearin interfaceMarshallerRegistry
-
-