aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTatu Saloranta <tsaloranta@gmail.com>2012-03-19 19:11:21 -0700
committerTatu Saloranta <tsaloranta@gmail.com>2012-03-19 19:11:21 -0700
commit337feca4a10581197656d497b94cde602c1b16a7 (patch)
tree3d2fe1542ce6f2253d255ef4c2aa2bfabe2cea2e /src/main
parent16d43e3cca1c8bd4c662863f10b8f0eba8379d1f (diff)
downloadjackson-databind-337feca4a10581197656d497b94cde602c1b16a7.tar.gz
Fixed [JACKSON-368]; one of infamous 'failing' cases... (yay!)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/deser/AbstractDeserializer.java22
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java4
-rw-r--r--src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java2
3 files changed, 21 insertions, 7 deletions
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/AbstractDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/AbstractDeserializer.java
index 17ef72762..b663b8069 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/AbstractDeserializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/AbstractDeserializer.java
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.deser;
import java.io.IOException;
+import java.util.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
@@ -22,6 +23,8 @@ public class AbstractDeserializer
protected final JavaType _baseType;
protected final ObjectIdReader _objectIdReader;
+
+ protected final Map<String, SettableBeanProperty> _backRefProperties;
// support for "native" types, which require special care:
@@ -30,11 +33,13 @@ public class AbstractDeserializer
protected final boolean _acceptInt;
protected final boolean _acceptDouble;
- public AbstractDeserializer(JavaType bt, ObjectIdReader oir)
+ public AbstractDeserializer(BeanDeserializerBuilder builder,
+ BeanDescription beanDesc, Map<String, SettableBeanProperty> backRefProps)
{
- _baseType = bt;
- _objectIdReader = oir;
- Class<?> cls = bt.getRawClass();
+ _baseType = beanDesc.getType();
+ _objectIdReader = builder.getObjectIdReader();
+ _backRefProperties = backRefProps;
+ Class<?> cls = _baseType.getRawClass();
_acceptString = cls.isAssignableFrom(String.class);
_acceptBoolean = (cls == Boolean.TYPE) || cls.isAssignableFrom(Boolean.class);
_acceptInt = (cls == Integer.TYPE) || cls.isAssignableFrom(Integer.class);
@@ -60,6 +65,15 @@ public class AbstractDeserializer
return _objectIdReader;
}
+ /**
+ * Method called by <code>BeanDeserializer</code> to resolve back reference
+ * part of managed references.
+ */
+ public SettableBeanProperty findBackReference(String logicalName)
+ {
+ return (_backRefProperties == null) ? null : _backRefProperties.get(logicalName);
+ }
+
/*
/**********************************************************
/* Deserializer implementation
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
index 937124686..7ef28e30c 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
@@ -559,8 +559,8 @@ public abstract class BeanDeserializerBase
}
backProp = ((BeanDeserializerBase) contentDeser).findBackReference(refName);
isContainer = true;
- } else if (valueDeser instanceof AbstractDeserializer) { // [JACKSON-368]: not easy to fix, alas
- throw new IllegalArgumentException("Can not handle managed/back reference for abstract types (property "+_beanType.getRawClass().getName()+"."+prop.getName()+")");
+ } else if (valueDeser instanceof AbstractDeserializer) {
+ backProp = ((AbstractDeserializer) valueDeser).findBackReference(refName);
} else {
throw new IllegalArgumentException("Can not handle managed/back reference '"+refName
+"': type for value deserializer is not BeanDeserializer or ContainerDeserializerBase, but "
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java
index 7366cae95..f794e46b9 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBuilder.java
@@ -342,7 +342,7 @@ public class BeanDeserializerBuilder
*/
public AbstractDeserializer buildAbstract()
{
- return new AbstractDeserializer(_beanDesc.getType(), _objectIdReader);
+ return new AbstractDeserializer(this, _beanDesc, _backRefProperties);
}
/**