Hi,
On Thu, Mar 12, 2015 at 12:03 PM, vincent(a)massol.net
wrote:
Hi Edy,
On 12 Mar 2015 at 10:49:29, Eduard Moraru (enygma2002(a)gmail.com(mailto:
enygma2002(a)gmail.com)) wrote:
Hi,
As it's documentation [1] mentions, the usage of the @Priority annotation
should be defined by the classes it is used on:
"The effect of using the Priority annotation in any particular instance
is
defined by other specifications that define the
use of a specific class.
For example, the Interceptors specification defines the use of priorities
on interceptors to control the order in which interceptors are called."
Therefore, I suggest we use the @Priority annotation on components that
need it and that like to specify the order in which they are *used* (i.e.
perform their main task).
so what you’re suggesting is that:
@Component
@Name(“content”)
@Priority(1000)
public class ContentMacro implement Macro
has a different meaning than:
@Component
@Named(“XWiki.WatchListJobClass")
@Priority(1000)
public class WatchListJobClassDocumentInitializer ...
because one if a Macro and the other one is a Document Initializer
right?
...and because they clearly express it, in their documentations, that they
accept some annotations and they define how those annotations will be
interpreted. Basically, the purpose of the javax.annotations package.
(BTW note that this wouldn’t work if in the
future we start supporting
several roles per component impl.)
So it means that people reading the code need to understand that even
though it’s the same annotation, it’ll have a different meaning.
Compare this to:
@Component
@Name(“content”)
@MacroPriority(1000)
I don`t find this better since it does not tell me what the macro does with
that priority. @MacroExcutionPriority would have been clear, if that is
what we pursue.
public class ContentMacro implement Macro
and
@Component
@Named(“XWiki.WatchListJobClass")
@DocumentInitializerPriority(1000)
public class WatchListJobClassDocumentInitializer ...
IMO the second one is more clear in its intent. WDYT?
Honestly, I am not a big fan of annotations, specially in Java, and I try
to keep them to a minimal as much as possible. It feels like a shortcut
that leads to a dead end. They are not code, but configuration and, as
such, modifying configuration should not require recompiling the code.
Back to our particular discussion, AFAIK, we are not doing multiple roles
per implementation. That, indeed, would probably not work with the javax
Priority annotation due to lack of specificity.
I do see the advantages of typed annotations, but also the need to be aware
of more and more annotations, as they come, when our usecase is pretty
simple and would be well satisfied by the javax Priority one. That is the
main reason why I looked for a more generic solution instead of just making
a new annotation for the document initializer use case. I find it uselessly
polluting.
I`d love to hear more opinions on this :)
For your love, here's another opinion.
1. I spent a while looking for javax.annotations.Priority, since I
didn't see it at
... Turns out it's a JEE class that's not in JSE. AFAIK, we're not
really using JEE yet, just JSE with a few JEE modules. Am I wrong? If
not, do we want to require JEE from now on, or is that annotation
available in a Maven Central library that doesn't bring in the whole JEE?