How to understand "synthetic" bean archive in weld?

674 views Asked by At

I am learning weld.
And when I study the source code of org.jboss.weld.environment.se.Weld class it mention synthetic bean archive several times in comment. It seemed it have thing with beans.xml.


I guess it is used to tell container load beans specified by manually and at this case we dont need beans.xml, but that is only my conjecture then who can tell me how to understand synthetic bean archive?

everything will be appreciated.

1

There are 1 answers

0
John Ament On

Synthetic bean archives are being formalized in CDI 2.0, though impls may use the notion now in a non-portable way. Docs are in the CDI 2.0-EDR2

Basically, the synthetic bean archive represents the subset of beans that have been loaded while initializing the CDI container. Assuming you have enabled discovery and just use initialize() from Weld, the synthetic bean archive contains the superset of all JAR files on the classpath, using standard bean discovery rules - except that archives without beans.xml are excluded.

If you disable discovery and programmatically add beans, the synthetic bean archive represents only those beans that you programmatically added.