default <T> Provider<T> provider(Injector injector, InjectionPoint<T> ip) { return provider(injector, ip.key()); } }
/** * Create a provider based on registered auto-binders. */ private <T> Provider<T> autoProvider(InjectionPoint<T> ip) { for (InjectAutoBind autoBind : _autoBind) { Provider<T> provider = autoBind.provider(this, ip); if (provider != null) { return provider; } } return providerDefault(ip.key()); }
/** * Creates an instance provider for a given InjectionPoint, such as a * method or field. */ @Override public <T> Provider<T> provider(InjectionPoint<T> ip) { Objects.requireNonNull(ip); Provider<T> provider = lookupProvider(ip); if (provider != null) { return provider; } provider = autoProvider(ip); if (provider != null) { return provider; } return new ProviderNull(ip.key(), -10000, new InjectScopeSingleton()); }
@Service public Object service(InjectionPoint ip) Class<?> type = ip.key().rawClass();
@Override public <T> Provider<T> provider(Injector manager, InjectionPoint<T> ip) { Service service = ip.annotation(Service.class); Class<T> rawClass = ip.key().rawClass(); if (service == null) { service = metaService(ip.key()); } if (service == null) { service = rawClass.getAnnotation(Service.class); } if (service == null) { return null; } String address = getManager().address(rawClass, service.value()); if (address != null && ! address.isEmpty()) { T proxy = getManager().service(address).as(rawClass); return ()->proxy; } else { return null; } }
@Override public <T> Provider<T> provider(Injector injector, InjectionPoint<T> ip) { Var var = ip.annotation(Var.class); if (var == null) { return null; } String name = var.value(); if (name.isEmpty()) { name = ip.name(); } String defaultValue = var.defaultValue(); return new ProviderVar<T>((InjectorAmp) injector, (Class<T>) ip.key().type(), name, defaultValue); }
/** * Create a provider for an injection point. */ private <T> Provider<T> lookupProvider(InjectionPoint<T> ip) { Key<T> key = ip.key(); BindingInject<T> bean = findBean(key); if (bean != null) { return bean.provider(ip); } BindingAmp<T> provider = findBinding(key); if (provider != null) { return provider.provider(ip); } provider = findObjectBinding(key); if (provider != null) { return provider.provider(ip); } return null; }