Return a dependency-injected instance
773577
def provide_with_default(self, name, default=None):
        
        return self.provider.instantiate_by_name_with_default(name, default_value=default)
666737
def bind(self, instance):
        

        p = self.clone()
        p.instance = weakref.ref(instance)
        return p
341179
def _instantiate(self, module, class_name,
                     args=None, kwargs=None, static=None):
        
        if args is None:
            args = []
        if kwargs is None:
            kwargs = {}
        if static is None:
            static = False

        _check_type('args', args, list)
        _check_type('kwargs', kwargs, dict)

        if static and class_name is None:
            return module

        if static and class_name is not None:
            return getattr(module, class_name)

        service_obj = getattr(module, class_name)

        # Replace scalars
        args = self._replace_scalars_in_args(args)
        kwargs = self._replace_scalars_in_kwargs(kwargs)

        # Replace service references
        args = self._replace_services_in_args(args)
        kwargs = self._replace_services_in_kwargs(kwargs)

        # Instantiate object
        return service_obj(*args, **kwargs)
592033
function createInternalInjector(cache, factory) {

    function getService(serviceName, caller) {
      if (cache.hasOwnProperty(serviceName)) {
        if (cache[serviceName] === INSTANTIATING) {
          throw $injectorMinErr('cdep', 'Circular dependency found: {0}',
                    serviceName + ' <- ' + path.join(' <- '));
        }
        return cache[serviceName];
      } else {
        try {
          path.unshift(serviceName);
          cache[serviceName] = INSTANTIATING;
          cache[serviceName] = factory(serviceName, caller);
          return cache[serviceName];
        } catch (err) {
          if (cache[serviceName] === INSTANTIATING) {
            delete cache[serviceName];
          }
          throw err;
        } finally {
          path.shift();
        }
      }
    }


    function injectionArgs(fn, locals, serviceName) {
      var args = [],
          $inject = createInjector.$$annotate(fn, strictDi, serviceName);

      for (var i = 0, length = $inject.length; i < length; i++) {
        var key = $inject[i];
        if (typeof key !== 'string') {
          throw $injectorMinErr('itkn',
                  'Incorrect injection token! Expected service name as string, got {0}', key);
        }
        args.push(locals && locals.hasOwnProperty(key) ? locals[key] :
                                                         getService(key, serviceName));
      }
      return args;
    }

    function isClass(func) {
      // Support: IE 9-11 only
      // IE 9-11 do not support classes and IE9 leaks with the code below.
      if (msie || typeof func !== 'function') {
        return false;
      }
      var result = func.$$ngIsClass;
      if (!isBoolean(result)) {
        // Support: Edge 12-13 only
        // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6156135/
        result = func.$$ngIsClass = /^(?:class\b|constructor\()/.test(stringifyFn(func));
      }
      return result;
    }

    function invoke(fn, self, locals, serviceName) {
      if (typeof locals === 'string') {
        serviceName = locals;
        locals = null;
      }

      var args = injectionArgs(fn, locals, serviceName);
      if (isArray(fn)) {
        fn = fn[fn.length - 1];
      }

      if (!isClass(fn)) {
        // http://jsperf.com/angularjs-invoke-apply-vs-switch
        // #5388
        return fn.apply(self, args);
      } else {
        args.unshift(null);
        return new (Function.prototype.bind.apply(fn, args))();
      }
    }


    function instantiate(Type, locals, serviceName) {
      // Check if Type is annotated and use just the given function at n-1 as parameter
      // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
      var ctor = (isArray(Type) ? Type[Type.length - 1] : Type);
      var args = injectionArgs(Type, locals, serviceName);
      // Empty object at position 0 is ignored for invocation with `new`, but required.
      args.unshift(null);
      return new (Function.prototype.bind.apply(ctor, args))();
    }


    return {
      invoke: invoke,
      instantiate: instantiate,
      get: getService,
      annotate: createInjector.$$annotate,
      has: function(name) {
        return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name);
      }
    };
  }
