/** * Install the provider of the class {@code clazz} and name {@code bindingName} * in the current scope. * * @param clazz the class for which to install the scoped provider of this scope. * @param bindingName the name, possibly {@code null}, for which to install the scoped provider. * @param scopedProvider the internal provider to install. * @param isTestProvider whether or not is a test provider, installed through a Test Module that should override * existing providers for the same class-bindingname. * @param <T> the type of {@code clazz}. * @return the provider that will be installed, if one was previously installed, it is returned, in a lock-free way. */ private <T> InternalProviderImpl<? extends T> installScopedProvider(Class<T> clazz, String bindingName, ScopedProviderImpl<? extends T> scopedProvider, boolean isTestProvider) { return installBoundProvider(clazz, bindingName, scopedProvider, isTestProvider); }
/** * Install bindings for scope. */ private void installBindingForScope() { //it's always possible to get access to the scope that contains an injected object. installBoundProvider(Scope.class, null, new InternalProviderImpl<>(this), false); }
private void installModule(boolean isTestModule, Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); try { if (isTestModule || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isCreatingInstancesInScope()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider, isTestModule); } else { installBoundProvider(clazz, bindingName, provider, isTestModule); } } } catch (Exception e) { throw new IllegalBindingException(format("Binding %s couldn't be installed", bindingName), e); } } }
/** * Install the provider of the class {@code clazz} and name {@code bindingName} * in the current scope. * * @param clazz the class for which to install the scoped provider of this scope. * @param bindingName the name, possibly {@code null}, for which to install the scoped provider. * @param <T> the type of {@code clazz}. * @return the provider that will be installed, if one was previously installed, it is returned, in a lock-free way. */ private <T> InternalProviderImpl<? extends T> installScopedProvider(Class<T> clazz, String bindingName, ScopedProviderImpl<? extends T> scopedProvider) { return installBoundProvider(clazz, bindingName, scopedProvider); }
/** * Install the provider of the class {@code clazz} and name {@code bindingName} * in the current scope. * * @param clazz the class for which to install the scoped provider of this scope. * @param bindingName the name, possibly {@code null}, for which to install the scoped provider. * @param scopedProvider the internal provider to install. * @param isTestProvider whether or not is a test provider, installed through a Test Module that should override * existing providers for the same class-bindingname. * @param <T> the type of {@code clazz}. * @return the provider that will be installed, if one was previously installed, it is returned, in a lock-free way. */ private <T> InternalProviderImpl<? extends T> installScopedProvider(Class<T> clazz, String bindingName, ScopedProviderImpl<? extends T> scopedProvider, boolean isTestProvider) { return installBoundProvider(clazz, bindingName, scopedProvider, isTestProvider); }
public ScopeImpl(Object name) { super(name); //it's always possible to get access to the scope that conitains an injected object. installBoundProvider(Scope.class, null, new InternalProviderImpl<>(this)); }
/** * Install bindings for scope. */ private void installBindingForScope() { //it's always possible to get access to the scope that contains an injected object. installBoundProvider(Scope.class, null, new InternalProviderImpl<>(this), false); }
private void installModule(boolean isTestModule, Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); try { if (isTestModule || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isCreatingInstancesInScope()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider, isTestModule); } else { installBoundProvider(clazz, bindingName, provider, isTestModule); } } } catch (Exception e) { throw new IllegalBindingException(format("Binding %s couldn't be installed", bindingName), e); } } }
private void installModule(Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); if (!hasTestModules || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isScoped()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider); } else { installBoundProvider(clazz, bindingName, provider); } } } }