com.cerner.beadledom.guice.dynamicbindings.DynamicBindingProviderImpl Maven / Gradle / Ivy
package com.cerner.beadledom.guice.dynamicbindings;
import com.cerner.beadledom.guice.BindingAnnotations;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
import java.lang.annotation.Annotation;
/**
* Internal implementation of {@link DynamicBindingProvider}.
*
* @author John Leacox
* @since 1.2
*/
class DynamicBindingProviderImpl implements DynamicBindingProvider {
private Injector injector;
private TypeLiteral type;
DynamicBindingProviderImpl(TypeLiteral type) {
this.type = type;
}
@Inject
void init(Injector injector) {
this.injector = injector;
}
@Override
public synchronized T get(Class extends Annotation> bindingAnnotation) {
BindingAnnotations.checkIsBindingAnnotation(bindingAnnotation);
Key key = Key.get(type, bindingAnnotation);
return injector.getInstance(key);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy