Refine search
/** Returns true if the key type is Provider (but not a subclass of Provider). */ private static boolean isProvider(Key<?> key) { return key.getTypeLiteral().getRawType().equals(Provider.class); }
private static boolean isTypeLiteral(Key<?> key) { return key.getTypeLiteral().getRawType().equals(TypeLiteral.class); }
private <U> void _find(Class<U> type, List<ExtensionComponent<U>> result, Injector container) { for (Entry<Key<?>, Binding<?>> e : container.getBindings().entrySet()) { if (type.isAssignableFrom(e.getKey().getTypeLiteral().getRawType())) { Annotation a = annotations.get(e.getKey()); Object o = e.getValue().getProvider().get(); if (o!=null) { GuiceExtensionAnnotation gea = a!=null ? extensionAnnotations.get(a.annotationType()) : null; result.add(new ExtensionComponent<>(type.cast(o), gea != null ? gea.getOrdinal(a) : 0)); } } } }
/** Returns true if the key type is MembersInjector (but not a subclass of MembersInjector). */ private static boolean isMembersInjector(Key<?> key) { return key.getTypeLiteral().getRawType().equals(MembersInjector.class) && key.getAnnotationType() == null; }
private <T> void validateKey(Object source, Key<T> key) { Annotations.checkForMisplacedScopeAnnotations( key.getTypeLiteral().getRawType(), source, errors); }
@Inject public GuiceQueryPreProcessor(Injector injector) { m_preProcessors = new ArrayList<>(); Map<Key<?>, Binding<?>> bindings = injector.getAllBindings(); for (Key<?> key : bindings.keySet()) { Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (QueryPreProcessor.class.isAssignableFrom(bindingClass)) { m_preProcessors.add((QueryPreProcessor)injector.getInstance(bindingClass)); } } }
@Inject public HealthCheckServiceImpl(Injector injector) { checkNotNull(injector); Map<Key<?>, Binding<?>> bindings = injector.getAllBindings(); for (Key<?> key : bindings.keySet()) { Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (HealthStatus.class.isAssignableFrom(bindingClass)) { checks.add((HealthStatus) injector.getInstance(bindingClass)); } } }
public Config getPluginConfigProxy(Plugin plugin) { final Injector injector = plugin.getInjector(); for (Key<?> key : injector.getAllBindings().keySet()) { Class<?> type = key.getTypeLiteral().getRawType(); if (Config.class.isAssignableFrom(type)) { return (Config) injector.getInstance(key); } } return null; }
@Inject public GuiceCommandProvider(Injector injector) { Map<Key<?>, Binding<?>> bindings = injector.getAllBindings(); for (Key<?> key : bindings.keySet()) { Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (TelnetCommand.class.isAssignableFrom(bindingClass)) { TelnetCommand command = (TelnetCommand)injector.getInstance(bindingClass); m_commandMap.put(command.getCommand(), command); } } }
@Inject @SuppressWarnings("unchecked") public GuiceQueryPluginFactory(Injector injector) { m_injector = injector; Map<Key<?>, Binding<?>> bindings = injector.getAllBindings(); for (Key<?> key : bindings.keySet()) { Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (QueryPlugin.class.isAssignableFrom(bindingClass)) { PluginName ann = (PluginName) bindingClass.getAnnotation(PluginName.class); if (ann == null) throw new IllegalStateException("QueryPlugin class " + bindingClass.getName() + " does not have required annotation " + PluginName.class.getName()); m_plugins.put(ann.name(), (Class<QueryPlugin>)bindingClass); } } }
@Inject public BodyParserEngineManagerImpl(Injector injector) { Map<String, Provider<? extends BodyParserEngine>> map = Maps.newHashMap(); // Now lookup all explicit bindings, and find the ones that implement // BodyParserEngine for (Map.Entry<Key<?>, Binding<?>> binding : injector.getBindings() .entrySet()) { if (BodyParserEngine.class.isAssignableFrom(binding.getKey() .getTypeLiteral().getRawType())) { Provider<? extends BodyParserEngine> provider = (Provider) binding .getValue().getProvider(); map.put(provider.get().getContentType(), provider); } } this.contentTypeToBodyParserMap = ImmutableMap.copyOf(map); logBodyParserEngines(); }
@Inject public TemplateEngineManagerImpl(Injector injector) { Map<String, Provider<? extends TemplateEngine>> map = new HashMap<>(); // Now lookup all explicit bindings, and find the ones that implement // TemplateEngine for (Map.Entry<Key<?>, Binding<?>> binding : injector.getBindings() .entrySet()) { if (TemplateEngine.class.isAssignableFrom(binding.getKey() .getTypeLiteral().getRawType())) { Provider<? extends TemplateEngine> provider = (Provider) binding .getValue().getProvider(); map.put(provider.get().getContentType(), provider); } } this.contentTypeToTemplateEngineMap = ImmutableMap.copyOf(map); logTemplateEngines(); }
public void startServices() throws KairosDBException { Map<Key<?>, Binding<?>> bindings = m_injector.getAllBindings(); for (Key<?> key : bindings.keySet()) { Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (KairosDBService.class.isAssignableFrom(bindingClass)) { KairosDBService service = (KairosDBService) m_injector.getInstance(bindingClass); logger.info("Starting service " + bindingClass); service.start(); m_services.add(service); } } }
Processor(BindingImpl<T> binding) { source = binding.getSource(); key = binding.getKey(); rawType = key.getTypeLiteral().getRawType(); scoping = binding.getScoping(); }
@SuppressWarnings({"unchecked", "rawtypes" }) @Override public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) { return () -> { Map<Object, Object> scopedObjects = getScopedObjectMap(key); T current = (T) scopedObjects.get(key); if (current == null && !scopedObjects.containsKey(key)) { current = unscoped.get(); // don't remember proxies; these exist only to serve circular dependencies if (Scopes.isCircularProxy(current)) { return current; } scopedObjects.put(key, current); } if (current instanceof javax.inject.Provider) { if (!javax.inject.Provider.class.isAssignableFrom(key.getTypeLiteral().getRawType())) { return (T) ((javax.inject.Provider) current).get(); } } return current; }; }
private Set<Object> getBeans(Collection<Class<? extends Annotation>> annotations) { Set<Object> beans = U.set(); for (Map.Entry<Key<?>, Binding<?>> e : injector.getAllBindings().entrySet()) { Key<?> key = e.getKey(); Binding<?> value = e.getValue(); boolean include = false; if (U.notEmpty(annotations)) { if (key.getTypeLiteral() != null && key.getTypeLiteral().getRawType() != null) { Class<?> type = key.getTypeLiteral().getRawType(); if (Metadata.isAnnotatedAny(type, annotations)) { include = true; } } } else { include = true; } if (include) { beans.add(value.getProvider().get()); } } return beans; }
public List<Config> getPluginConfigProxies() { List<Injector> injectors = new ArrayList<>(); injectors.add(RuneLite.getInjector()); getPlugins().forEach(pl -> injectors.add(pl.getInjector())); List<Config> list = new ArrayList<>(); for (Injector injector : injectors) { for (Key<?> key : injector.getAllBindings().keySet()) { Class<?> type = key.getTypeLiteral().getRawType(); if (Config.class.isAssignableFrom(type)) { Config config = (Config) injector.getInstance(key); list.add(config); } } } return list; }
if (StringUtils.hasText(config) && !PathMatchingFilter.class.isAssignableFrom(key.getTypeLiteral().getRawType())) { throw new ConfigurationException("Config information requires a PathMatchingFilter - can't apply to " + key.getTypeLiteral().getRawType()); if (PathMatchingFilter.class.isAssignableFrom(key.getTypeLiteral().getRawType())) { bindPathMatchingFilter(castToPathMatching(key), filterToPathToConfig.get(key));
Class<?> bindingClass = key.getTypeLiteral().getRawType(); if (DataPointFactory.class.isAssignableFrom(bindingClass))
@Override public void configure(Binder binder) { for (Class clazz : mockableInjections) { binder.bind(clazz).toInstance(EasyMock.createNiceMock(clazz)); } for (Object obj : injectedObjs) { binder.bind((Class) obj.getClass()).toInstance(obj); } for (Key<?> key : mockableKeys) { binder.bind((Key<Object>) key).toInstance(EasyMock.createNiceMock(key.getTypeLiteral().getRawType())); } binder.bind(AuthConfig.class).toInstance(new AuthConfig()); } }