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 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