}
}
if (!constructorInjectionPoints.isEmpty()) {
if (constructorInjectionPoints.size() > 1) {
throw new InjectionFailure("more than one constructor in "
+ type.getFullyQualifiedName() + " is marked as the injection point!");
}
final MetaConstructor constructor = constructorInjectionPoints.get(0);
return new ConstructionStrategy() {
@Override
public void generateConstructor(ConstructionStatusCallback callback) {
Statement[] parameterStatements
= resolveInjectionDependencies(constructor.getParameters(), ctx, constructor);
if (injector.isSingleton() && injector.isCreated()) return;
IOCProcessingContext processingContext = ctx.getProcessingContext();
processingContext.append(
Stmt.declareVariable(type)
.asFinal()
.named(injector.getVarName())
.initializeWith(Stmt
.newObject(type)
.withParameters(parameterStatements))
);
callback.beanConstructed();
handleInjectionTasks(ctx, injectionTasks);
doPostConstruct(ctx, injector, postConstructTasks);
doPreDestroy(ctx, injector, preDestroyTasks);
}
};
}
else {
// field injection
if (!hasDefaultConstructor(type))
throw new InjectionFailure("there is no public default constructor or suitable injection constructor for type: "
+ type.getFullyQualifiedName());
return new ConstructionStrategy() {
@Override
public void generateConstructor(ConstructionStatusCallback callback) {