public interface ContextSensitiveProvider<T>
Provider, but with knowledge of the target
This interface, along with
ContextSensitiveBinder, is useful for injecting custom logger types, among other
things. However, context-sensitive injections can make maintenance and debugging more difficult.
T getInContext(InjectionPoint injectionPoint)
Tfor the given context.
InjectionPointfor this provision.
Tfor an unknown context.
InjectionPoint may not be known in all cases, for example if a
Provider<T> is used instead
T. This method will be called in those cases.
One reasonable implementation is to return a generically applicable instance, such as an anonymous logger.
Another valid implementation is to throw an unchecked exception; in that case,
RuntimeException- If injection without a context is not supported.
Copyright © 2014–2015. All rights reserved.