Inject everything that can be injected. This method is intentionally not synchronized. If we
locked while injecting members (ie. running user code), things would deadlock should the user
code build a just-in-time binding from another thread.
506941
private void injectDynamically() {
    injectionRequestProcessor.injectMembers();
    stopwatch.resetAndLog("Static member injection");

    initializer.injectAll(errors);
    stopwatch.resetAndLog("Instance injection");
    errors.throwCreationExceptionIfErrorsExist();

    if (shellBuilder.getStage() != Stage.TOOL) {
      for (InjectorShell shell : shells) {
        loadEagerSingletons(shell.getInjector(), shellBuilder.getStage(), errors);
      }
      stopwatch.resetAndLog("Preloading singletons");
    }
    errors.throwCreationExceptionIfErrorsExist();
  }
1032584
private BasicInjectionTarget<T> prepareInjectionTarget(BasicInjectionTarget<T> injectionTarget) {
        try {
            postProcess(initialize(validate(injectionTarget)));
            return injectionTarget;
        } catch (Throwable e) {
            throw new IllegalArgumentException(e);
        }
    }
346155
def configure_once(config=None, bind_in_runtime=True):
    """"""
    with _INJECTOR_LOCK:
        if _INJECTOR:
            return _INJECTOR

        return configure(config, bind_in_runtime=bind_in_runtime)
274872
public void initializeAll(InjectionManager injectionManager) {
        if (injectionManager != null) {
            for (Converter<?> converter : _converters) {
                Field[] fields = ReflectionUtils.getFields(converter.getClass(), Inject.class);
                for (Field field : fields) {
                    final Object value;
                    if (field.getType() == Converter.class) {
                        // Injected converters are used as callbacks. They
                        // should be assigned to the outer converter, which is
                        // this.
                        value = this;
                    } else {
                        InjectionPoint<Object> injectionPoint = new MemberInjectionPoint<Object>(field, converter);
                        value = injectionManager.getInstance(injectionPoint);
                    }
                    field.setAccessible(true);
                    try {
                        field.set(converter, value);
                    } catch (Exception e) {
                        throw new IllegalStateException("Could not initialize converter: " + converter, e);
                    }
                }
            }
        }
    }
1048632
public static boolean hasInject(MemberLiteral<?, ?> member) {
    return member.isAnnotationPresent(Inject.class)
        || member.isAnnotationPresent(javax.inject.Inject.class);
  }
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;
    }
550562
void outputStaticInjectionMethods(Class<?> type, FragmentMap fragments,
      NameGenerator nameGenerator, SourceWriteUtil sourceWriteUtil) {
    String methodName = nameGenerator.convertToValidMemberName("injectStatic_" + type.getName());
    SourceSnippetBuilder body = new SourceSnippetBuilder();
    for (InjectionPoint injectionPoint : InjectionPoint.forStaticMethodsAndFields(type)) {
      Member member = injectionPoint.getMember();
      try {
        List<InjectorMethod> staticInjectionHelpers = new ArrayList<InjectorMethod>();

        if (member instanceof Method) {
          MethodLiteral<?, Method> method =
              MethodLiteral.get((Method) member, TypeLiteral.get(member.getDeclaringClass()));
          body.append(methodCallUtil.createMethodCallWithInjection(method, null, nameGenerator,
              staticInjectionHelpers));
        } else if (member instanceof Field) {
          FieldLiteral<?> field =
              FieldLiteral.get((Field) member, TypeLiteral.get(member.getDeclaringClass()));
          body.append(sourceWriteUtil.createFieldInjection(field, null, nameGenerator,
              staticInjectionHelpers));
        }

        outputMethods(staticInjectionHelpers, fragments);
      } catch (NoSourceNameException e) {
        errorManager.logError(e.getMessage(), e);
      }
    }

    // Note that the top-level method that performs static injection will only
    // invoke a bunch of other injector methods.  Therefore, it doesn't matter
    // which package it goes in, and we don't need to invoke getUserPackageName
    // (which is good, because in practice users statically inject types that
    // have no user package name because they're private inner classes!)
    String packageName = type.getPackage().getName();
    InjectorMethod method = SourceSnippets.asMethod(false, "private void " + methodName + "()",
        packageName, body.build());
    GinjectorFragmentOutputter fragment =
        fragments.get(fragmentPackageNameFactory.create(packageName));
    fragment.outputMethod(method);
    fragment.invokeInInitializeStaticInjections(methodName);
  }
