org.codehaus.jackson.map.deser
Class BeanDeserializerFactory

java.lang.Object
  extended by org.codehaus.jackson.map.DeserializerFactory
      extended by org.codehaus.jackson.map.deser.BasicDeserializerFactory
          extended by org.codehaus.jackson.map.deser.BeanDeserializerFactory
Direct Known Subclasses:
CustomDeserializerFactory

public class BeanDeserializerFactory
extends BasicDeserializerFactory

Concrete deserializer factory class that adds full Bean deserializer construction logic using class introspection.

Since there is no caching, this factory is stateless and a globally shared singleton instance (instance) can be used by DeserializerProviders).


Field Summary
static BeanDeserializerFactory instance
           
 
Fields inherited from class org.codehaus.jackson.map.deser.BasicDeserializerFactory
_arrayDeserializers, optionalHandlers
 
Constructor Summary
protected BeanDeserializerFactory()
          We will provide default constructor to allow sub-classing, but make it protected so that no non-singleton instances of the class will be instantiated.
 
Method Summary
protected  void _addDeserializerConstructors(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, BeanDeserializer deser, AnnotationIntrospector intr, CreatorContainer creators)
           
protected  void _addDeserializerFactoryMethods(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, BeanDeserializer deser, AnnotationIntrospector intr, CreatorContainer creators)
           
protected  void addBeanProps(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializer deser)
          Method called to figure out settable properties for the bean deserializer to use.
protected  void addDeserializerCreators(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializer deser)
          Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.
protected  void addReferenceProperties(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializer deser)
          Method that will find if bean has any managed- or back-reference properties, and if so add them to bean, to be linked during resolution phase.
 JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc)
          Method that is to actually build a bean deserializer instance.
 JsonDeserializer<Object> buildThrowableDeserializer(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc)
           
protected  SettableAnyProperty constructAnySetter(DeserializationConfig config, AnnotatedMethod am)
          Method called to construct fallback SettableAnyProperty for handling unknown bean properties, given a method that has been designated as such setter.
protected  BeanDeserializer constructBeanDeserializerInstance(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc)
          Method for construcing "empty" deserializer: overridable to allow sub-classing of BeanDeserializer.
protected  SettableBeanProperty constructSettableProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedField field)
           
protected  SettableBeanProperty constructSettableProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedMethod setter)
          Method that will construct a regular bean property setter using the given setter method.
protected  SettableBeanProperty constructSetterlessProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedMethod getter)
          Method that will construct a regular bean property setter using the given setter method.
protected  ThrowableDeserializer constructThrowableDeserializerInstance(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc)
           
 JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config, JavaType type, DeserializerProvider p)
          Method that DeserializerProviders call to create a new deserializer for types other than Collections, Maps, arrays and enums.
protected  boolean isPotentialBeanType(Class<?> type)
          Helper method used to skip processing for types that we know can not be (i.e.
 
Methods inherited from class org.codehaus.jackson.map.deser.BasicDeserializerFactory
constructCreatorProperty, constructEnumResolver, createArrayDeserializer, createCollectionDeserializer, createEnumDeserializer, createMapDeserializer, createTreeDeserializer, findDeserializerFromAnnotation, findPropertyContentTypeDeserializer, findPropertyTypeDeserializer, findTypeDeserializer, modifyTypeByAnnotation, resolveType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final BeanDeserializerFactory instance
Constructor Detail

BeanDeserializerFactory

protected BeanDeserializerFactory()
We will provide default constructor to allow sub-classing, but make it protected so that no non-singleton instances of the class will be instantiated.

Method Detail

createBeanDeserializer

public JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config,
                                                       JavaType type,
                                                       DeserializerProvider p)
                                                throws JsonMappingException
Method that DeserializerProviders call to create a new deserializer for types other than Collections, Maps, arrays and enums.

Overrides:
createBeanDeserializer in class BasicDeserializerFactory
type - Type to be deserialized
p - Provider that can be called to create deserializers for contained member types
Throws:
JsonMappingException

buildBeanDeserializer

public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig config,
                                                      JavaType type,
                                                      BasicBeanDescription beanDesc)
                                               throws JsonMappingException
Method that is to actually build a bean deserializer instance. All basic sanity checks have been done to know that what we have may be a valid bean type, and that there are no default simple deserializers.

