LOG.info("Container verified.");
}
@Override
public <M extends Module> Container loadModule(Class<M> moduleClass) {
Module module = strategyFactory.create(moduleClass, Qualifier.NONE, Scopes.PROTOTYPE).get(this);
for (Mapping<?> mapping : module.getMappings()) {
Class<?> implementationType = mapping.getImplementationType();
Object qualifier = mapping.getQualifier();
if (qualifier.equals(Qualifier.NONE)) {
qualifier = metadataAdapter.getQualifier(implementationType, implementationType.getAnnotations());
}
if (mapping instanceof InstanceMapping) {
InstanceMapping<?> instanceMapping = (InstanceMapping) mapping;
Object instance = instanceMapping.getInstance();
for (Class<?> target : mapping.getTargetClasses()) {
addMapping(Locksmith.makeKey(target, qualifier), instance);
}
for (Key<?> targetGeneric : mapping.getTargetKeys()) {
addMapping(targetGeneric, instance);
}
} else {
for (Class<?> target : mapping.getTargetClasses()) {
addMapping(Locksmith.makeKey(target, qualifier), implementationType, mapping.getScope());
}
for (Key<?> targetGeneric : mapping.getTargetKeys()) {
addMapping(targetGeneric, implementationType, mapping.getScope());
}
}
}
for (Map.Entry<Key, Class> entry : module.getNonManagedComponentFactories().entrySet()) {
registerNonManagedComponentFactory(entry.getKey(), entry.getValue());
}
return this;
}