weld/core — pull request #626 by awptt (2014-08-05 14:09:10+00:00)
Title: Improve Weld SE Startup Performance: Use available jandex.idx files and more

The proposed code change with this pull request helps to improve the memory consumption of Weld SE during and after the start-up phase.

In our application we currently have (just) 22 JAR files with a beans.xml file. In future, this number should grow. If we start-up Weld SE in this environment, our application consumes additional 30 MB memory (which is an increase of 50 percent).

During the start-up, Weld SE scans all jars with a beans.xml file completely, using java.util.zip.ZipFile. With a memory profiler we can see that during the initialization, the memory consumption raises up to 300 MB, before it decreases again.

The following pull request contains a proposal to improve the start-up behaviour of Weld SE. It contains the following enhancements:
* If an archive contained a beans.xml with bean-discovery-mode=none is was completely scanned by URLScanner.scan(). The scan-result was returned in a Collection. After the scanning, this result was never used. In this pull request, URLScanner is adapted, so that an archive with bean-discovery-mode=none is not scanned anymore.
* The Weld SE Startup is now able to use jandex.idx files at the meta-inf directory of an archive (if Jandex is in the classpath). The implementation first checks if an index is available and usable. If yes, Weld SE just need to load the index instead or reading the complete archive.
* The beans.xml files are not re-parsed during a merge operation any-more. The new class BeansXMLMergeUtil is able to do the merge without re-parsing.

Especially in bigger Java SE applications, the memory consumption and start-up performance of the CDI Container can become a show stopper. The proposed changes can help to solve this problem.