Right now the constructor models contain all constructors of a class.
If there are constructors without injection annotations the annotation of the
DependencyModel for this parameter is set
to null. This incurrs a NPE when later injecting the resolution.
public InjectionProvider newInjectionProvider( Resolution resolution,
DependencyModel dependencyModel ) throws
InvalidInjectionException
{
final Annotation annotation = dependencyModel.injectionAnnotation();
Class<? extends Annotation> injectionAnnotationType =
annotation.annotationType();
InjectionProviderFactory factory = providerFactories.get(
injectionAnnotationType );
if( factory == null )
{
throw new InvalidInjectionException( "Unknown injection annotation
@" +
injectionAnnotationType.getSimpleName() );
}
return factory.newInjectionProvider( resolution, dependencyModel );
}
What would be a better solution ?
1) Ignore all constructors which have no sufficient injection annotations, do
call them?
2) Have a DefaultsProviderFactory for this case (e.g. providing default values
for primitive types and null for objects)
and use that in this case?
The Problem occurred with the ReentrantReadWriteLock of the JDK which is
injected and has itself multiple constructors
one of them beeing public RentrantReadWriteLock(boolean b); For this
constructor no injection annotation can be found.
Michael
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev