from what I see, this consists in:
- renaming @Component to @Role
- detect @Inject instead of @Component in descriptor extractor
- hardcode special Maven objects to "magically" generate ${project} expression
and other Maven objects that can be recognized by their sole type
for Lists and Maps, I don't know if the component injection code in core can
do the expected work, I need to investigate into DefaultMavenPluginManager.
Notice that readonly has to remain for exceptional cases where @Parameter
isn't intended for user configuration
All this should be doable and not so hard to implement.
The only drawback I see is that the new annotations would be more different
from javadoc tags, then need more work for plugin developers to learn.
IMHO, given that annotations will get compiled, we should provide @Component,
but deprecate with instructions to use @Inject: this will give users an easier
transition than direct @Component replacement/removal.
Regards,
Hervé
Le samedi 26 mai 2012 22:06:47 Brett Porter a écrit :
> On 25/05/2012, at 5:23 PM, Brett Porter wrote:
> >> But anything more specific that these needs extension: we're in that case
> >>
> >> Please have a look at [2], with proposed Improvements and comment
> >
> > Agree - but I'd still like to avoid typing both in the 90% of cases where
> > the plugin tools can figure it out for you.
> >
> > I'll see if I can put together an example that covers all the different
> > types...
> What if @Parameter were left as is (@Inject would be optional there), but we
> used the following for the different types of @Component injections:
>
> ===
>
> // inject stuff for Maven - session covers all but should also support
> the same for project, localRepository, reactorProjects, // mojoExecution,
> executedProject, plugin, settings
> @Inject
> private MavenSession session;
>
> // standard injection used for most components
> @Inject
> private IComponent component;
>
> // injection where we need a specific implementation (role-hint)
> @Inject
> @Named("another")
> private IMultiComponent anotherComponent;
>
> // Lookup a Map by its generic type (fine for plugin.xml, might be
> erasure problem at runtime) @Inject
> private Map<String, IMultiComponent> componentsMap;
>
> // Lookup a List by its generic type
> @Inject
> private List<IMultiComponent> componentsList;
>
> // Lookup an array by its type
> @Inject
> private IMultiComponent[] componentsArray;
>
> /// EXCEPTIONAL CASES
>
> // Specify the role, since it is less specific than the concrete class
> we need it to be // NOTE: As you can't have two qualifiers, we move the
> hint back into here for this case // The other alternative is just have
> @Role(clazz) and not make it a @Qualifier, then the hint is always @Named.
> // That may impact how useful it would be at runtime though
> @Inject
> @Role(role = IMultiComponent.class, hint = "another")
> private AnotherComponentImpl specificComponent;
>
> // Lookup a Map by its role
> @Inject
> @Role(role = IMultiComponent.class)
> private Map<String, AbstractMultiComponent> componentsMapByRole;
>
> // Lookup a List by its role
> @Inject
> @Role(role = IMultiComponent.class)
> private List<AbstractMultiComponent> componentsListByRole;
>
> // Lookup an array by its role
> @Inject
> @Role(role = IMultiComponent.class)
> private AbstractMultiComponent[] componentsArrayByRole;
>
> ===
>
> This is for Role:
>
> ====
>
> @Retention(RUNTIME)
> @Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD})
> @Qualifier
> public @interface Role {
> Class<?> role();
>
> String hint() default "default";
> }
>
> ====
>
> WDYT?
>
> Cheers,
> Brett
>
> --
> Brett Porter
> [email protected]
> http://brettporter.wordpress.com/
> http://au.linkedin.com/in/brettporter
> http://twitter.com/brettporter
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]