Provide an injector to getInstance classes where needed

@param provider class type
438231
public static void injectWith(Class<InjectionProvider> provider) {

		try {
			injectionProvider = (InjectionProvider) ClassFactory.newInstanceOf(provider);
			log.info("Registered injection provider: " + injectionProvider.getClass().getName());
		}
		catch (ClassFactoryException e) {
			log.error("Failed to instantiate injection provider: ", e);
			throw new IllegalArgumentException(e);
		}
	}
1168187
public <T extends RESTDataProvider> void registerProvider(Class<T> providerClass, Class<?> providerInterface) {
        try {
            final Constructor<T> constructor = providerClass.getConstructor(RESTProviderFactory.class);
            final T instance = constructor.newInstance(this);

            providerMap.put(providerClass, instance);
            if (providerInterface != null) {
                providerMap.put(providerInterface, instance);
            }
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
734587
private static boolean isProviderClass(Class<?> c)
    {
        return (c != null) && c.isAnnotationPresent(javax.ws.rs.ext.Provider.class);
    }
182635
public static <T> List<T> findServiceProviders( Class<T> klass )
    {
        ServiceLoader<T> loader = ServiceLoader.load( klass );
        List<T> providers = new ArrayList<T>();
        Iterator<T> it = loader.iterator();
        while ( it.hasNext() )
        {
            providers.add( it.next() );
        }
        return providers;
    }
182466
private static CacheProvider getCacheProvider(Method javaMethod) {
        if (!javaMethod.isAnnotationPresent(Cache.class)) {
            return null;
        }

        Cache an = javaMethod.getAnnotation(Cache.class);
        Class<? extends CacheProvider> cacheClazz = an.value();

        try {
            Constructor<? extends CacheProvider> constructor = cacheClazz.getDeclaredConstructor();
            constructor.setAccessible(true);
            return constructor.newInstance();
        } catch (Exception e) {
            throw new EventsException("Cannot instantiate cache provider "
                    + cacheClazz.getSimpleName() + " for method "
                    + Utils.methodToString(javaMethod), e);
        }
    }
717278
@Override
    public void init (Injector injector)
        throws Exception
    {
        super.init(injector);

        // configure the client manager to use our bits
        _clmgr.setDefaultSessionFactory(new SessionFactory() {
            @Override
            public Class<? extends PresentsSession> getSessionClass (AuthRequest areq) {
                return CrowdSession.class;
            }
            @Override
            public Class<? extends ClientResolver> getClientResolverClass (Name username) {
                return CrowdClientResolver.class;
            }
        });
    }
577925
private <T> Provider<T> createProvider(Key<T> key)
  {
    Class<T> type = (Class<T>) key.rawClass();

    if (Provider.class.equals(type)) {
      TypeRef subType = TypeRef.of(key.type()).to(Provider.class).param(0);

      Key<Object> subkey = Key.of(subType.type(), key.annotationTypes());

      return (Provider) new ProviderProvider(key, -10, provider(subkey));
    }
    else if (Optional.class.equals(type)) {
      TypeRef subType = TypeRef.of(key.type()).to(Optional.class).param(0);

      Key<Object> subkey = Key.of(subType.type(), key.annotationTypes());

      return (Provider) new ProviderOptional(key, -10, provider(subkey));
    }
    else if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
      return new ProviderNull(key, -10000, new InjectScopeSingleton());
    }

    int priority = -10;

    // auto-provider is factory
    InjectScope<T> scope = findScope(type);

    BindingAmp<T> binding = new ProviderConstructor<>(this, key, priority, scope, type);

    binding.bind();

    return binding.provider();
  }
773303
def bind_to_provider(self, cls, provider):
        """"""
        self._check_class(cls)
        if provider is None:
            raise InjectorException('Provider cannot be None, key=%s' % cls)

        self._bindings[cls] = provider
        logger.debug('Bound %s to a provider %s', cls, provider)
        return self
1352467
public static InjectionProvider<?>[] providersForInstancesSuppliers(final InjectionProviderInstancesSupplier... suppliers) {
        final InjectionProviderInstancesSupplier supplier = mergeSuppliers(suppliers);
        return supplier.get().toArray(new InjectionProvider<?>[supplier.get().size()]);
    }
160440
private void generateInjectAdapter(TypeElement type, ExecutableElement constructor,
      List<Element> fields) throws IOException {
    String packageName = getPackage(type).getQualifiedName().toString();
    TypeMirror supertype = getApplicationSupertype(type);
    if (supertype != null) {
      supertype = processingEnv.getTypeUtils().erasure(supertype);
    }
    ClassName injectedClassName = ClassName.get(type);
    ClassName adapterClassName = adapterName(injectedClassName, INJECT_ADAPTER_SUFFIX);

    boolean isAbstract = type.getModifiers().contains(ABSTRACT);
    boolean injectMembers = !fields.isEmpty() || supertype != null;
    boolean disambiguateFields = !fields.isEmpty()
        && (constructor != null)
        && !constructor.getParameters().isEmpty();
    boolean dependent = injectMembers
        || ((constructor != null) && !constructor.getParameters().isEmpty());

    TypeSpec.Builder result = TypeSpec.classBuilder(adapterClassName.simpleName())
        .addOriginatingElement(type)
        .addModifiers(PUBLIC, FINAL)
        .superclass(ParameterizedTypeName.get(ClassName.get(Binding.class), injectedClassName))
        .addJavadoc("$L", bindingTypeDocs(injectableType(type.asType()), isAbstract,
            injectMembers, dependent).toString());

    for (Element field : fields) {
      result.addField(memberBindingField(disambiguateFields, field));
    }
    if (constructor != null) {
      for (VariableElement parameter : constructor.getParameters()) {
        result.addField(parameterBindingField(disambiguateFields, parameter));
      }
    }
    if (supertype != null) {
      result.addField(supertypeBindingField(supertype));
    }

    result.addMethod(writeInjectAdapterConstructor(constructor, type, injectedClassName));
    if (dependent) {
      result.addMethod(attachMethod(
          constructor, fields, disambiguateFields, injectedClassName, supertype, true));
      result.addMethod(getDependenciesMethod(
          constructor, fields, disambiguateFields, supertype, true));
    }
    if (constructor != null) {
      result.addMethod(
          getMethod(constructor, disambiguateFields, injectMembers, injectedClassName));
    }
    if (injectMembers) {
      result.addMethod(
          membersInjectMethod(fields, disambiguateFields, injectedClassName, supertype));
    }

    JavaFile javaFile = JavaFile.builder(packageName, result.build())
        .addFileComment(AdapterJavadocs.GENERATED_BY_DAGGER)
        .build();
    javaFile.writeTo(processingEnv.getFiler());
  }
831199
public static <T> T getInstance(Class<T> clazz) {
        Objects.requireNonNull(clazz, Required.CLASS.toString());

        return injector.getInstance(clazz);
    }
297920
@Override
    public InjectionBinding<WebServiceRef> createOverrideInjectionBinding(Class<?> instanceClass, Member member,
                                                                          Resource resource, String jndiName) throws InjectionException {

        Class<?> typeClass = resource.type();

        if (member != null) {
            Class<?> inferredType = InjectionHelper.getTypeFromMember(member);
            if (typeClass.getName().equals(Object.class.getName())) { //default
                typeClass = inferredType;
            } else {
                if (!inferredType.isAssignableFrom(typeClass)) {
                    Tr.error(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                             member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName());
                    throw new InjectionException(Tr.formatMessage(tc, "error.service.ref.member.level.annotation.type.not.compatible",
                                                                  member.getName(), member.getDeclaringClass().getName(), typeClass.getName(), inferredType.getName()));
                }
            }
        }

        InjectionBinding<WebServiceRef> binding;

        //only service type injections are possible with the @Resource annotation
        if (Service.class.isAssignableFrom(typeClass)) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found has type=" + typeClass.getName() + " and is refers to a JAX-WS service reference");
            }
            binding = WebServiceRefBindingBuilder.createWebServiceRefBindingFromResource(resource, ivNameSpaceConfig, typeClass, jndiName);
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "The @Resource annotation found did not refer to a web service reference type.");
            }
            binding = null;
        }

        return binding;
    }
