io.smallrye.beanbag.InjectingSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smallrye-beanbag Show documentation
Show all versions of smallrye-beanbag Show documentation
A trivial programmatic bean container implementation
package io.smallrye.beanbag;
import java.util.List;
/**
* A provider which injects things into injectors after getting the instance from another provider.
*/
final class InjectingSupplier implements BeanSupplier {
private final BeanSupplier instanceSupplier;
private final List> injectors;
InjectingSupplier(final BeanSupplier instanceSupplier, final List> injectors) {
this.instanceSupplier = instanceSupplier;
this.injectors = injectors;
}
public T get(Scope scope) {
final T instance = instanceSupplier.get(scope);
for (Injector injector : injectors) {
injector.injectInto(scope, instance);
}
return instance;
}
}