All Downloads are FREE. Search and download functionalities are using the official Maven repository.

toothpick.InjectorImpl Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package toothpick;

import toothpick.registries.MemberInjectorRegistryLocator;

/**
 * Default implementation of an injector.
 */
public final class InjectorImpl implements Injector {
  /**
   * {@inheritDoc}
   *
   * 

* ⚠ Warning ⚠ : This implementation needs a proper setup of {@link toothpick.registries.MemberInjectorRegistry} instances * at the annotation processor level. We will bubble up the hierarchy, starting at class {@code T}. As soon * as a {@link MemberInjector} is found, we use it to inject the members of {@code obj}. If registries are not find then * you will observe strange behaviors at runtime : only members defined in super class will be injected. *

*/ @Override public void inject(T obj, Scope scope) { Class currentClass = (Class) obj.getClass(); do { MemberInjector memberInjector = MemberInjectorRegistryLocator.getMemberInjector(currentClass); if (memberInjector != null) { memberInjector.inject(obj, scope); return; } else { currentClass = currentClass.getSuperclass(); } } while (currentClass != null); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy