injector.state.getProvisionListenerBindings(); injector.provisionListenerStore = new ProvisionListenerCallbackStore(provisionListenerBindings); stopwatch.resetAndLog("TypeListeners & ProvisionListener creation");
@Override @SuppressWarnings("unchecked") // the result type always agrees with the ConstructorInjector type public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { factory.constructorInjector = (ConstructorInjector<T>) injector.constructors.get(constructorInjectionPoint, errors); factory.provisionCallback = injector.provisionListenerStore.get(this); }
/** Cleans up any state that may have been cached when constructing the JIT binding. */ private void removeFailedJitBinding(Binding<?> binding, InjectionPoint ip) { failedJitBindings.add(binding.getKey()); jitBindings.remove(binding.getKey()); membersInjectorStore.remove(binding.getKey().getTypeLiteral()); provisionListenerStore.remove(binding); if (ip != null) { constructors.remove(ip); } }
@Override public void initialize(final InjectorImpl injector, final Errors errors) throws ErrorsException { originalFactory.source = getSource(); originalFactory.provisionCallback = injector.provisionListenerStore.get(this); // For these kinds of providers, the 'user supplied provider' is really 'guice supplied' // So make our user supplied provider just delegate to the guice supplied one. originalFactory.delegateProvider = getProvider(); originalFactory.initialize(injector, errors); }
/** Cleans up any state that may have been cached when constructing the JIT binding. */ private void removeFailedJitBinding(Binding<?> binding, InjectionPoint ip) { failedJitBindings.add(binding.getKey()); jitBindings.remove(binding.getKey()); membersInjectorStore.remove(binding.getKey().getTypeLiteral()); provisionListenerStore.remove(binding); if (ip != null) { constructors.remove(ip); } }
injector.state.getProvisionListenerBindings(); injector.provisionListenerStore = new ProvisionListenerCallbackStore(provisionListenerBindings); stopwatch.resetAndLog("TypeListeners & ProvisionListener creation");
!validationStarted, "Member injection could not be requested after validation is started"); ProvisionListenerStackCallback<T> provisionCallback = binding == null ? null : injector.provisionListenerStore.get(binding);
/** Cleans up any state that may have been cached when constructing the JIT binding. */ private void removeFailedJitBinding(Binding<?> binding, InjectionPoint ip) { failedJitBindings.add(binding.getKey()); jitBindings.remove(binding.getKey()); membersInjectorStore.remove(binding.getKey().getTypeLiteral()); provisionListenerStore.remove(binding); if (ip != null) { constructors.remove(ip); } }
injector.state.getProvisionListenerBindings(); injector.provisionListenerStore = new ProvisionListenerCallbackStore(provisionListenerBindings); stopwatch.resetAndLog("TypeListeners & ProvisionListener creation");
/** Creates a binding for a type annotated with @ProvidedBy. */ <T> BindingImpl<T> createProvidedByBinding( Key<T> key, Scoping scoping, ProvidedBy providedBy, Errors errors) throws ErrorsException { Class<?> rawType = key.getTypeLiteral().getRawType(); Class<? extends javax.inject.Provider<?>> providerType = providedBy.value(); // Make sure it's not the same type. TODO: Can we check for deeper loops? if (providerType == rawType) { throw errors.recursiveProviderType().toException(); } // Assume the provider provides an appropriate type. We double check at runtime. @SuppressWarnings("unchecked") Key<? extends Provider<T>> providerKey = (Key<? extends Provider<T>>) Key.get(providerType); ProvidedByInternalFactory<T> internalFactory = new ProvidedByInternalFactory<T>(rawType, providerType, providerKey); Object source = rawType; BindingImpl<T> binding = LinkedProviderBindingImpl.createWithInitializer( this, key, source, Scoping.<T>scope(key, this, internalFactory, source, scoping), scoping, providerKey, internalFactory); internalFactory.setProvisionListenerCallback(provisionListenerStore.get(binding)); return binding; }
/** * Cleans up any state that may have been cached when constructing the JIT binding. */ private void removeFailedJitBinding(Binding<?> binding, InjectionPoint ip) { failedJitBindings.add(binding.getKey()); jitBindings.remove(binding.getKey()); membersInjectorStore.remove(binding.getKey().getTypeLiteral()); provisionListenerStore.remove(binding); if (ip != null) { constructors.remove(ip); } }
injector.state.getProvisionListenerBindings(); injector.provisionListenerStore = new ProvisionListenerCallbackStore(provisionListenerBindings); stopwatch.resetAndLog("TypeListeners & ProvisionListener creation");
@Override public Boolean visit(ProviderKeyBinding<? extends T> binding) { prepareBinding(); Key<? extends javax.inject.Provider<? extends T>> providerKey = binding.getProviderKey(); // always visited with Binding<T> @SuppressWarnings("unchecked") BoundProviderFactory<T> boundProviderFactory = new BoundProviderFactory<T>( injector, providerKey, source, injector.provisionListenerStore.get((ProviderKeyBinding<T>) binding)); bindingData.addCreationListener(boundProviderFactory); InternalFactory<? extends T> scopedFactory = Scoping.scope( key, injector, (InternalFactory<? extends T>) boundProviderFactory, source, scoping); putBinding( new LinkedProviderBindingImpl<T>( injector, key, source, scopedFactory, scoping, providerKey)); return true; }
@Override public Boolean visit(ProviderInstanceBinding<? extends T> binding) { prepareBinding(); javax.inject.Provider<? extends T> provider = binding.getUserSuppliedProvider(); if (provider instanceof InternalProviderInstanceBindingImpl.Factory) { @SuppressWarnings("unchecked") InternalProviderInstanceBindingImpl.Factory<T> asProviderMethod = (InternalProviderInstanceBindingImpl.Factory<T>) provider; return visitInternalProviderInstanceBindingFactory(asProviderMethod); } Set<InjectionPoint> injectionPoints = binding.getInjectionPoints(); Initializable<? extends javax.inject.Provider<? extends T>> initializable = initializer.<javax.inject.Provider<? extends T>>requestInjection( injector, provider, null, source, injectionPoints); // always visited with Binding<T> @SuppressWarnings("unchecked") InternalFactory<T> factory = new InternalFactoryToInitializableAdapter<T>( initializable, source, injector.provisionListenerStore.get((ProviderInstanceBinding<T>) binding)); InternalFactory<? extends T> scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding( new ProviderInstanceBindingImpl<T>( injector, key, source, scopedFactory, scoping, provider, injectionPoints)); return true; }
@Override @SuppressWarnings("unchecked") // the result type always agrees with the ConstructorInjector type public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { factory.constructorInjector = (ConstructorInjector<T>) injector.constructors.get(constructorInjectionPoint, errors); factory.provisionCallback = injector.provisionListenerStore.get(this); }
@Override @SuppressWarnings("unchecked") // the result type always agrees with the ConstructorInjector type public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { factory.constructorInjector = (ConstructorInjector<T>) injector.constructors.get(constructorInjectionPoint, errors); factory.provisionCallback = injector.provisionListenerStore.get(this); }
@SuppressWarnings("unchecked") // the result type always agrees with the ConstructorInjector type public void initialize(InjectorImpl injector, Errors errors) throws ErrorsException { factory.constructorInjector = (ConstructorInjector<T>) injector.constructors.get(constructorInjectionPoint, errors); factory.provisionCallback = injector.provisionListenerStore.get(this); }
@Override public void initialize(final InjectorImpl injector, final Errors errors) throws ErrorsException { originalFactory.source = getSource(); originalFactory.provisionCallback = injector.provisionListenerStore.get(this); // For these kinds of providers, the 'user supplied provider' is really 'guice supplied' // So make our user supplied provider just delegate to the guice supplied one. originalFactory.delegateProvider = getProvider(); originalFactory.initialize(injector, errors); }
@Override public void initialize(final InjectorImpl injector, final Errors errors) throws ErrorsException { originalFactory.source = getSource(); originalFactory.provisionCallback = injector.provisionListenerStore.get(this); // For these kinds of providers, the 'user supplied provider' is really 'guice supplied' // So make our user supplied provider just delegate to the guice supplied one. originalFactory.delegateProvider = getProvider(); originalFactory.initialize(injector, errors); }
!validationStarted, "Member injection could not be requested after validation is started"); ProvisionListenerStackCallback<T> provisionCallback = binding == null ? null : injector.provisionListenerStore.get(binding);