Class MarshallerInspector
java.lang.Object
org.nuxeo.ecm.core.io.registry.reflect.MarshallerInspector
- All Implemented Interfaces:
Comparable<MarshallerInspector>
Utility class used to instanciate marshallers. This class checks if a marshaller has annotation
Setup
and
inspect every attributes having Inject
annotation.
To get a valid marshaller instance :
- Create an inspector for your marshaller class using constructor
MarshallerInspector(Class)
. This will checks your marshaller has annotationSetup
and inspect every attributes havingInject
annotation. - You can check it's a valid marshaller by calling @ #isValid()}
- You can check it's a
Writer
by callingisWriter()
- You can check it's a
Reader
by callingisReader()
- You can finally call
getInstance(RenderingContext)
to get a valid marshaller instance withRenderingContext
and required services injected.
This class implements Comparable
and then handle marshaller priorities rules: look at
MarshallerRegistry
javadoc to read the rules.
- Since:
- 7.2
-
Constructor Summary
ConstructorDescriptionMarshallerInspector
(Class<?> clazz) Create an inspector for the given class. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(MarshallerInspector inspector) boolean
TwoMarshallerInspector
are equals if their managed clazz are the same.<T> T
Create an instance of this marshaller.Class<?>
getNewInstance
(RenderingContext ctx, boolean singleton) Create a new instance of the marshaller.List<javax.ws.rs.core.MediaType>
int
hashCode()
void
injectCtx
(Object instance, RenderingContext ctx, boolean singleton) Inject the context.void
injectServices
(Object instance) Inject the services.boolean
boolean
isReader()
boolean
isWriter()
-
Constructor Details
-
MarshallerInspector
Create an inspector for the given class.- Parameters:
clazz
- The class to analyse and instantiate.
-
-
Method Details
-
getInstance
Create an instance of this marshaller. Depending on the instantiation mode, get the current singleton instance, get a thread local one or create a new one.- Parameters:
ctx
- TheRenderingContext
to inject, if null create an empty context.- Returns:
- An instance of this class.
- Since:
- 7.2
-
getNewInstance
Create a new instance of the marshaller. It injects the required services if the marshaller is not a singleton. If it's a singleton, it prepares the context variables to handle thread localized context. Then it injects the given ctx.- Parameters:
ctx
- TheRenderingContext
to inject.- Returns:
- An instance of the marshaller.
- Since:
- 7.2
-
injectCtx
Inject the context. -
injectServices
Inject the services. -
getInstantiations
-
getPriority
-
getSupports
-
getMarshalledType
-
getGenericType
-
isMarshaller
public boolean isMarshaller() -
isWriter
public boolean isWriter() -
isReader
public boolean isReader() -
compareTo
- Specified by:
compareTo
in interfaceComparable<MarshallerInspector>
-
hashCode
public int hashCode() -
equals
TwoMarshallerInspector
are equals if their managed clazz are the same.
-