Re: Automatic configuration
The *usual* way to do automatic service registration is this:
1. Put @Service on all classes you want to create as a service (put @Contract on all interfaces or classes that should be advertised)
2. Use the inhabitant generator during build
3. Use the populate method of a Populator which you can get from the DynamicConfigurationService
The DynamicConfigurationService is available in every hk2 registry (unless it has been explicitly removed, giving rise to a read-only hk2 registry).
If the above steps are not what you are looking for you can use the other method on Populator to do whatever you want for automatic service registration.
In particular the hk2 testing facility hk2-junitrunner scans all classes in a package. You can see the code around lines 414 in HK2Runner.java. The HK2Runner example is going directly to the DynamicConfiguration returned from the DynamicConfigurationService rather than using the Populator but the basic idea is the same.
If you are using the inhabitant generator method during build instead you can do it all in one line with createAndPopulateServiceLocator.
I hope this helps.