+1 for 2.2 (wow, 2 in a single day) :)
I am probably the only one affected today.
I would really welcome this change since it will allow me to simplify my
implementation as well.
I am glad to see that what I have evoked previously became finally useful
for the core, that was my initial feeling.
My own implementation was not a component and the parameter was passed to
the constructor. This has the advantage to build the resolver as a local
property and resolve many times using the same arguments. However, this does
not fit for a singleton component.
Denis
On Wed, Mar 10, 2010 at 15:02, Thomas Mortagne <thomas.mortagne(a)xwiki.com>wrote;wrote:
On Wed, Mar 10, 2010 at 14:59, Sergiu Dumitriu
<sergiu(a)xwiki.com> wrote:
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
+1
Users of these methods should not be affected, only implementations.
Well not affect if they recompile but i think at runtime it would fail
because it's not the same method signature.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs