Factory method
@return create a {@link ChainedProviderService}
@param <X> provider class
@param name name
@param primary first service
@param secondary secondary service
494031
public static <X> ChainedProviderService<X> chain(final String name,
                                                      final ProviderService<X> primary,
                                                      final ProviderService<X> secondary) {

        return new ChainedProviderServiceImpl<X>(name, primary, secondary);
    }
648575
@VisibleForTesting
  C createServiceClient(Object soapClient, D adsServiceDescriptor, S adsSession) {
    return adsServiceClientFactory.create(soapClient, adsServiceDescriptor, adsSession);
  }
1016406
protected ExecutorService createDefaultExecutorService(ConcurrentAsyncExecutorProvider provider) {
        final int corePoolSize = 0;
        Integer maximumPoolSize = provider != null ? provider.provideMaxPoolSize() : null;
        if (maximumPoolSize == null) {
            maximumPoolSize = 10;
        }
        final long keepAliveTime = 60L;
        final TimeUnit seconds = TimeUnit.SECONDS;
        final BlockingQueue<Runnable> workQueue = createDefaultBlockingQueue();
        final RejectedExecutionHandler rejected = createRejectedExecutionHandler();
        return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, seconds, workQueue, rejected);
    }
982051
public void createService(String domainProviderName, boolean force, Map<String, String> attributes) {
        // check if a domain has been chosen
        if (domainProviderName == null || domainProviderName.isEmpty()) {
            domainProviderName = selectDomainProvider();
        }

        // get domain provider Id
        String domainProviderId = "";
        List<DomainProvider> domainProvider = getDomainProvider();
        for (DomainProvider provider : domainProvider) {
            if (provider.getName().getString(Locale.getDefault()).equals(domainProviderName)) {
                domainProviderId = provider.getId();
            }
        }
        // get the connector which should be created
        ConnectorProvider connectorProvider =
            getConnectorToCreate(domainProviderId, attributes.get(ServiceCommands.CONNECTOR_TYPE));

        String id;
        if (attributes.isEmpty() || !attributes.containsKey(org.osgi.framework.Constants.SERVICE_PID)) {
            OutputStreamFormater.printValue("Please enter an ID");
            id = readUserInput();
        } else {
            id = attributes.get(org.osgi.framework.Constants.SERVICE_PID);
        }

        ServiceDescriptor descriptor = connectorProvider.getDescriptor();
        OutputStreamFormater.printValue(String.format("Please enter the attributes for %s, keep empty for default",
            descriptor.getName().getString(Locale.getDefault())));

        // get attributes for connector
        Map<String, String> attributeMap = getConnectorAttributes(descriptor.getAttributes(), attributes);
        Map<String, Object> properties = new HashMap<String, Object>();

        ConnectorDescription connectorDescription =
            new ConnectorDescription(domainProviderId, connectorProvider.getId(), attributeMap, properties);
        if (force) {
            if (id != null && !id.isEmpty()) {
                serviceManager.forceCreateWithId(id, connectorDescription);
            } else {
                serviceManager.forceCreate(connectorDescription);
            }
            OutputStreamFormater.printValue("Connector successfully created");
        } else {
            OutputStreamFormater.printValue("Do you want to create the connector with the following attributes:", "");
            OutputStreamFormater.printValue("Connector ID", id);
            for (String key : attributeMap.keySet()) {
                OutputStreamFormater.printValue(key, attributeMap.get(key));
            }
            OutputStreamFormater.printValue("Create connector: (Y/n)");
            if (!readUserInput().equalsIgnoreCase("n")) {
                try {
                    if (id != null && !id.isEmpty()) {
                        serviceManager.createWithId(id, connectorDescription);
                    } else {
                        serviceManager.create(connectorDescription);
                    }
                    OutputStreamFormater.printValue("Connector successfully created");
                } catch (RuntimeException e) {
                    e.printStackTrace();
                    OutputStreamFormater.printValue("Connector validation failed, creation aborted");
                }
            } else {
                OutputStreamFormater.printValue("Creation aborted");
            }
        }
    }
723084
function createPlatformFactory(parentPlaformFactory, name, providers) {
	        if (providers === void 0) { providers = []; }
	        var marker = new OpaqueToken("Platform: " + name);
	        return function (extraProviders) {
	            if (extraProviders === void 0) { extraProviders = []; }
	            if (!getPlatform()) {
	                if (parentPlaformFactory) {
	                    parentPlaformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
	                }
	                else {
	                    createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
	                }
	            }
	            return assertPlatform(marker);
	        };
	    }
1355881
public QueueConsumer createQueueListener(final String name, final ConsumerCallback messageCallback)
    {
        Preconditions.checkState(connectionFactory != null, "connection factory was never injected!");
        return new QueueConsumer(connectionFactory, amqpConfig, name, messageCallback);
    }
1074643
@SuppressWarnings("unchecked")
    public synchronized <T> T load(final PluggableService<T> service, final String providerName)
            throws ProviderLoaderException {
        final ProviderIdent ident = new ProviderIdent(service.getName(), providerName);
        debug("loadInstance for " + ident + ": " + pluginJar);

        if (null == pluginProviderDefs.get(ident)) {
            final String[] strings = getClassnames();
            for (final String classname : strings) {
                final Class<?> cls;
                try {
                    cls = loadClass(classname);
                    if (matchesProviderDeclaration(ident, cls)) {
                        pluginProviderDefs.put(ident, cls);
                    }
                } catch (PluginException e) {
                    log.error("Failed to load class from " + pluginJar + ": classname: " + classname + ": "
                            + e.getMessage());
                }
            }
        }
        final Class<T> cls = pluginProviderDefs.get(ident);
        if (null != cls) {
            try {
                return createProviderForClass(service, cls);
            } catch (PluginException e) {
                throw new ProviderLoaderException(e, service.getName(), providerName);
            }
        }
        return null;
    }
81561
@SuppressWarnings({ "unchecked", "rawtypes" })
    public AbstractSubscriptionPublisher create(final Object provider) {
        String interfaceClassName = ProviderAnnotations.getProvidedInterface(provider).getName();

        String subscriptionPublisherClassName = interfaceClassName + SubscriptionPublisher.class.getSimpleName();
        String subcriptionPublisherImplClassName = subscriptionPublisherClassName + "Impl";
        try {

            Class<?> subscriptionPublisherImplClass = Class.forName(subcriptionPublisherImplClassName);
            AbstractSubscriptionPublisher subscriptionPublisherImpl = (AbstractSubscriptionPublisher) subscriptionPublisherImplClass.newInstance();
            try {
                Class<?> subscriptionPublisherInjectionClass = Class.forName(subscriptionPublisherClassName
                        + "Injection");
                if (subscriptionPublisherInjectionClass.isInstance(provider)) {
                    ((SubscriptionPublisherInjection) provider).setSubscriptionPublisher(subscriptionPublisherImpl);
                }
            } catch (ClassNotFoundException exception) {
                //if subscriptionPublisherInjectionClassname could not be found, we assume that the provider does not require a SubscriptionPublisher
            }

            return subscriptionPublisherImpl;
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("For given provider of joynr interface \"" + interfaceClassName
                    + "\", expected subscription publisher class of type \"" + subcriptionPublisherImplClassName
                    + "\" could not be found by the classloader." + " Please ensure the class can be loaded.");
        } catch (InstantiationException e) {
            throw new IllegalArgumentException("For given provider of joynr interface \"" + interfaceClassName
                    + "\", expected subscription publisher class of type \"" + subcriptionPublisherImplClassName
                    + "\" could not be instantiated due to the following error: " + e.getMessage());

        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("For given provider of joynr interface \"" + interfaceClassName
                    + "\", expected subscription publisher class of type \"" + subcriptionPublisherImplClassName
                    + "\" could not be accessed due to the following error: " + e.getMessage());
        }
    }
1278259
public static WebSocketFactory createWebSocketFactory() {
        Class<WebSocketFactory>         clazz = WebSocketFactory.class;
        ServiceLoader<WebSocketFactory> loader = ServiceLoader.load(clazz);
        return loader.iterator().next();    
    }
884766
public CompiledTemplate.Factory getTemplateFactory(String name) {
    CompiledTemplate.Factory factory = getTemplateData(name).factory;
    if (factory == null) {
      throw new IllegalArgumentException("cannot get a factory for the private template: " + name);
    }
    return factory;
  }
760018
protected function createRuntimeDriver(string $name): ProviderContract
    {
        $config = $this->config['runtime'][$name] ?? [];

        return $this->createProvider(new Runtime($name, $config));
    }
726550
public static ClientConfiguration createClient(final Endpoint endpoint, final DataProvider provider) {
        return createClient(singletonList(endpoint), singletonList(provider));
    }
926211
public Object service(String name) {
        Object service = this.services.get(name);
        if (service == null) {
            throw new IllegalArgumentException("Service '" + name + "' not found");
        }
        return service; 
    }
745830
private static Service<NetworkInterfaceBinding> createInterfaceService(String name, ParsedInterfaceCriteria criteria) {
        return NetworkInterfaceService.create(name, criteria);
    }
231493
public static <U> LifecycleProvider<U> of(@Nonnull final Class<? extends Provider<U>> providerClass)
    {
        return new DelegatingLifecycleProvider<U>(providerClass, null);
    }
457992
@Override
    public ServiceDelegate createServiceDelegate(URL url, QName qname,
                                                 @SuppressWarnings("rawtypes") Class cls) {
        Bus bus = null;
        JaxWsClientMetaData clientMetaData = JaxWsMetaDataManager.getJaxWsClientMetaData();
        if (clientMetaData != null) {
            bus = clientMetaData.getClientBus();
        }
        if (bus == null) {
            bus = BusFactory.getThreadDefaultBus();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "No client  bus is found, the thread context default bus " + bus.getId() + " is used");
            }
        }

        WebServiceRefInfo wsrInfo = wsRefInfo.get();

        List<WebServiceFeature> serviceFeatures = wsFeatures.get();
        final List<WebServiceFeature> fServiceFeatures = serviceFeatures;

        AtomicServiceReference<JaxWsSecurityConfigurationService> secConfigSR = securityConfigSR.get();
        JaxWsSecurityConfigurationService securityConfigService = secConfigSR == null ? null : secConfigSR.getService();

        // @TJJ create final vars in order to call a doPriv when creating the LibertyServiceImpl as required by java 2 security
        final JaxWsSecurityConfigurationService scs = securityConfigService;
        final WebServiceRefInfo wi = wsrInfo;
        final Bus b = bus;
        final URL u = url;
        final QName qn = qname;
        final Class c = cls;
        final List<WebServiceFeature> sf = serviceFeatures;

        if (serviceFeatures != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Thread context features are configured with " + serviceFeatures);
            }
            LibertyServiceImpl lsl = AccessController.doPrivileged(new PrivilegedAction<LibertyServiceImpl>() {
                @Override
                public LibertyServiceImpl run() {
                    return new LibertyServiceImpl(scs, wi, b, u, qn, c, sf.toArray(new WebServiceFeature[sf.size()]));
                }
            });
            return lsl;

        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Thread context features are not set");
            }

            LibertyServiceImpl lsl = AccessController.doPrivileged(new PrivilegedAction<LibertyServiceImpl>() {
                @Override
                public LibertyServiceImpl run() {
                    return new LibertyServiceImpl(scs, wi, b, u, qn, c);
                }
            });
            return lsl;

        }
    }
577925
private <T> Provider<T> createProvider(Key<T> key)
  {
    Class<T> type = (Class<T>) key.rawClass();

    if (Provider.class.equals(type)) {
      TypeRef subType = TypeRef.of(key.type()).to(Provider.class).param(0);

      Key<Object> subkey = Key.of(subType.type(), key.annotationTypes());

      return (Provider) new ProviderProvider(key, -10, provider(subkey));
    }
    else if (Optional.class.equals(type)) {
      TypeRef subType = TypeRef.of(key.type()).to(Optional.class).param(0);

      Key<Object> subkey = Key.of(subType.type(), key.annotationTypes());

      return (Provider) new ProviderOptional(key, -10, provider(subkey));
    }
    else if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) {
      return new ProviderNull(key, -10000, new InjectScopeSingleton());
    }

    int priority = -10;

    // auto-provider is factory
    InjectScope<T> scope = findScope(type);

    BindingAmp<T> binding = new ProviderConstructor<>(this, key, priority, scope, type);

    binding.bind();

    return binding.provider();
  }