Can you specify the hint for a Component from the pom.xml

109 Views Asked by At

If you define a component in your Mojo (groovy or java using maven-plugin-annotations), eg:

@Component
Parser parser;

And you have multiple implementations of Parser, that have

@Component(role=Parser.class, hint="simple")
public class SimpleParser implements Parser

and

@Component(role=Parser.class, hint="complex")
public class ComplexParser implements Parser

Is there a way to choose the implementation from the pom.xml (or setting.xml or CLI with -D)?

I would think it would/should be possible to specify

<configuration>
  <parser>complex</parser>
</configuration>

but that doesn't work.

(Of course, there is also no way to set an alias on a Component which is annoying also (or at least would be if you could specify the hint), since we use m_ prefixes on our member variables (ie, in our code, it would actually be m_parser.)

0

There are 0 best solutions below