DefaultImpl(LifecycleManager mgr) { container = InjectionContainer.create(CachePolicy.MEMOIZE, mgr); }
/** * Create a new instantiator with a default policy of {@code MEMOIZE}. * @return The instantiator. */ public static InjectionContainer create() { return create(CachePolicy.MEMOIZE); }
DefaultImpl(LifecycleManager mgr) { container = InjectionContainer.create(CachePolicy.MEMOIZE, mgr); }
/** * <p> * Create a new DefaultInjector. <tt>maxDepth</tt> represents the maximum * depth of the dependency hierarchy before it is assume that there is a * cycle. Bindings with a NO_PREFERENCE cache policy will use * <tt>defaultPolicy</tt>. * <p> * This constructor can be used to increase this depth in the event that * configuration requires it, although for most purposes the default 100 * should be sufficient. * * @param defaultPolicy The CachePolicy used in place of NO_PREFERENCE * @param maxDepth The maximum depth of the dependency hierarchy * @param functions The BindingFunctions to use, ordered with highest * priority functions first * @throws IllegalArgumentException if maxDepth is less than 1, or if * defaultPolicy is NO_PREFERENCE * @throws NullPointerException if spi or functions are null */ public DefaultInjector(CachePolicy defaultPolicy, int maxDepth, BindingFunction... functions) { if (defaultPolicy.equals(CachePolicy.NO_PREFERENCE)) { throw new IllegalArgumentException("Default CachePolicy cannot be NO_PREFERENCE"); } solver = DependencySolver.newBuilder() .addBindingFunctions(functions) .setMaxDepth(maxDepth) .build(); instantiator = InjectionContainer.create(defaultPolicy); }