JSR-330 knows the @Qualifier meta annotation. (@Named is a @Qualifier itself)
Thus it would be perfectly possible to create a @Role Qualifier: @Qualifier public @interface @Role { value(); hint() default ""; } Note: the role is usually the Interface, thus we do not need it in most cases as JSR-330/299 are typesafe anyway. Only if we inject into Object.class or a shared common interface. and write something like: @Inject @Role(hint="git") private ScmProvider gitScm; LieGrue, strub ----- Original Message ----- > From: John Casey <jdca...@commonjava.org> > To: Maven Developers List <dev@maven.apache.org> > Cc: > Sent: Monday, May 21, 2012 10:30 PM > Subject: Re: Maven Plugins annotations support @Component role attribute to > Class<?> > > On 5/21/12 7:03 AM, Olivier Lamy wrote: >> 2012/5/21 Brett Porter<br...@apache.org>: >>> >>> On 21/05/2012, at 3:45 AM, Hervé BOUTEMY wrote: >>> >>>> here, the end-user is a plugin developer, then someone who should > be able to >>>> create a (Plexus) component when necessary >>>> >>>> Yes, I liked @Component too but as soon as you write a component > and inject >>>> somponents inside it, you discover the discrepency: the more I work > on this, >>>> the more I discover these little discrepencies that lost me for a > long time. >>>> Notice that the target is JSR330 @Inject. >>>> Is it too early to use @Inject? >>> >>> Agree - I didn't think @component (the Javadoc annotation) would > carry over to the plugin annotation. It should just use @Inject if that's > feasible. >> Yup possible >> @Inject >> @Named( value = "maven" ) >> protected ArtifactMetadataSource artifactMetadataSource; > > What do we do about: > > protected Map<Wagon> wagons; > > In the old setup, IIRC we used something like: > > @component role=org.apache.maven.wagon.Wagon ... > > If we were to use a CDI approach, we'd need a provider to compose the > Map instance, right? That, or we'd need to use Instance<Wagon>, unless > > I'm just too much of a newbie to know better... > > In any case, what about the other collection-oriented attributes of > @component? Don't we have a hints= attribute, or am I confusing all of > this with the Plexus @Requirement stuff? > >> >> But not possible anymore for >> @Component( role = ArtifactMetadataSource.class, roleHint = > "maven" ) >> protected Object artifactMetadataSource; >> >> but not sure it's a real problem for this "feature" :-) >> >> But again we use annotations here only for plugin metadata generation >> and not at runtime. >> >> Maybe in the future we could handle @Inject at runtime level. >> >> But IMHO classpath scanning at runtime to find various annotations >> will have a huge performance impact whereas simply reading the xml >> plugin descriptor is fast. >> And that's what we need with a tool such Maven fast startup/execution. >> >> my 0.02 euros >> >>> >>> - Brett >>> >>> -- >>> Brett Porter >>> br...@apache.org >>> http://brettporter.wordpress.com/ >>> http://au.linkedin.com/in/brettporter >>> http://twitter.com/brettporter >>> >>> >>> >>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org >>> For additional commands, e-mail: dev-h...@maven.apache.org >>> >> >> >> > > > -- > John Casey > Developer, PMC Chair - Apache Maven (http://maven.apache.org) > Blog: http://www.johnofalltrades.name/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org > For additional commands, e-mail: dev-h...@maven.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org