FYI, I was so upset because of the dependency on the occupant files, and did not have the ability to check the runtime of annotated classes, I wrote this project:
https://github.com/VA-CTT/HK2Utilities
Since the Eclipse / Maven / habitant runtime generators did not play well, it was almost impossible to debug the code that used HK2 in eclipse without scanning at run time.
HK2Utilities package is available in the center:
<dependency> <groupId>gov.va.oia</groupId> <artifactId>HK2Utilities</artifactId> <version>1.4.1</version> </dependency>
To use it, you simply call:
ServiceLocator locator = HK2RuntimeInitializer.init("myName", false, new String[]{"my.package.one", "my.package.two"});
This scans the execution class path for the classes in the listed packages and automatically populates them with a service locator.
You do not need to create files with this model, and in practice, I found that it works faster than the resident processing code (not that performance matters a lot for this one-time operation)
source share