use of org.qi4j.runtime.injection.InjectionContext in project qi4j-sdk by Qi4j.
the class ActivatorModel method newInstance.
@SuppressWarnings("unchecked")
public Activator<ActivateeType> newInstance(InjectionContext injectionContext) {
try {
Activator<ActivateeType> instance = (Activator<ActivateeType>) constructorsModel.newInstance(injectionContext);
injectionContext = new InjectionContext(injectionContext.module(), injectionContext.uses(), instance);
inject(injectionContext, instance);
return instance;
} catch (Exception ex) {
throw new ConstructionException("Could not instantiate " + activatorType.getName(), ex);
}
}
use of org.qi4j.runtime.injection.InjectionContext in project qi4j-sdk by Qi4j.
the class ActivatorsModel method newInstances.
public Iterable<Activator<ActivateeType>> newInstances(Module module) throws ActivationException {
List<Activator<ActivateeType>> activators = new ArrayList<>();
for (ActivatorModel<ActivateeType> activatorModel : activatorModels) {
InjectionContext injectionContext = new InjectionContext((ModuleInstance) module, UsesInstance.EMPTY_USES);
activators.add(activatorModel.newInstance(injectionContext));
}
return activators;
}
use of org.qi4j.runtime.injection.InjectionContext in project qi4j-sdk by Qi4j.
the class ModuleInstance method newObject.
// Implementation of ObjectFactory
@Override
public <T> T newObject(Class<T> mixinType, Object... uses) throws NoSuchObjectException {
NullArgumentException.validateNotNull("mixinType", mixinType);
ModelModule<ObjectModel> modelModule = typeLookup.lookupObjectModel(mixinType);
if (modelModule == null) {
throw new NoSuchObjectException(mixinType.getName(), name());
}
InjectionContext injectionContext = new InjectionContext(modelModule.module(), UsesInstance.EMPTY_USES.use(uses));
return mixinType.cast(modelModule.model().newInstance(injectionContext));
}
use of org.qi4j.runtime.injection.InjectionContext in project qi4j-sdk by Qi4j.
the class ModuleInstance method injectTo.
@Override
public void injectTo(Object instance, Object... uses) throws ConstructionException {
NullArgumentException.validateNotNull("instance", instance);
ModelModule<ObjectModel> modelModule = typeLookup.lookupObjectModel(instance.getClass());
if (modelModule == null) {
throw new NoSuchObjectException(instance.getClass().getName(), name());
}
InjectionContext injectionContext = new InjectionContext(modelModule.module(), UsesInstance.EMPTY_USES.use(uses));
modelModule.model().inject(injectionContext, instance);
}
use of org.qi4j.runtime.injection.InjectionContext in project qi4j-sdk by Qi4j.
the class EntityMixinsModel method newMixin.
public Object newMixin(EntityInstance entityInstance, StateHolder state, Object[] mixins, Method method) {
MixinModel model = methodImplementation.get(method);
InjectionContext injectionContext = new InjectionContext(entityInstance, UsesInstance.EMPTY_USES, state);
Object mixin = model.newInstance(injectionContext);
mixins[methodIndex.get(method)] = mixin;
return mixin;
}
Aggregations