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 annotation Setup and inspect every attributes having Inject annotation.

To get a valid marshaller instance :

This class implements Comparable and then handle marshaller priorities rules: look at MarshallerRegistry javadoc to read the rules.

Since:
7.2
  • Constructor Details

    • MarshallerInspector

      public MarshallerInspector(Class<?> clazz)
      Create an inspector for the given class.
      Parameters:
      clazz - The class to analyse and instantiate.
  • Method Details

    • 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 - The RenderingContext to 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 - The RenderingContext to 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:
      compareTo in interface Comparable<MarshallerInspector>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Two MarshallerInspector are equals if their managed clazz are the same.
      Overrides:
      equals in class Object