Interface JustInTimeInjectionResolver
-
- All Known Implementing Classes:
GreedyResolver
,JustInTimeInjectionResolverImpl
@Contract public interface JustInTimeInjectionResolver
The JustInTimeInjectionResolver is called when an injection point cannot find anything to inject. It allows a third party systems to dynamically add descriptors to the system whenever an injection point would have failed to resolve (or an Optional injection point found no service definitions).All injection resolvers registered with the system will be called in a random order. Resolvers should therefore not rely on the ordering of installed injection resolvers. Any injection resolvers added as a result of this callback will NOT be called until the next injection resolution failure.
Implementations of this interface are placed into the registry like any other service. One use-case would be to inject the
DynamicConfigurationService
into the implementation in order to add services if this resolver can do so. Another option would be to inject aServiceLocator
and use one of the methods inServiceLocatorUtilities
in order to add services to the registryIf any of the registered injection resolvers commits a dynamic change then the system will try one more time to resolve the injection before failing (or returning null if the injection point is Optional).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
justInTimeResolution(Injectee failedInjectionPoint)
This method will be called whenever an injection point cannot be resolved.
-
-
-
Method Detail
-
justInTimeResolution
boolean justInTimeResolution(Injectee failedInjectionPoint)
This method will be called whenever an injection point cannot be resolved. If this method adds anything to the configuration it should return true. Otherwise it should return false. The injection point that failed to be resolved is given in failedInjectionPoint.If this method throws an exception that exception will be added to the set of exceptions in the MultiException that may be thrown from the injection resolver.
This method can be called on multiple threads with different or the same
Injectee
. Therefore care must be taken in this method to not add the same descriptor more than once- Parameters:
failedInjectionPoint
- The injection point that failed to resolve- Returns:
- true if this method has added a descriptor to the
ServiceLocator
which may be used to resolve theInjectee
. False if this method did not add a descriptor to theServiceLocator
that might help resolve the injection point
-
-