307574
private static Object injectAndPostConstruct(Object injectionProvider, Class Klass, List injectedBeanStorage)
    {
        Object instance = null;
        if (injectionProvider != null)
        {
            try
            {

                Object managedObject = _FactoryFinderProviderFactory.INJECTION_PROVIDER_INJECT_CLASS_METHOD.invoke(injectionProvider, Klass);

                instance = _FactoryFinderProviderFactory.MANAGED_OBJECT_GET_OBJECT_METHOD.invoke(managedObject, null);

                if (instance != null) {

                    Object creationMetaData = _FactoryFinderProviderFactory.MANAGED_OBJECT_GET_CONTEXT_DATA_METHOD.invoke
                                    (managedObject, CreationalContext.class);

                    addBeanEntry(instance, creationMetaData, injectedBeanStorage);

                    _FactoryFinderProviderFactory.INJECTION_PROVIDER_POST_CONSTRUCT_METHOD.invoke(
                                                                                                  injectionProvider, instance, creationMetaData);
                }
            } catch (Exception ex)
            {
                throw new FacesException(ex);
            }
        }
        return instance;
    }
1176551
@Override
    public Injector getInjector(AbstractModule... modules) {
        List<Module> moduleList = getModuleList(modules);

        // Add EurekaModule for any plugins which require it.
        // Currently needed only for ndbench-evcache-plugins, but we don't add EurekaModule to module-level
        // because choice of LookupService impl should be made at application level to avoid conflicts from
        // different modules creating different LookupService implementations.
        String discoveryEnv = System.getenv(NdBenchConstants.DISCOVERY_ENV);
        if(StringUtils.isBlank(discoveryEnv) || discoveryEnv == "local"){
            moduleList.add(Modules.override(new EurekaModule()).with(new AbstractModule() {
                @Override
                protected void configure() {
                    // Default EurekaInstanceConfig is CloudInstanceConfig, which works only in AWS env.
                    // When not in AWS, override to use MyDataCenterInstanceConfig instead.
                    bind(EurekaInstanceConfig.class).toProvider(MyDataCenterInstanceConfigProvider.class).in(Scopes.SINGLETON);
                }
            }));
        } else {
            moduleList.add(new EurekaModule());
        }

        Injector injector = Guice.createInjector(moduleList);
        injector.getInstance(IConfiguration.class).initialize();
        return injector;
    }
824081
protected @Nonnull <T> Provider<T> getBeanProvider(@Nullable BeanResolutionContext resolutionContext, @Nonnull Class<T> beanType) {
        return getBeanProvider(resolutionContext, beanType, null);
    }
304147
@SuppressWarnings("unchecked")
	public <T> RestBuilder addProvider(Class<? extends ContextProvider<T>> provider) {

		Assert.notNull(provider, "Missing context provider!");
		registeredProviders.put(null, provider);
		return this;
	}
773614
public static void initialize(SingletonProvider instance) {
        synchronized (SingletonProvider.class) {
            if (INSTANCE == null) {
                INSTANCE = instance;
            } else {
                throw new RuntimeException("SingletonProvider is already initialized with " + INSTANCE);
            }
        }
    }