@Override public <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type) { return this.delegateInjector.findBindingsByType(type); }
public <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type) { return resolve().findBindingsByType(type); }
@Inject public void inject(Injector injector) { final List<Binding<TLSCertificateChecker>> checkerBindings = injector.findBindingsByType(new TypeLiteral<TLSCertificateChecker>(){}); checker = findChecker(checkerType, checkerBindings); if (checker == null) { throw new IAE("Could not find certificate checker with type: " + checkerType); } }
@Inject public void inject(Injector injector) { final List<Binding<Emitter>> emitterBindings = injector.findBindingsByType(new TypeLiteral<Emitter>(){}); emitter = findEmitter(emitterType, emitterBindings); if (emitter == null) { emitter = findEmitter(NoopEmitterModule.EMITTER_TYPE, emitterBindings); } if (emitter == null) { List<String> knownTypes = new ArrayList<>(); for (Binding<Emitter> binding : emitterBindings) { final Annotation annotation = binding.getKey().getAnnotation(); if (annotation != null) { knownTypes.add(((Named) annotation).value()); } } throw new ISE("Unknown emitter type[%s]=[%s], known types[%s]", EMITTER_PROPERTY, emitterType, knownTypes); } }
List<Binding<T>> sameTypes = injector.findBindingsByType(type); if (!sameTypes.isEmpty()) { sb.append(format("%n Did you mean?"));
/** * Introspects the injector and collects all instances of bound {@code List<ServletDefinition>} * into a master list. * * <p>We have a guarantee that {@link com.google.inject.Injector#getBindings()} returns a map that * preserves insertion order in entry-set iterators. */ private ServletDefinition[] collectServletDefinitions(Injector injector) { List<ServletDefinition> servletDefinitions = Lists.newArrayList(); for (Binding<ServletDefinition> entry : injector.findBindingsByType(SERVLET_DEFS)) { servletDefinitions.add(entry.getProvider().get()); } // Copy to a fixed size array for speed. return servletDefinitions.toArray(new ServletDefinition[servletDefinitions.size()]); }
/** * Introspects the injector and collects all instances of bound {@code List<FilterDefinition>} * into a master list. * * <p>We have a guarantee that {@link com.google.inject.Injector#getBindings()} returns a map that * preserves insertion order in entry-set iterators. */ private FilterDefinition[] collectFilterDefinitions(Injector injector) { List<FilterDefinition> filterDefinitions = Lists.newArrayList(); for (Binding<FilterDefinition> entry : injector.findBindingsByType(FILTER_DEFS)) { filterDefinitions.add(entry.getProvider().get()); } // Copy to a fixed-size array for speed of iteration. return filterDefinitions.toArray(new FilterDefinition[filterDefinitions.size()]); }
expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.<Binding<ServletDefinition>>of(mockBinding)); Provider<ServletDefinition> bindingProvider = Providers.of(servletDefinition);
expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.<Binding<ServletDefinition>>of(mockBinding)); Provider<ServletDefinition> bindingProvider = Providers.of(servletDefinition);
expect(injector.findBindingsByType(eq(servetDefsKey.getTypeLiteral()))) .andReturn(ImmutableList.<Binding<ServletDefinition>>of(mockBinding)); Provider<ServletDefinition> bindingProvider = Providers.of(servletDefinition);
@Override public <B> Iterator<BindingDescriptor<B>> getBindings(Class<B> clazz) { List<BindingDescriptor<B>> result = new ArrayList<BindingDescriptor<B>>(); for (Binding<B> binding : injector.findBindingsByType(TypeLiteral.get(clazz))) { result.add(new GuiceBindingDescriptorAdapter<B>(binding)); } return result.iterator(); } }
private void collect(Consumer<TestEventCollector> consumer) { injector.findBindingsByType(TypeLiteral.get(TestEventCollector.class)).stream() .map(Binding::getProvider) .map(Provider::get) .forEach(consumer); logCollectors(injector); }
@Inject public Default(Injector injector) { List<Binding<FeatureExtensions>> bindingsByType = injector == null ? Lists .<Binding<FeatureExtensions>> newArrayList() : injector.findBindingsByType(TypeLiteral .get(FeatureExtensions.class)); for (Binding<FeatureExtensions> binding : bindingsByType) { featureExtensionCallbacks.add(binding.getProvider().get()); } }
@Override public <B> Iterator<BindingDescriptor<B>> getBindings(Class<B> clazz) { List<BindingDescriptor<B>> result = new ArrayList<>(); for (Binding<B> binding : injector.findBindingsByType(TypeLiteral.get(clazz))) { result.add(new GuiceBindingDescriptorAdapter<>(binding)); } return result.iterator(); } }
@Inject public AbstractComposite(Class<T> clazz, Injector injector) { List<Binding<T>> bindingsByType = injector.findBindingsByType(TypeLiteral .get(clazz)); for (Binding<T> binding : bindingsByType) { try { elements.add(binding.getProvider().get()); } catch (RuntimeException e) { handle(e); } } }
protected final void beginTransaction() { final List<Binding<EntityManager>> bindings = getInjector().findBindingsByType( TypeLiteral.get( EntityManager.class ) ); for ( final Binding<EntityManager> binding : bindings ) { final EntityManager em = binding.getProvider().get(); em.getTransaction().begin(); } }
public void contributeActions(XtextEditor editor) { List<Binding<IActionContributor>> bindingsByType = injector.findBindingsByType(TypeLiteral.get(IActionContributor.class)); for (Binding<IActionContributor> binding : bindingsByType) { IActionContributor actionContributor = injector.getInstance(binding.getKey()); actionContributor.contributeActions(editor); children.add(actionContributor); } }
public void initialize(IPreferenceStoreAccess access) { List<Binding<IPreferenceStoreInitializer>> list = injector.findBindingsByType(TypeLiteral .get(IPreferenceStoreInitializer.class)); for (Binding<IPreferenceStoreInitializer> binding : list) { IPreferenceStoreInitializer storeInitializer = injector.getInstance(binding.getKey()); storeInitializer.initialize(access); } }
private List<Pair<IdMatcher, Watcher>> getRegisteredWatchers() { ImmutableList.Builder<Pair<IdMatcher, Watcher>> registrationsBuilder = ImmutableList.builder(); List<Binding<GuiceWatcherRegistration>> guiceWatcherRegistrationBindings = injector.findBindingsByType(TypeLiteral.get(GuiceWatcherRegistration.class)); for (Binding<GuiceWatcherRegistration> watcherRegistrationBinding : guiceWatcherRegistrationBindings) { GuiceWatcherRegistration guiceWatcherRegistration = watcherRegistrationBinding.getProvider().get(); registrationsBuilder.add(new StrongPair<>(guiceWatcherRegistration.matcher(), guiceWatcherRegistration.watcher())); } return registrationsBuilder.build(); }
protected final void usesTransaction() { final List<Binding<DbCleaner>> bindings = getInjector().findBindingsByType( TypeLiteral.get( DbCleaner.class ) ); for ( final Binding<DbCleaner> binding : bindings ) { final DbCleaner cleaner = binding.getProvider().get(); cleaner.usesTransaction(); } }