use of org.qi4j.api.composite.InvalidValueCompositeException in project qi4j-sdk by Qi4j.
the class InjectionProviderFactoryStrategy method newInjectionProvider.
@Override
public InjectionProvider newInjectionProvider(Resolution resolution, DependencyModel dependencyModel) throws InvalidInjectionException {
Class<? extends Annotation> injectionAnnotationType = dependencyModel.injectionAnnotation().annotationType();
InjectionProviderFactory factory1 = generalProviderFactories.get(injectionAnnotationType);
InjectionProviderFactory factory2 = valuesProviderFactories.get(injectionAnnotationType);
if (factory1 == null && factory2 == null) {
InjectionProviderFactory factory = metaInfo.get(InjectionProviderFactory.class);
if (factory != null) {
return factory.newInjectionProvider(resolution, dependencyModel);
} else {
throw new InvalidInjectionException("Unknown injection annotation @" + injectionAnnotationType.getSimpleName());
}
}
ModelDescriptor composite = resolution.model();
Class<?> compositeType = first(composite.types());
if (factory1 != null && ValueComposite.class.isAssignableFrom(compositeType)) {
throw new InvalidValueCompositeException("@" + injectionAnnotationType.getSimpleName() + " is not allowed in ValueComposites: " + compositeType);
}
InjectionProviderFactory factory;
if (factory1 == null) {
factory = factory2;
} else {
factory = factory1;
}
return factory.newInjectionProvider(resolution, dependencyModel);
}
Aggregations