I know it is still not quite popular, since the spec was released just a few months ago.
I haven't "installed" weld yet, I'm just reading, and by this question I want to make sure I've understood this important point correct:
Is resolution of beans that are in 3rd-party jars achieved by declaring them as <alternatives>
in your beans.xml
?
If not, how to use beans from 3rd party libraries that don't have beans.xml
?
Putting the jar on the classpath won't work unless there is beans.xml
in their META-INF
, which you can't make true for 3rd party jars. (see Gavin King's post on the subject)
why think so complicated?
Simply make a producerMethod for those 3rd party classes.
Let's assume you have a 3rd party library which automatically takes PDF files and sends them per faximile, and you like to use something like
private @Inject PdfFaxService faxService;
in your code, then you could simply provide this with a producer method. The PdfFaxService works stateless, so we can safely assume that we can make it @ApplicationScoped
:
public @Produces @ApplicationScoped PdfFaxService createFaxService() {
return new PdfFaxService(initparameters);
}
somewhere.
hth.