Registers a component using a factory method.

        :param locator: a locator to identify component to be created.

        :param factory: a factory function that receives a locator and returns a created component.
974852
def register(self, locator, factory):
        
        if locator == None:
            raise Exception("Locator cannot be null")
        if factory == None:
            raise Exception("Factory cannot be null")

        self._registrations.append(Registration(locator, factory))
1143756
def factory(name, klass = nil, &block)
      @registry[name.to_sym] = Resolver::Factory.new(block || klass)
    end
884050
function createFactory(descriptor) {
  return function Stamp(options = {}, ...args) {
    // The 'methods' metadata object becomes the prototype for new object instances.
    const instance = Object.create(descriptor.methods || {});

    // Deep merge, then override with shallow merged properties, then apply property descriptors.
    merge(instance, descriptor.deepProperties);
    assign(instance, descriptor.properties);
    Object.defineProperties(instance, descriptor.propertyDescriptors || {});

    // Run initializers sequentially.
    return (descriptor.initializers || [])
      .filter(isFunction)
      .reduce((resultingInstance, initializer) => {
        // Invoke an initializer in the way specification tell us to.
        const returnedValue = initializer.call(
          // 'this' context will be the object instance itself
          resultingInstance,
          // the first argument passed from factory to initializer
          options,
          // special arguments. See specification.
          {instance: resultingInstance, stamp: Stamp, args: [options].concat(args)}
        );

        // Any initializer can override the object instance with basically anything.
        return returnedValue === undefined ? resultingInstance : returnedValue;
      }, instance);
  };
}
183312
def _register_bundle_factories(self, bundle):
        # type: (Bundle) -> None
        
        # Load the bundle factories
        factories = _load_bundle_factories(bundle)

        for context, factory_class in factories:
            try:
                # Register each found factory
                self._register_factory(context.name, factory_class, False)
            except ValueError as ex:
                # Already known factory
                _logger.error(
                    "Cannot register factory '%s' of bundle %d (%s): %s",
                    context.name,
                    bundle.get_bundle_id(),
                    bundle.get_symbolic_name(),
                    ex,
                )
                _logger.error(
                    "class: %s -- module: %s",
                    factory_class,
                    factory_class.__module__,
                )
            else:
                # Instantiate components
                for name, properties in context.get_instances().items():
                    self.instantiate(context.name, name, properties)
369267
def register_class(cls):
        
        if cls.appname in LinkFactory._class_dict:
            return
        LinkFactory.register(cls.appname, cls)
1367471
public function registerFactory()
    {
        $this->app->bindShared('view', function($app)
        {
            // Next we need to grab the engine resolver instance that will be used by the
            // environment. The resolver will be used by an environment to get each of
            // the various engine implementations such as plain PHP or Template engine.
            $resolver = $app['view.engine.resolver'];

            $finder = $app['view.finder'];

            $factory = new Factory($resolver, $finder, $app['events']);

            // We will also set the container instance on this view environment since the
            // view composers may be classes registered in the container, which allows
            // for great testable, flexible composers for the application developer.
            $factory->setContainer($app);

            $factory->share('app', $app);

            return $factory;
        });
    }
1040237
def load(self, name):
        
        try:
            return self._factories[name]()
        except KeyError:
            raise ValueError(
                "no %s factory registered under name %r, options are: %r" %
                (self.interface.__name__, name, sorted(self._factories)),
            )
989475
private Reference createDefinitionResourceFactoryReference(ComponentNameSpaceConfiguration compNSConfig,
                                                               InjectionScope scope,
                                                               String refName,
                                                               String type,
                                                               @Sensitive Map<String, Object> properties) throws Exception {

        ResourceFactoryBuilder builder = getResourceFactoryBuilder(type);

        J2EEName j2eeName = compNSConfig.getJ2EEName();

        // d660700 - Based on the scope, determine the metadata for recording the
        // resulting reference, and add additional keys to the properties list.
        String appName, moduleName, compName;
        MetaData metaData;
        if (scope == InjectionScope.GLOBAL) {
            metaData = null;
            appName = moduleName = compName = null;
        } else {
            appName = j2eeName.getApplication();

            if (scope == InjectionScope.APP) {
                metaData = compNSConfig.getApplicationMetaData(); // F743-31682
                moduleName = compName = null;
            } else {
                moduleName = j2eeName.getModule();

                if (scope == InjectionScope.MODULE) {
                    metaData = compNSConfig.getModuleMetaData();
                    compName = null;
                } else {
                    compName = j2eeName.getComponent();

                    metaData = compNSConfig.getComponentMetaData();
                    if (metaData == null) {
                        // All components in a web module share the same namespace.
                        metaData = compNSConfig.getModuleMetaData();
                    }
                }
            }
        }

        if (appName == null) {
            properties.remove("application");
        } else {
            properties.put("application", appName);
        }

        if (moduleName == null) {
            properties.remove("module");
        } else {
            properties.put("module", moduleName);
        }

        if (compName == null) {
            properties.remove("component");
        } else {
            properties.put("component", compName);
        }

        properties.put("declaringApplication", j2eeName.getApplication());
        properties.put("jndiName", InjectionScope.denormalize(refName));

        ResourceFactory resourceFactory = builder.createResourceFactory(properties);
        Reference ref = new ResourceFactoryReference(type, resourceFactory, properties);

        // Save the reference in the relevant scope data so that it can be
        // destroyed when the scope is destroyed.
        getInjectionScopeData(metaData).addDefinitionReference(refName, ref);

        return ref;
    }
808227
def setFactory( self, factory ):
        
        self._factory = factory
        self._queryWidget.setFactory(factory)
1194507
function noComponentFactoryError(component) {
    var /** @type {?} */ error = Error("No component factory found for " + stringify(component) + ". Did you add it to @NgModule.entryComponents?");
    ((error))[ERROR_COMPONENT] = component;
    return error;
}
1106792
void compile() {
    TypeInfo factoryType = innerClasses.registerInnerClass(FACTORY_CLASS, FACTORY_ACCESS);
    SoyClassWriter cw =
        SoyClassWriter.builder(factoryType)
            .implementing(FACTORY_TYPE)
            .setAccess(FACTORY_ACCESS)
            .sourceFileName(templateNode.getSourceLocation().getFileName())
            .build();
    innerClasses.registerAsInnerClass(cw, factoryType);

    generateStaticInitializer(cw);
    defineDefaultConstructor(cw, factoryType);
    generateCreateMethod(cw, factoryType);
    cw.visitEnd();
    innerClasses.add(cw.toClassData());
  }
1119140
public void registerFactory(String name, String groupName, Factory factory) {
        getProxyBuilder().factories.put(name, factory);
        getRegistrationGroup(groupName).add(name);
        factory.onFactoryRegistration(this, name, groupName);
    }
1067143
def create(self, locator):
        
        for registration in self._registrations:
            this_locator = registration.locator

            if this_locator == locator:
                try:
                    return registration.factory(locator)
                except Exception as ex:
                    if isinstance(ex, CreateException):
                        raise ex
                    
                    raise CreateException(
                        None,
                        "Failed to create object for " + str(locator)
                    ).with_cause(ex)
1351513
function componentFactory(vConfig) {

		// Inherit cacheTokens from owner component if not defined in asyncHints
		if (!vConfig.asyncHints || !vConfig.asyncHints.cacheTokens) {
			var oOwnerComponent = Component.get(ManagedObject._sOwnerId);
			var mCacheTokens = oOwnerComponent && oOwnerComponent._mCacheTokens;
			if (typeof mCacheTokens === "object") {
				vConfig.asyncHints = vConfig.asyncHints || {};
				vConfig.asyncHints.cacheTokens = mCacheTokens;
			}
		}

		function createInstance(oClass) {

			// retrieve the required properties
			var sName = vConfig.name,
				sId = vConfig.id,
				oComponentData = vConfig.componentData,
				sController = sName + '.Component',
				mSettings = vConfig.settings;

			// create an instance
			var oInstance = new oClass(jQuery.extend({}, mSettings, {
				id: sId,
				componentData: oComponentData,
				_cacheTokens: vConfig.asyncHints && vConfig.asyncHints.cacheTokens
			}));
			assert(oInstance instanceof Component, "The specified component \"" + sController + "\" must be an instance of sap.ui.core.Component!");
			Log.info("Component instance Id = " + oInstance.getId());

			/*
			 * register for messaging: register if either handleValidation is set in metadata
			 * or if not set in metadata and set on instance
			 */
			var bHandleValidation = oInstance.getMetadata().handleValidation() !== undefined || vConfig.handleValidation;
			if (bHandleValidation) {
				// calculate handleValidation for registration
				if (oInstance.getMetadata().handleValidation() !== undefined) {
					bHandleValidation = oInstance.getMetadata().handleValidation();
				} else {
					bHandleValidation = vConfig.handleValidation;
				}
				sap.ui.getCore().getMessageManager().registerObject(oInstance, bHandleValidation);
			}

			// Some services may demand immediate startup
			activateServices(oInstance);

			if (typeof Component._fnOnInstanceCreated === "function") {

				// In async mode the hook can provide a promise which will be added to the promise chain
				var oPromise = Component._fnOnInstanceCreated(oInstance, vConfig);
				if (vConfig.async && oPromise instanceof Promise) {
					return oPromise.then(function() {
						// Make sure that the promise returned by the hook can not modify the resolve value
						return oInstance;
					});
				}

			}

			return oInstance;
		}

		// load the component class
		var vClassOrPromise = loadComponent(vConfig, {
			failOnError: true,
			createModels: true,
			waitFor: vConfig.asyncHints && vConfig.asyncHints.waitFor
		});
		if ( vConfig.async ) {
			// async: instantiate component after Promise has been fulfilled with component
			//        constructor and delegate the current owner id for the instance creation
			var sCurrentOwnerId = ManagedObject._sOwnerId;
			return vClassOrPromise.then(function(oClass) {
				return runWithOwner(function() {
					return createInstance(oClass);
				}, sCurrentOwnerId);
			});
		} else {
			// sync: constructor has been returned, instantiate component immediately
			return createInstance(vClassOrPromise);
		}
	}
1026521
public Factory registerObject(Object obj, ULocale locale, int kind, boolean visible) {
        Factory factory = new SimpleLocaleKeyFactory(obj, locale, kind, visible);
        return registerFactory(factory);
    }
464153
def _get_from_factory(self, factory, svc_registration):
        # type: (Any, ServiceRegistration) -> Any
        
        svc_ref = svc_registration.get_reference()
        try:
            # Use the existing service
            service, counter = self.__factored[svc_ref]
            counter.inc()
        except KeyError:
            # Create the service
            service = factory.get_service(self.__bundle, svc_registration)
            counter = _UsageCounter()
            counter.inc()

            # Store the counter
            self.__factored[svc_ref] = (service, counter)

        return service
486901
private void createInstance() throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstance");

        ManagedObjectFactory<?> ejbManagedObjectFactory = home.beanMetaData.ivEnterpriseBeanFactory;
        if (ejbManagedObjectFactory != null) {
            createInstanceUsingMOF(ejbManagedObjectFactory);
        } else {
            createInstanceUsingConstructor();
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstance");
    }