I'm stuck on the mismatch between ServiceLoader (which provides me with all available implementations of some java interface) and @EJB (which provides me of one particular implementation of some @Local annotated interface, which simply fails if multiple are available).
The problem with ServiceLoader is, that it produces instances that are not managed nor injected. The good thing is, that i can add implementations simply by adding jars in my ear file.
The problem with @EJB is that you can not say "give me all implementations, ony by one" like ServiceLocator does; you need to pick one. The good thing is, that the thing is managed, injected, intercepted etc... and that the container calculates the dependency tree and makes sure everything is instantiated in the right order.
I was wondering if anyone had some clever way out of this. How can i have injected all EJB's implementing some @Local interface + influencing the deployment order of these ejb's such that these dependents are instantiated before the service that wants to delegate to them?