Class MarshallerInspector
- java.lang.Object
-
- org.nuxeo.ecm.core.io.registry.reflect.MarshallerInspector
-
- All Implemented Interfaces:
Comparable<MarshallerInspector>
public class MarshallerInspector extends Object implements Comparable<MarshallerInspector>
Utility class used to instanciate marshallers. This class checks if a marshaller has annotationSetupand inspect every attributes havingInjectannotation.To get a valid marshaller instance :
- Create an inspector for your marshaller class using constructor
MarshallerInspector(Class). This will checks your marshaller has annotationSetupand inspect every attributes havingInjectannotation. - You can check it's a valid marshaller by calling @ #isValid()}
- You can check it's a
Writerby callingisWriter() - You can check it's a
Readerby callingisReader() - You can finally call
getInstance(RenderingContext)to get a valid marshaller instance withRenderingContextand required services injected.
This class implements
Comparableand then handle marshaller priorities rules: look atMarshallerRegistryjavadoc to read the rules.- Since:
- 7.2
-
-
Constructor Summary
Constructors Constructor Description MarshallerInspector(Class<?> clazz)Create an inspector for the given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(MarshallerInspector inspector)booleanequals(Object obj)TwoMarshallerInspectorare equals if their managed clazz are the same.TypegetGenericType()<T> TgetInstance(RenderingContext ctx)Create an instance of this marshaller.InstantiationsgetInstantiations()Class<?>getMarshalledType()ObjectgetNewInstance(RenderingContext ctx, boolean singleton)Create a new instance of the marshaller.IntegergetPriority()List<javax.ws.rs.core.MediaType>getSupports()inthashCode()voidinjectCtx(Object instance, RenderingContext ctx, boolean singleton)Inject the context.voidinjectServices(Object instance)Inject the services.booleanisMarshaller()booleanisReader()booleanisWriter()
-
-
-
Constructor Detail
-
MarshallerInspector
public MarshallerInspector(Class<?> clazz)
Create an inspector for the given class.- Parameters:
clazz- The class to analyse and instantiate.
-
-
Method Detail
-
getInstance
public <T> T getInstance(RenderingContext ctx)
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- TheRenderingContextto inject, if null create an empty context.- Returns:
- An instance of this class.
- Since:
- 7.2
-
getNewInstance
public Object getNewInstance(RenderingContext ctx, boolean singleton)
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- TheRenderingContextto inject.- Returns:
- An instance of the marshaller.
- Since:
- 7.2
-
injectCtx
public void injectCtx(Object instance, RenderingContext ctx, boolean singleton)
Inject the context.
-
injectServices
public void injectServices(Object instance)
Inject the services.
-
getInstantiations
public Instantiations getInstantiations()
-
getPriority
public Integer getPriority()
-
getSupports
public List<javax.ws.rs.core.MediaType> getSupports()
-
getMarshalledType
public Class<?> getMarshalledType()
-
getGenericType
public Type getGenericType()
-
isMarshaller
public boolean isMarshaller()
-
isWriter
public boolean isWriter()
-
isReader
public boolean isReader()
-
compareTo
public int compareTo(MarshallerInspector inspector)
- Specified by:
compareToin interfaceComparable<MarshallerInspector>
-
equals
public boolean equals(Object obj)
TwoMarshallerInspectorare equals if their managed clazz are the same.
-
-