On Thu, Mar 12, 2015 at 11:45 AM, vincent(a)massol.net <vincent(a)massol.net> wrote:
On 12 Mar 2015 at 10:30:50, Marius Dumitru Florea
(mariusdumitru.florea@xwiki.com(mailto:mariusdumitru.florea@xwiki.com)) wrote:
On Thu, Mar 12, 2015 at 10:41 AM,
vincent(a)massol.net wrote:
Hi devs,
As part of
http://jira.xwiki.org/browse/XWIKI-11905, Edy has started using the Java
@Priority annotation.
This seems very good and I personally didn’t know about this annotation before (maybe
it’s been introduced not that long ago?). So for me it raises the question of: do we want
to use this annotation more and how does it compare with what we’ve done so far.
I can think of a few places that could have used it:
* Macros.get/setPriority(). It should be possible to add support for @Priority and modify
MacroTransformation to use that annotation.
* Transformations. We have a jira issue opened for adding support for Priority in
Transformation’s executions (in TransformationManager).
* @DisposePriority (used by ECM).
* TranslationBundle.get/setPriority()
* … and probably some other places…
However, I think there’s a namespacing problem. For example imagine that we code a Macro
and set @Priority on that Macro component. The ECM could interpret it as a dispose
priority while the MacroTransformation could interpret it as an execution priority…
Globally I think that use an annotation for expressing priority is great and much better
than what we’ve done in the past with get/setPriority() methods. It’s better because
priority is not a business concept and we’re polluting the business interface with it.
Now, in order to fix the namespacing issue, I
think that the best solution is that each module requiring some priority should introduce
its own annotation and should NOT depend on the @Priority one from the JDK (i.e. we ban
the usage of it).
We could also define a generic Priority annotation that has a role
(namespace) besides the value.
@Priority(role = org.xwiki.rendering.macro.Macro.class, value = 210)
Yes, I thought about it too, but discarded it because it’s less nice than having a
strongly typed annotation IMO.
The advantage I see is that we can write a
generic component to
retrieve the instance list sorted by priority, for a given role.
Retrieving a given annotation is a one liner in java
so it’s not really an issue.
Thanks
-Vincent
Thanks,
Marius
>
> WDYT?
>
> Thanks
> -Vincent
>
>
> W
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs