Retrieves the factory registered with the given and its factory context

        :param factory_name: The name of the factory
        :return: A (factory, context) tuple
        :raise TypeError: Unknown factory, or factory not manipulated
175583
def __get_factory_with_context(self, factory_name):
        # type: (str) -> Tuple[type, FactoryContext]
        
        factory = self.__factories.get(factory_name)
        if factory is None:
            raise TypeError("Unknown factory '{0}'".format(factory_name))

        # Get the factory context
        factory_context = getattr(
            factory, constants.IPOPO_FACTORY_CONTEXT, None
        )
        if factory_context is None:
            raise TypeError(
                "Factory context missing in '{0}'".format(factory_name)
            )

        return factory, factory_context
1348553
@Override
    public void registerFactory(String name, Class<? extends ChannelFactory> factory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "registerFactory: " + name + "; " + factory);
        }
        synchronized (this.factories) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Class<? extends ChannelFactory> prevFactory = this.factories.get(name);
                if (null != prevFactory && factory != prevFactory) {
                    Tr.event(tc, "WARNING: overlaying existing factory: " + prevFactory);
                }
            }
            this.factories.put(name, factory);
        } // end-sync

        // now that we have a new factory type, tell ChannelUtils to process
        // any delayed config that might be waiting for it
        ChannelUtils.loadConfig(null);
    }
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)
808227
def setFactory( self, factory ):
        
        self._factory = factory
        self._queryWidget.setFactory(factory)
915488
@Internal
	public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Type t) {
		final Class<?> factoryClass;
		if (registeredTypeInfoFactories.containsKey(t)) {
			factoryClass = registeredTypeInfoFactories.get(t);
		}
		else {
			if (!isClassType(t) || !typeToClass(t).isAnnotationPresent(TypeInfo.class)) {
				return null;
			}
			final TypeInfo typeInfoAnnotation = typeToClass(t).getAnnotation(TypeInfo.class);
			factoryClass = typeInfoAnnotation.value();
			// check for valid factory class
			if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) {
				throw new InvalidTypesException("TypeInfo annotation does not specify a valid TypeInfoFactory.");
			}
		}

		// instantiate
		return (TypeInfoFactory<OUT>) InstantiationUtil.instantiate(factoryClass);
	}
1266420
def _load_bundle_factories(bundle):
    # type: (Bundle) -> List[Tuple[FactoryContext, type]]
    
    result = []

    # Get the Python module
    module_ = bundle.get_module()

    # Get the bundle context
    bundle_context = bundle.get_bundle_context()

    for name in dir(module_):
        try:
            # Get the module member
            factory_class = getattr(module_, name)
            if not inspect.isclass(factory_class):
                continue

            # Check if it is a class
            if sys.modules[factory_class.__module__] is not module_:
                # Only keep classes from this module
                continue
        except (AttributeError, KeyError):
            # getattr() didn't work or __module__ is not a member of the class,
            # or the module is not known by the interpreter
            continue

        context = _set_factory_context(factory_class, bundle_context)
        if context is None:
            # Error setting up the factory context
            continue

        result.append((context, factory_class))

    return result
987438
def get_factory_context(cls):
    # type: (type) -> FactoryContext
    
    context = getattr(cls, constants.IPOPO_FACTORY_CONTEXT, None)

    if context is None:
        # Class not yet manipulated
        context = FactoryContext()
    elif is_from_parent(cls, constants.IPOPO_FACTORY_CONTEXT):
        # Create a copy the context
        context = context.copy(True)
        # * Manipulation has not been applied yet
        context.completed = False
    else:
        # Nothing special to do
        return context

    # Context has been created or copied, inject the new bean
    setattr(cls, constants.IPOPO_FACTORY_CONTEXT, context)
    return context
