Skip to content

Commit

Permalink
Close some gaps to allow using the tryToResolveUnresolved flows
Browse files Browse the repository at this point in the history
There are two ways the resolving can be done:

1)

- override ReadableObjectId and implement tryToResolveUnresolved
- override DefaultDeserializationContext and override
  createReadableObjectId to return your new ReadableObjectID subclasses

2)

- override DefaultDeserializationContext and implement
  tryToResolveUnresolvedObjectId. The code has access to
  the registered resolved using roid.getResolver() and can use
  it to do any necessary handling.
  • Loading branch information
MarSik committed Sep 14, 2015
1 parent d7fa14a commit 33ca823
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Expand Up @@ -118,12 +118,23 @@ public ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> gen, Object
_objectIdResolvers.add(resolver);
}

ReadableObjectId entry = new ReadableObjectId(key);
ReadableObjectId entry = createReadableObjectId(key);
entry.setResolver(resolver);
_objectIds.put(key, entry);
return entry;
}


/**
* Factory method to create a new instance of ReadableObjectId or its
* subclass. It is ment to be overriden when custom ReadableObjectId is
* needed for tryToResolveUnresolvedObjectId.
* @param key The key to associate with the new ReadableObjectId
* @return New ReadableObjectId instance
*/
protected ReadableObjectId createReadableObjectId(IdKey key) {
return new ReadableObjectId(key);
}

@Deprecated // since 2.4
@Override
public ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> gen) {
Expand Down
Expand Up @@ -110,7 +110,16 @@ public boolean tryToResolveUnresolved(DeserializationContext ctxt)
{
return false;
}


/**
* Allow access to the resolver in case anybody wants to use it directly in
* DeserializationContext::tryToResolveUnresolvedObjectId.
* @return The registered resolver
*/
public ObjectIdResolver getResolver() {
return _resolver;
}

@Override
public String toString() {
return String.valueOf(_key);
Expand Down

0 comments on commit 33ca823

Please sign in to comment.