535950
def provide(self, cls):
        
        support.verify_class_type(cls, 'cls')
        if not self._is_injectable_fn(cls):
            provide_loc = locations.get_back_frame_loc()
            raise errors.NonExplicitlyBoundClassError(provide_loc, cls)
        try:
            return self._obj_provider.provide_class(
                cls, self._injection_context_factory.new(cls.__init__),
                direct_init_pargs=[], direct_init_kwargs={})
        except errors.Error as e:
            if self._use_short_stack_traces:
                raise e
            else:
                raise
583109
function () {
		var that = this,
				independent, 
				dependencyNotRequired;
		
		promiseIndependent = this.saveFixturesFromArray(independentFixtures);
		promiseDelayedDependency = this.saveFixturesFromArray(delayedDependencyFixtures);
		
		promise = Q.all([ promiseIndependent, promiseDelayedDependency ])
			.then(function(models) {
				return that.saveFixturesFromArray(requiredDependencyFixtures);
			});
		
		return promise;
	}
41363
public static ClassInjector getInstance(ClassLoader loader) {
        ClassInjector injector = null;

        synchronized (cShared) {
            Reference ref = (Reference)cShared.get(loader);
            if (ref != null) {
                injector = (ClassInjector)ref.get();
            }
            if (injector == null) {
                injector = new ClassInjector(loader);
                cShared.put(loader, new WeakReference(injector));
            }
            return injector;
        }
    }
1212673
def getInstance(cls, *args):
        '''
        
        '''
        if not cls.__singleton:
            cls.__singleton = Config(*args)
        return cls.__singleton
569396
protected @Nonnull <T> T inject(@Nonnull BeanResolutionContext resolutionContext, @Nullable BeanDefinition requestingBeanDefinition, @Nonnull T instance) {
        @SuppressWarnings("unchecked") Class<T> beanType = (Class<T>) instance.getClass();
        Optional<BeanDefinition<T>> concreteCandidate = findConcreteCandidate(beanType, null, false, true);
        if (concreteCandidate.isPresent()) {
            BeanDefinition definition = concreteCandidate.get();
            if (requestingBeanDefinition != null && requestingBeanDefinition.equals(definition)) {
                // bail out, don't inject for bean definition in creation
                return instance;
            }
            doInject(resolutionContext, instance, definition);
        }
        return instance;
    }
253631
def get_dependency_type(_type):
        
        if _type == DependencyTypes.AFTER:
            return 'after'
        elif _type == DependencyTypes.AFTER_ANY:
            return 'afterany'
        elif _type == DependencyTypes.AFTER_CORR:
            return 'aftercorr'
        elif _type == DependencyTypes.AFTER_NOT_OK:
            return 'afternotok'
        elif _type == DependencyTypes.AFTER_OK:
            return 'afterok'
        else:
            return None
1294719
private Object getBindingObjectInstance(Context c, Hashtable<?, ?> envmt, String className, ResourceInfo resourceRefInfo, Reference bindingRef, InjectionBinding<?> binding) throws Exception {
        Object bindingObject = binding.getBindingObject();
        if (bindingObject instanceof Reference) {
            // Handle special Reference.
            Reference ref = (Reference) bindingObject;

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "ref=" + ref.getClass().getName() + ", factory=" + ref.getFactoryClassName());

            if (ref == bindingRef) {
                throw new InjectionException(Tr.formatMessage(tc, "INDIRECT_LOOKUP_LOOP_CWNEN1008E"));
            }

            // A resource-ref to a data-source.  Propagate resource-ref info.
            if (ref instanceof ResourceFactoryReference) {
                ResourceFactoryReference factoryRef = (ResourceFactoryReference) ref;
                ResourceFactory factory = factoryRef.getResourceFactory();

                return factory.createResource(resourceRefInfo);
            }

            // An indirect reference to another indirect reference (e.g.,
            // resource-ref to data-source override).  Propagate resource-ref
            // info if necessary.
            if (ref instanceof IndirectReference) {
                IndirectReference indirectRef = (IndirectReference) ref;
                String refBindingName = indirectRef.bindingName;

                // resource-ref1 -> resource-ref2 -> data-source should use
                // resource-ref2's info.

                String refClassName = ref.getClassName();
                if (refClassName == null) {
                    refClassName = className;
                }

                ResourceInfo refResourceRefInfo = indirectRef.resourceInfo;
                if (refResourceRefInfo == null) {
                    refResourceRefInfo = resourceRefInfo;
                }

                return getObjectInstance(c, envmt, refClassName, refBindingName, refResourceRefInfo, indirectRef);
            }
        }

        // We could return null and use InitialContext.lookup, but that will
        // eventually call InjectionBinding.getInjectionObject anyway (assuming
        // non-conflicting JavaColonNamingHelper), so we might as well just make
        // the call while we have the InjectionBinding.  This also allows
        // @Resource(lookup="java:...") to work even if JNDI is disabled.
        return binding.getInjectionObject();
    }
827532
def cached(self, dependency):
        
        if dependency.threadlocal:
            return getattr(self._local, dependency.name, None)
        elif dependency.singleton:
            return self._singleton.get(dependency.name)
925806
function inject(moduleName) {
                    var localParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
                    var real = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];

                    var self = this,
                        deferred = $q.defer();
                    if (angular.isDefined(moduleName) && moduleName !== null) {
                        if (angular.isArray(moduleName)) {
                            var promisesList = [];
                            angular.forEach(moduleName, function (module) {
                                promisesList.push(self.inject(module, localParams, real));
                            });
                            return $q.all(promisesList);
                        } else {
                            self._addToLoadList(self._getModuleName(moduleName), true, real);
                        }
                    }
                    if (modulesToLoad.length > 0) {
                        var res = modulesToLoad.slice(); // clean copy
                        var loadNext = function loadNext(moduleName) {
                            moduleCache.push(moduleName);
                            modulePromises[moduleName] = deferred.promise;
                            self._loadDependencies(moduleName, localParams).then(function success() {
                                try {
                                    justLoaded = [];
                                    _register(providers, moduleCache, localParams);
                                } catch (e) {
                                    self._$log.error(e.message);
                                    deferred.reject(e);
                                    return;
                                }

                                if (modulesToLoad.length > 0) {
                                    loadNext(modulesToLoad.shift()); // load the next in list
                                } else {
                                        deferred.resolve(res); // everything has been loaded, resolve
                                    }
                            }, function error(err) {
                                deferred.reject(err);
                            });
                        };

                        // load the first in list
                        loadNext(modulesToLoad.shift());
                    } else if (localParams && localParams.name && modulePromises[localParams.name]) {
                        return modulePromises[localParams.name];
                    } else {
                        deferred.resolve();
                    }
                    return deferred.promise;
                }
754519
def inject( object )
      trip.object = object
      object.send :scorpion_hunt=, self

      object.injected_attributes.each do |attr|
        next if object.send "#{ attr.name }?"
        next if attr.lazy?

        object.send :inject_dependency, attr, fetch( attr.contract )
      end

      object.send :on_injected

      object
    end
870549
function createFromDependency(pluginName) {
    var npmID = PluginDependency.nameToNpmID(pluginName);
    var version = pkg.dependencies[npmID];

    return PluginDependency.create(pluginName, version);
}
859598
def get_injectable(name):
    
    i = get_raw_injectable(name)
    return i() if isinstance(i, _InjectableFuncWrapper) else i
1214836
private <T> T newInstance(DatastoreId id, DatastoreType datastoreType, DynamicType<?> types, TransactionalCache.Mode cacheMode) {
        validateType(types);
        InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler(datastoreType, getProxyMethodService());
        T instance = proxyFactory.createInstance(invocationHandler, types.getCompositeType());
        cache.put(id, instance, cacheMode);
        return instance;
    }