Throws:
JsonMappingException

buildThrowableDeserializer

public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationConfig config,
                                                           JavaType type,
                                                           BasicBeanDescription beanDesc)
                                                    throws JsonMappingException
Throws:
JsonMappingException

constructBeanDeserializerInstance

protected BeanDeserializer constructBeanDeserializerInstance(DeserializationConfig config,
                                                             JavaType type,
                                                             BasicBeanDescription beanDesc)
Method for construcing "empty" deserializer: overridable to allow sub-classing of BeanDeserializer.


constructThrowableDeserializerInstance

protected ThrowableDeserializer constructThrowableDeserializerInstance(DeserializationConfig config,
                                                                       JavaType type,
                                                                       BasicBeanDescription beanDesc)

addDeserializerCreators

protected void addDeserializerCreators(DeserializationConfig config,
                                       BasicBeanDescription beanDesc,
                                       BeanDeserializer deser)
                                throws JsonMappingException
Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.

Throws:
JsonMappingException

_addDeserializerConstructors

protected void _addDeserializerConstructors(DeserializationConfig config,
                                            BasicBeanDescription beanDesc,
                                            VisibilityChecker<?> vchecker,
                                            BeanDeserializer deser,
                                            AnnotationIntrospector intr,
                                            CreatorContainer creators)
                                     throws JsonMappingException
Throws:
JsonMappingException

_addDeserializerFactoryMethods

protected void _addDeserializerFactoryMethods(DeserializationConfig config,
                                              BasicBeanDescription beanDesc,
                                              VisibilityChecker<?> vchecker,
                                              BeanDeserializer deser,
                                              AnnotationIntrospector intr,
                                              CreatorContainer creators)
                                       throws JsonMappingException
Throws:
JsonMappingException

addBeanProps

protected void addBeanProps(DeserializationConfig config,
                            BasicBeanDescription beanDesc,
                            BeanDeserializer deser)
                     throws JsonMappingException
Method called to figure out settable properties for the bean deserializer to use.

Note: designed to be overridable, and effort is made to keep interface similar between versions.

Throws:
JsonMappingException

addReferenceProperties

protected void addReferenceProperties(DeserializationConfig config,
                                      BasicBeanDescription beanDesc,
                                      BeanDeserializer deser)
                               throws JsonMappingException
Method that will find if bean has any managed- or back-reference properties, and if so add them to bean, to be linked during resolution phase.

Throws:
JsonMappingException
Since:
1.6

constructAnySetter

protected SettableAnyProperty constructAnySetter(DeserializationConfig config,
                                                 AnnotatedMethod am)
                                          throws JsonMappingException
Method called to construct fallback SettableAnyProperty for handling unknown bean properties, given a method that has been designated as such setter.

Throws:
JsonMappingException

constructSettableProperty

protected SettableBeanProperty constructSettableProperty(DeserializationConfig config,
                                                         BasicBeanDescription beanDesc,
                                                         String name,
                                                         AnnotatedMethod setter)
                                                  throws JsonMappingException
Method that will construct a regular bean property setter using the given setter method.

Parameters:
setter - Method to use to set property value; or null if none. Null only for "setterless" properties
Returns:
Property constructed, if any; or null to indicate that there should be no property based on given definitions.
Throws:
JsonMappingException

constructSettableProperty

protected SettableBeanProperty constructSettableProperty(DeserializationConfig config,
                                                         BasicBeanDescription beanDesc,
                                                         String name,
                                                         AnnotatedField field)
                                                  throws JsonMappingException
Throws:
JsonMappingException

constructSetterlessProperty

protected SettableBeanProperty constructSetterlessProperty(DeserializationConfig config,
                                                           BasicBeanDescription beanDesc,
                                                           String name,
                                                           AnnotatedMethod getter)
                                                    throws JsonMappingException
Method that will construct a regular bean property setter using the given setter method.

Parameters:
getter - Method to use to get property value to modify, null if none. Non-null for "setterless" properties.
Throws:
JsonMappingException

isPotentialBeanType

protected boolean isPotentialBeanType(Class<?> type)
Helper method used to skip processing for types that we know can not be (i.e. are never consider to be) beans: things like primitives, Arrays, Enums, and proxy types.

Note that usually we shouldn't really be getting these sort of types anyway; but better safe than sorry.