566478
void performJavaNameSpaceBinding() throws InjectionException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "performJavaNameSpaceBinding: " + this);

        for (InjectionBinding<A> injectionBinding : ivAllAnnotationsCollection.values())
        {
            // F743-31682 - Only bind to java:global/:app/:module if needed.
            if (injectionBinding.getInjectionScope() == InjectionScope.COMP ||
                ivContext.ivBindNonCompInjectionBindings)
            {
                if (injectionBinding.getBindingObject() == null)
                {
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "skipping empty " + injectionBinding);
                }
                else
                {
                    injectionBinding.bindInjectedObject();
                }
            }
            else
            {
                if (isTraceOn && tc.isEntryEnabled())
                    Tr.debug(tc, "skipping non-java:comp " + injectionBinding.toSimpleString());
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "performJavaNameSpaceBinding");
    }
558790
@Override
  public <T> void inject(T obj, Scope scope) {
    Class<? super T> currentClass = (Class<T>) obj.getClass();
    do {
      MemberInjector<? super T> memberInjector = MemberInjectorLocator.getMemberInjector(currentClass);
      if (memberInjector != null) {
        memberInjector.inject(obj, scope);
        return;
      } else {
        currentClass = currentClass.getSuperclass();
      }
    } while (currentClass != null);
  }
1296800
void injectSession(Class<?>[] parameterTypes, List<Object> arguments, T session) {
		if (parameterTypes != null) {
			int i = 0;
			for (Class<?> parameterType : parameterTypes) {
				if (parameterType.isInstance(session)) {
					arguments.set(i, session);
					break;
				}
				i++;
			}
		}
	}
420986
public final void addInjectionBinding(InjectionBinding<A> injectionBinding)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isDebugEnabled())
            Tr.debug(tc, "addInjectionBinding: " + injectionBinding);

        // jndi name not found in collection, simple add
        ivAllAnnotationsCollection.put(injectionBinding.getJndiName(), injectionBinding);
    }
905254
private void injectCache(IntConsumer cacheAware) {
      if (cacheAware instanceof CacheAware) {
         ((CacheAware) cacheAware).injectCache(registry.getComponent(Cache.class));
      }
   }
922381
protected void inject(Collection<? extends Expression> objs) {
        for (Object o : objs) {
            if (o == null) {
                continue;
            }

            injector.injectMembers(o);
        }
    }
995699
@Override
    public <T> void aroundInject(final InjectionContext<T> injectionContext) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Annotations: " + injectionContext.getAnnotatedType());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Perform EE injection.");
        }
        injectJavaEEResources(injectionContext);

        // perform Weld injection
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                injectionContext.proceed();
                return null;
            }

        });

    }
480296
def inject(self):
        """"""
        if self.is_injected():
            return False

        with open(self, mode="a+") as fp:
            fp.seek(0)
            fp.write("\n".join([
                "",
                "try:",
                "    import pout",
                "except ImportError:",
                "    pass",
                "else:",
                "    pout.inject()",
                "",
            ]))

        return True
875355
public boolean injectionPossible(Class<?> component) {
        String name = component.getName();
        LOGGER.debug("Try to find class {} in bundle {}", name, bundleContext.getBundle().getSymbolicName());
        String searchString = name.replaceAll("\\$\\$.*", "");
        searchString = searchString.replaceAll("\\$", "\\\\\\$"); // for nested and anonymous classes
        if (bundleResources.matches(".*" + searchString + ".*")) {
            LOGGER.trace("Found class {} in bundle {}", name, bundleContext.getBundle().getSymbolicName());
            return true;
        }
        LOGGER.trace("Class {} not available in bundle {}", name, bundleContext.getBundle().getSymbolicName());
        return false;
    }
187964
@Override
    public void registerInjectionTargetListener(WebSphereInjectionTargetListener<?> listener) {
        Object instance = listener.getObject();
        injectionTargetListeners.put(instance, listener);
    }