735423
private static function getPuliFactory()
    {
        if (null === self::$puliFactory) {
            if (!defined('PULI_FACTORY_CLASS')) {
                throw new PuliUnavailableException('Puli Factory is not available');
            }

            $puliFactoryClass = PULI_FACTORY_CLASS;

            if (!ClassDiscovery::safeClassExists($puliFactoryClass)) {
                throw new PuliUnavailableException('Puli Factory class does not exist');
            }

            self::$puliFactory = new $puliFactoryClass();
        }

        return self::$puliFactory;
    }
1291319
protected function resolveFactory(string $factory_class) : FactoryInterface {
    // If the requested factory is the default.
    if ($this->factoryClass == $factory_class) {
      // If we've not yet instantiated the default.
      if (empty($this->factory)) {
        $this->factory = $this->factoryResolver->getFactoryInstance($this->factoryClass);
      }
      // Return the default.
      return $this->factory;
    }
    // If the requested factory is NOT the default.
    return $this->factoryResolver->getFactoryInstance($factory_class);
  }
910538
function(name) {
			var args = [].slice.call(arguments, 1);
			var factory = this.get(name);
			return factory ? factory.apply(this, args) : null;
		}
1119140
public void registerFactory(String name, String groupName, Factory factory) {
        getProxyBuilder().factories.put(name, factory);
        getRegistrationGroup(groupName).add(name);
        factory.onFactoryRegistration(this, name, groupName);
    }
412680
def need_record_permission(factory_name):
    
    def need_record_permission_builder(f):
        @wraps(f)
        def need_record_permission_decorator(self, record=None, *args,
                                             **kwargs):
            permission_factory = (
                getattr(self, factory_name) or
                getattr(current_records_rest, factory_name)
            )

            # FIXME use context instead
            request._methodview = self

            if permission_factory:
                verify_record_permission(permission_factory, record)
            return f(self, record=record, *args, **kwargs)
        return need_record_permission_decorator
    return need_record_permission_builder
737849
def provider_factory(factory=_sentinel, scope=NoneScope):
    '''
    
    '''
    if factory is _sentinel:
        return functools.partial(provider_factory, scope=scope)
    provider = Provider(factory, scope)
    return provider
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)),
            )
669838
def __get_stored_instances(self, factory_name):
        # type: (str) -> List[StoredInstance]
        
        with self.__instances_lock:
            return [
                stored_instance
                for stored_instance in self.__instances.values()
                if stored_instance.factory_name == factory_name
            ]
247160
def get_register_func(base_class, nickname):
    
    if base_class not in _REGISTRY:
        _REGISTRY[base_class] = {}
    registry = _REGISTRY[base_class]

    def register(klass, name=None):
        """Register functions"""
        assert issubclass(klass, base_class), \
            "Can only register subclass of %s"%base_class.__name__
        if name is None:
            name = klass.__name__
        name = name.lower()
        if name in registry:
            warnings.warn(
                "\033[91mNew %s %s.%s registered with name %s is"
                "overriding existing %s %s.%s\033[0m"%(
                    nickname, klass.__module__, klass.__name__, name,
                    nickname, registry[name].__module__, registry[name].__name__),
                UserWarning, stacklevel=2)
        registry[name] = klass
        return klass

    register.__doc__ = "Register %s to the %s factory"%(nickname, nickname)
    return register
351806
public static final TermFactory getTermFactory() {
		if (tf == null) {
			try {
				@SuppressWarnings("unchecked")
				Class<? extends TermFactory> clazz = (Class<? extends TermFactory>) Class
						.forName(DEFAULT_TERM_FACTORY);
				Method m = clazz.getMethod("getInstance");
				registerTermFactory((TermFactory) m.invoke(null));
				log.debug("Retrived {} as default TermFactory implementation.",
						DEFAULT_TERM_FACTORY);
			} catch (Exception e) {
				log.error("Unable to get TermFactory from default", e);
				throw new RuntimeException(
						"No TermFactory implementation registered!");
			}
		}
		return tf;
	}