+1
On Thu, Apr 8, 2010 at 14:21, Vincent Massol <vincent(a)massol.net> wrote:
Hi devs,
Since the JSR330 is now accepted as final and thus as a standard, I'd like to propose
that we modify our component annotations to use it.
Rationale
========
The advantages of using it are:
* Be standard, ie:
** Our components will be able to be re-used by injectors other than ours (Guice for
example)
** Since IDEs will support JSR330 they'll be able to offer features for our code
(auto complete, graph, etc), for ex
http://blogs.jetbrains.com/idea/tag/dependency-injection/
Proposed Changes
===============
Note: JSR330 doesn't specify how components should be bound, hence the need to keep
xwiki-specific metadata for the bindings.
* @Component and @ComponentRole stay unchanged
* Deprecate @Requirement, replaced by @Inject
* Use @Named or application-specific annotations (based on @Qualifier) instead of hints
specified in the @Requirement annotation
* Add new @Role(Class) to specify a dependency role in the case of collections (since
generics are not available using reflection in Java)
* Deprecate @InstantiationStrategy, replaced by @Singleton. We don't need to
introduce any other scope annotations for now.
* Note that the default scope in the JSR330 spec is "per lookup". Since our
default is singleton, we'll need to add @Singleton annotations everywhere we used to
not have anything.
Example before:
@Component("html")
public class HTMLMacro extends AbstractMacro<HTMLMacroParameters>
{
...
@Requirement
private HTMLCleaner htmlCleaner;
...
@Requirement("xhtmlmacro/1.0")
private PrintRendererFactory xhtmlRendererFactory;
...
Same example after the change:
@Component("html")
public class HTMLMacro extends AbstractMacro<HTMLMacroParameters>
{
...
@Inject
private HTMLCleaner htmlCleaner;
...
@Inject
@Named("xhtmlmacro/1.0")
private PrintRendererFactory xhtmlRendererFactory;
...
WDYT?
Thanks
-Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs