Bind initial object instances to the DI container.
323834
protected function bindInitialInstances(ContainerInterface $container)
	{
		foreach($this->komponents as $komponent)
		{
			$container->bindInstance(get_class($komponent), $komponent);
		}
	}
797632
def bind(*args):
    """"""
    if _debug: bind._debug("bind %r", args)

    # generic bind is pairs of names
    if not args:
        # find unbound clients and bind them
        for cid, client in client_map.items():
            # skip those that are already bound
            if client.clientPeer:
                continue

            if not cid in server_map:
                raise RuntimeError("unmatched server {!r}".format(cid))
            server = server_map[cid]

            if server.serverPeer:
                raise RuntimeError("server already bound %r".format(cid))

            bind(client, server)

        # see if there are any unbound servers
        for sid, server in server_map.items():
            if server.serverPeer:
                continue

            if not sid in client_map:
                raise RuntimeError("unmatched client {!r}".format(sid))
            else:
                raise RuntimeError("mistery unbound server {!r}".format(sid))

        # find unbound application service elements and bind them
        for eid, element in element_map.items():
            # skip those that are already bound
            if element.elementService:
                continue

            if not eid in service_map:
                raise RuntimeError("unmatched element {!r}".format(cid))
            service = service_map[eid]

            if server.serverPeer:
                raise RuntimeError("service already bound {!r}".format(cid))

            bind(element, service)

        # see if there are any unbound services
        for sid, service in service_map.items():
            if service.serviceElement:
                continue

            if not sid in element_map:
                raise RuntimeError("unmatched service {!r}".format(sid))
            else:
                raise RuntimeError("mistery unbound service {!r}".format(sid))

    # go through the argument pairs
    for i in xrange(len(args)-1):
        client = args[i]
        if _debug: bind._debug("    - client: %r", client)
        server = args[i+1]
        if _debug: bind._debug("    - server: %r", server)

        # make sure we're binding clients and servers
        if isinstance(client, Client) and isinstance(server, Server):
            client.clientPeer = server
            server.serverPeer = client

        # we could be binding application clients and servers
        elif isinstance(client, ApplicationServiceElement) and isinstance(server, ServiceAccessPoint):
            client.elementService = server
            server.serviceElement = client

        # error
        else:
            raise TypeError("bind() requires a client and server")

        if _debug: bind._debug("    - bound")
912509
public void bind() throws Throwable
   {
      if (name == null)
         throw new IllegalArgumentException("Name is null");

      if (obj == null)
         throw new IllegalArgumentException("Obj is null");

      if (trace)
         log.trace("Binding " + obj.getClass().getName() + " under " + name);

      Properties properties = new Properties();
      properties.setProperty(Context.PROVIDER_URL, jndiProtocol + "://" + jndiHost + ":" + jndiPort);
      Context context = new InitialContext(properties);

      try
      {
         String className = obj.getClass().getName();
         Reference ref = new Reference(className,
                                       new StringRefAddr("class", className),
                                       JndiBinder.class.getName(),
                                       null);
         ref.add(new StringRefAddr("name", name));

         objs.put(name, obj);

         Util.bind(context, name, ref);

         if (log.isDebugEnabled())
            log.debug("Bound " + obj.getClass().getName() + " under " + name);
      }
      finally
      {
         if (context != null)
         {
            try
            {
               context.close();
            }
            catch (NamingException ne)
            {
               // Ignore
            }
         }
      }
   }
828542
private void init()
    {
        this.container = InfinispanCache.findCacheContainer();
        if (this.container == null) {
            try {
                this.container = new DefaultCacheManager(this.getClass().getResourceAsStream(
                                "/org/efaps/util/cache/infinispan-config.xml"));
                if (this.container instanceof EmbeddedCacheManager) {
                    this.container.addListener(new CacheLogListener(InfinispanCache.LOG));
                }
                InfinispanCache.bindCacheContainer(this.container);
                final Cache<String, Integer> cache = this.container
                                .<String, Integer>getCache(InfinispanCache.COUNTERCACHE);
                cache.put(InfinispanCache.COUNTERCACHE, 1);
            } catch (final FactoryConfigurationError e) {
                InfinispanCache.LOG.error("FactoryConfigurationError", e);
            } catch (final IOException e) {
                InfinispanCache.LOG.error("IOException", e);
            }
        } else {
            final Cache<String, Integer> cache = this.container
                            .<String, Integer>getCache(InfinispanCache.COUNTERCACHE);
            Integer count = cache.get(InfinispanCache.COUNTERCACHE);
            if (count == null) {
                count = 1;
            } else {
                count = count + 1;
            }
            cache.put(InfinispanCache.COUNTERCACHE, count);
        }
    }
766213
public static void onStartup(String container, Object containerContext) {
        try {
            startedUp = false;
            logger = LoggerUtil.getStandardLogger();
            containerName = container;

            // use reflection to avoid build-time dependencies
            String pluginPackage = MdwDataSource.class.getPackage().getName() + "." + containerName.toLowerCase();
            String namingProviderClass = pluginPackage + "." + containerName + "Naming";
            namingProvider = Class.forName(namingProviderClass).asSubclass(NamingProvider.class).newInstance();
            logger.info("Naming Provider: " + namingProvider.getClass().getName());

            String ds = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_DATASOURCE_PROVIDER);
            if (ds == null)
                ds = PropertyManager.getProperty("mdw.container.datasource_provider"); // compatibility
            if (StringHelper.isEmpty(ds) || ds.equals(DataSourceProvider.TOMCAT)) {
                dataSourceProvider = new TomcatDataSource();
            } else if (DataSourceProvider.MDW.equals(ds)){
                dataSourceProvider = new MdwDataSource();
            } else {
                String dsProviderClass = pluginPackage + "." + ds + "DataSource";
                dataSourceProvider = Class.forName(dsProviderClass).asSubclass(DataSourceProvider.class).newInstance();
            }
            logger.info("Data Source Provider: " + dataSourceProvider.getClass().getName());

            String jms = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_JMS_PROVIDER);
            if (jms == null)
                jms = PropertyManager.getProperty("mdw.container.jms_provider"); // compatibility
            if (StringHelper.isEmpty(jms))
                jms = JmsProvider.ACTIVEMQ;

            if (JmsProvider.ACTIVEMQ.equals(jms)) {
                if (jmsProvider == null) {
                    // use below to avoid build time dependency
                    jmsProvider = Class.forName("com.centurylink.mdw.container.plugin.activemq.ActiveMqJms").asSubclass(JmsProvider.class).newInstance();
                }
            }
            else {
                String jmsProviderClass = pluginPackage + "." + jms + "Jms";
                jmsProvider = Class.forName(jmsProviderClass).asSubclass(JmsProvider.class).newInstance();
            }

            logger.info("JMS Provider: " + (jmsProvider==null?"none":jmsProvider.getClass().getName()));

            String tp = PropertyManager.getProperty(PropertyNames.MDW_CONTAINER_THREADPOOL_PROVIDER);
            if (tp == null)
                tp = PropertyManager.getProperty("mdw.container.threadpool_provider"); // compatibility
            if (StringHelper.isEmpty(tp) || ThreadPoolProvider.MDW.equals(tp)) {
                threadPoolProvider = new CommonThreadPool();
                MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                ObjectName mbeanName = new ObjectName("com.centurylink.mdw.container.plugin:type=CommonThreadPool,name=MDW Thread Pool Info");
                if (!mbs.isRegistered(mbeanName))
                    mbs.registerMBean(threadPoolProvider, mbeanName);
            }
            else {
                String tpProviderClass = pluginPackage + "." + tp + "ThreadPool";
                threadPoolProvider = Class.forName(tpProviderClass).asSubclass(ThreadPoolProvider.class).newInstance();
            }
            logger.info("Thread Pool Provider: " + threadPoolProvider.getClass().getName());

            startedUp = true;
            startupTime = new Date();
        }
        catch (Exception ex) {
            throw new StartupException("Failed to initialize ApplicationContext", ex);
        }
    }
901553
private static void initIfNeeded()
   {
      if (!INITIALIZED)
      {
         synchronized (JCRAPIAspect.class)
         {
            if (!INITIALIZED)
            {
               ExoContainer container = ExoContainerContext.getTopContainer();
               JCRAPIAspectConfig config = null;
               if (container != null)
               {
                  config = (JCRAPIAspectConfig)container.getComponentInstanceOfType(JCRAPIAspectConfig.class);
               }
               if (config == null)
               {
                  TARGET_INTERFACES = new Class<?>[]{};
                  LOG.warn("No interface to monitor could be found");
               }
               else
               {
                  TARGET_INTERFACES = config.getTargetInterfaces();
                  for (Class<?> c : TARGET_INTERFACES)
                  {
                     Statistics global = new Statistics(null, "global");
                     Map<String, Statistics> statistics = new TreeMap<String, Statistics>();
                     Method[] methods = c.getMethods();
                     for (Method m : methods)
                     {
                        String name = getStatisticsName(m);
                        statistics.put(name, new Statistics(global, name));
                     }
                     JCRStatisticsManager.registerStatistics(c.getSimpleName(), global, statistics);
                     ALL_STATISTICS.put(c.getSimpleName(), statistics);
                  }
               }
               INITIALIZED = true;
            }
         }
      }
   }
673786
private void writeInitializers(
      GinjectorBindings bindings,
      StringBuilder initializeEagerSingletonsBody, StringBuilder initializeStaticInjectionsBody,
      SourceWriteUtil sourceWriteUtil, SourceWriter writer) {

    if (bindings.hasEagerSingletonBindingInSubtree()) {
      sourceWriteUtil.writeMethod(writer,
          "public void initializeEagerSingletons()", initializeEagerSingletonsBody.toString());
    }

    if (bindings.hasStaticInjectionRequestInSubtree()) {
      sourceWriteUtil.writeMethod(writer,
          "public void initializeStaticInjections()", initializeStaticInjectionsBody.toString());
    }
  }
783003
public static function initialize()
	{
		if (static::$initialized)
		{
			throw new RuntimeException('Container can only be initialized once');
		}

		// get the Dependency Container instance
		$dic = static::getDic();

		\Config::load('dependency', true);

		// setup the autoloader if none was set yet
		try
		{
			$loader = $dic->resolve('autoloader');

			if ($loader instanceof \Fuel\Core\Autoloader)
			{
				throw new ResolveException;
			}
		}
		catch (ResolveException $e)
		{
			// Check whether there is a VENDORPATH
			if ( ! defined('VENDORPATH'))
			{
				throw new RuntimeException('Container must be initialized in Fuel context');
			}

			// fetch the composer autoloader instance
			$loader = require VENDORPATH.'autoload.php';

			// allow the framework to access the composer autoloader
			$dic->inject('autoloader', $loader);
		}

		// get all defined namespaces
		$prefixes = array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4());

		// scan all composer packages loaded for the presence of FuelServiceProviders
		foreach ($prefixes as $namespace => $paths)
		{
			// does this package define a service provider
			if (class_exists($class = trim($namespace,'\\').'\\Providers\\FuelServiceProvider'))
			{
				// register it with the DiC
				$dic->registerService(new $class);
			}
		}

		// register service providers defined in config
		foreach (\Config::get('dependency.services', []) as $service)
		{
			$service = new $service;

			$dic->registerService($service);
		}

		// register resources defined in config
		foreach (\Config::get('dependency.resources', []) as $identifier => $resource)
		{
			$dic->register($identifier, $resource);
		}

		// register singleton resources defined in config
		foreach (\Config::get('dependency.singletons', []) as $identifier => $singleton)
		{
			$dic->registerSingleton($identifier, $singleton);
		}

		// register extensions defined in config
		foreach (\Config::get('dependency.extensions', []) as $identifier => $extension)
		{
			$dic->extension($identifier, $extension);
		}

		// mark we're initialized
		static::$initialized = true;
	}
1186206
public void load(Properties map, DynamicInitializer<C> di) throws ClassNotFoundException {
        load(map, di, /* assign key? */ false);
    }
1209753
protected static function initDependencyInjection()
    {
        /*
         * Create instances of required classes
         * Create instance of Doozr_Di_Map_Static and pass required classes as arguments to constructor
         * The Di-Map builder requires two objects Collection + Importer
         */
        $collection = new Doozr_Di_Collection();
        $importer   = new Doozr_Di_Importer_Json();
        $dependency = new Doozr_Di_Dependency();
        $map        = new Doozr_Di_Map_Static($collection, $importer, $dependency);

        // Generate map from static JSON map of Doozr
        $map->generate(self::$registry->getParameter('doozr.directory.root').'Data/Private/Config/.map.json');

        // Create container and set factory and map
        $container = Doozr_Di_Container::getInstance();
        $container
            ->factory(
                new Doozr_Di_Factory(self::$registry)
            )
            ->map($map);

        // Doozr's only Di container. We don't use any other. All Id's + instances shared static!
        self::$registry->setContainer($container);

        // Important for bootstrap result
        return true;
    }
846576
private synchronized void initialize() {
        Iterator types = EntityTypesLocator.getEntityTypes().getAllEntityTypes();
        String factoryName = null;

        while (types.hasNext()) {
            Class type = (Class) types.next();
            if (type != Object.class) {
                String factoryKey =
                        "org.apereo.portal.services.EntityNameFinderService.NameFinderFactory.implementation_"
                                + type.getName();
                try {
                    factoryName = PropertiesManager.getProperty(factoryKey);
                } catch (Exception runtime) {
                    String dMsg =
                            "EntityNameFinderService.initialize(): "
                                    + "could not find property for "
                                    + type.getName()
                                    + " factory.";
                    log.debug(dMsg);
                }
                if (factoryName != null) {
                    try {
                        IEntityNameFinderFactory factory =
                                (IEntityNameFinderFactory) Class.forName(factoryName).newInstance();
                        getNameFinders().put(type, factory.newFinder());
                    } catch (Exception e) {
                        String eMsg =
                                "EntityNameFinderService.initialize(): "
                                        + "Could not instantiate finder for "
                                        + type.getName()
                                        + ": ";
                        log.error(eMsg, e);
                    }
                }
            }
        }
        setInitialized(true);
    }
921598
def _post_init(self, name, container=None):
        
        self.name = name
        self.container = container
1285601
def map_init(interface, params):
    """"""
    import numpy as np
    import random
    np.random.seed(params['seed'])
    random.seed(params['seed'])
    return params
1306479
protected function initializeObject()
    {
        $assetValidatorImplementationClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface(AssetValidatorInterface::class);
        foreach ($assetValidatorImplementationClassNames as $assetValidatorImplementationClassName) {
            $this->addValidator($this->objectManager->get($assetValidatorImplementationClassName));
        }
    }
1001539
def initChild(cls, obj, name, subContext, parent = None):
    """"""
    addr = statsId(obj)
    if addr not in cls.containerMap:
      if not parent:
        # Find out the parent of the calling object by going back through the call stack until a self != this.
        f = inspect.currentframe()
        while not cls.__getSelf(f):
          f = f.f_back
        this = cls.__getSelf(f)
        f = f.f_back
        while cls.__getSelf(f) == this or not cls.__getSelf(f):
          f = f.f_back
        parent = cls.__getSelf(f)

      # Default subcontext to an autoincrementing ID.
      if subContext is None:
        cls.subId += 1
        subContext = cls.subId

      if subContext is not '':
        path = '%s/%s' % (name, subContext)
      else:
        path = name

      # Now that we have the name, create an entry for this object.
      cls.parentMap[addr] = parent
      container = cls.getContainerForObject(statsId(parent))
      if not container and isinstance(parent, unittest.TestCase):
        cls.init(parent, '/test-case')
      cls.containerMap[addr] = cls.__getStatContainer(path, cls.getContainerForObject(statsId(parent)))
    return cls.containerMap[addr]
765763
public static BindingResult bindObjectToInstance(Object object, Object source) {
        return bindObjectToInstance(object, source, getBindingIncludeList(object), Collections.emptyList(), null);
    }
894304
def bind_to_constructor(self, cls, constructor):
        """"""
        self._check_class(cls)
        if constructor is None:
            raise InjectorException('Constructor cannot be None, key=%s' % cls)

        self._bindings[cls] = _ConstructorBinding(constructor)
        logger.debug('Bound %s to a constructor %s', cls, constructor)
        return self