On 03/10/2010 02:48 PM, Vincent Massol wrote:
Hi,
I'd like to change for EntityReferenceResolver from:
EntityReference resolve(T entityReferenceRepresentation, EntityType type);
to
EntityReference resolve(T entityReferenceRepresentation, EntityType type, Object...
parameters);
And for EntityReferenceSerializer, from:
T serialize(EntityReference reference);
to
T serialize(EntityReference reference, Object... parameters);
The rationale is that we need a new resolver that can normalize an EntityReference
against a fixed EntityReference. Right now to implement this we need to use the execution
context and modify it to modify the current doc to have that ref, do the resolving and
then restore the context. It's complex and requires extra work:
private<T> DocumentReference resolveReference(T referenceToResolve,
DocumentReferenceResolver<T> resolver,
DocumentReference defaultReference)
{
XWikiContext xcontext = getXWikiContext();
String originalWikiName = xcontext.getDatabase();
XWikiDocument originalCurentDocument = xcontext.getDoc();
try {
xcontext.setDatabase(defaultReference.getWikiReference().getName());
xcontext.setDoc(new XWikiDocument(defaultReference));
return resolver.resolve(referenceToResolve);
} finally {
xcontext.setDoc(originalCurentDocument);
xcontext.setDatabase(originalWikiName);
}
}
So I'd like to write a new resolver that would be used like this:
docResolver.resolve(refToNormalize, defaultReference)
Notes:
1) **IMPORTANT**: Note that this could break backward compat for anyone who's done
implementations based on Resolver/Serializer APIs but I still think it's ok to go with
it in
2) I'd need this for XE 2.2.2 since I need this new resolver. I could hack it and
continue using the code above though and only make the change in 2.3 (trunk).
Here's my +1
+1
Users of these methods should not be affected, only implementations.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/