So basically it is still the same issue as a week or so ago: how to select a different implementation for an interface.
Doing this within your code:
AFAIK that's not possible, and I wonder if even JSR330 supports it.

If you don't specify a specific hint (or name), the default implementation will be used.
If you want a specific implementation, you need to specify it.

With Plexus this is possible:

@Requirement
private Map<String,SomeService> serviceMap;

this will give you all the available SomeServices, where the key maps to the hint.
Now you can easily pick the preferred instance.

Back to why you want this: You want another ArchetypeGenerationQueryer. This means that on the places where this is injected, you don't want the default instance, but instead a Map, so you can select one. A pull request for the Maven Archetype project is required here.

This is the most clean solution.

There might be different solution, but that means you need to get access to the Guice context and re-bind the service to a new implementation. I wonder if that'll work.

Robert

On Wed, 01 Feb 2017 23:32:29 +0100, Laird Nelson <ljnel...@gmail.com> wrote:

On Wed, Feb 1, 2017 at 1:27 PM Robert Scholte <rfscho...@apache.org> wrote:

bq. If you want to use JSR-330, you must understand that your code won't
be compatible with Maven 2 or 3.0.x but only with Maven 3.1.0+

this is probably the reason why *I* haven't seen it used that much.


Sure.  In my case, this won't matter.


Your confusion is probably coming from 2 different descriptors, which both
use @Component.


No, I'm aware of both of them.  I'm interested indirectly in the Maven
plugin API @Component, which indirectly causes a <component> element/stanza in the plugin.xml. I know that part. What I *don't* know (still!) is how, as an end user, to alter the *components.xml* that is *already present* in the maven-archetype-plugin (the plugin whose component selection I want to
override) such that *my* implementation is chosen instead of the default
one.  I was hoping to use Sisu/Guice/something else to accomplish this
since there doesn't seem to be any documented way to do it using Plexus
constructs.

Thanks again for your help.

Best,
Laird

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to