Inject the SPI MessageRouter.

This is injected by TrConfigurator, which is also SPI. So it's possible for
third-party code to implement and inject their own MessageRouter.
342001
@Override
    public void setMessageRouter(MessageRouter msgRouter) {

        externalMessageRouter.set(msgRouter);

        if (msgRouter instanceof WsMessageRouter) {
            setWsMessageRouter((WsMessageRouter) msgRouter);
        }
    }
1047120
@Override
  public <T> Provider<T> provider(InjectionPoint<T> ip)
  {
    Objects.requireNonNull(ip);

    Provider<T> provider = lookupProvider(ip);

    if (provider != null) {
      return provider;
    }

    provider = autoProvider(ip);

    if (provider != null) {
      return provider;
    }

    return new ProviderNull(ip.key(), -10000, new InjectScopeSingleton());
  }
21288
def configure(config=None, bind_in_runtime=True):
    """"""
    global _INJECTOR

    with _INJECTOR_LOCK:
        if _INJECTOR:
            raise InjectorException('Injector is already configured')

        _INJECTOR = Injector(config, bind_in_runtime=bind_in_runtime)
        logger.debug('Created and configured an injector, config=%s', config)
        return _INJECTOR
581823
def inject_mode(arg_namespace):
    """"""

    try:
        injector.inject_into_files(arg_namespace.scheme, arg_namespace.file)
    except (IndexError, FileNotFoundError,
            PermissionError, IsADirectoryError) as exception:
        if isinstance(exception, IndexError):
            print('"{}" has no valid injection marker lines.'.format(
                exception.args[0]))
        if isinstance(exception, FileNotFoundError):
            print('Lacking resource "{}" to complete operation.'.format(
                exception.filename))
        if isinstance(exception, PermissionError):
            print('No write permission for current working directory.')
        if isinstance(exception, IsADirectoryError):
            print('"{}" is a directory. Provide a *.yaml scheme file instead.'
                  .format(exception.filename))
500254
public synchronized MessageRouterConfigListenerImpl register(BundleContext bundleContext) {
        if (serviceRegistration != null) {
            return this; // Already registered.
        }

        Dictionary<String, Object> props = new Hashtable<String, Object>(1);
        props.put(Constants.SERVICE_VENDOR, "IBM");

        // register the ManagedService that will handle the config
        serviceRegistration = bundleContext.registerService(MessageRouterConfigListener.class, this, props);
        return this;
    }
994475
@Override
    public void setTraceRouter(WsTraceRouter traceRouter) {

        internalTraceRouter.set(traceRouter);

        // Pass the earlierMessages queue to the router.
        // Now that the internalMessageRouter is non-null, this class will
        // NOT add any more messages to the earlierMessages queue.
        // The MessageRouter basically owns the earlierMessages queue
        // from now on.
        if (earlierTraces != null) {
            synchronized (this) {
                if (earlierTraces != null) {
                    traceRouter.setEarlierTraces(earlierTraces);
                }
            }
        } else {
            traceRouter.setEarlierTraces(null);
        }
    }
994184
public void reconfigureMessaging( String etcDir, Map<String,String> msgData )
	throws IOException {

		String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY );
		Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType );
		if( ! Utils.isEmptyOrWhitespaces( etcDir )
				&& ! Utils.isEmptyOrWhitespaces( messagingType )) {

			// Write the messaging configuration
			File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" );
			Logger logger = Logger.getLogger( getClass().getName());

			Properties props = Utils.readPropertiesFileQuietly( f, logger );
			props.putAll( msgData );
			props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY );

			Utils.writePropertiesFile( props, f );

			// Set the messaging type
			f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT );

			props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName()));
			if( messagingType != null ) {
				props.put( Constants.MESSAGING_TYPE, messagingType );
				Utils.writePropertiesFile( props, f );
			}
		}
	}
1083388
def inject(self, inst, **renames):
        """"""
        if renames:
            di = self.clone(**renames)
        else:
            di = self
        pro = di._provides
        inst.__injections_source__ = di
        deps = getattr(inst, '__injections__', None)
        if deps:
            for attr, dep in deps.items():
                val = pro.get(dep.name)
                if val is None:
                    raise MissingDependencyError(dep.name)

                if not isinstance(val, dep.type):
                    raise TypeError("Wrong provider for {!r}".format(val))
                setattr(inst, attr, val)
        meth = getattr(inst, '__injected__', None)
        if meth is not None:
            meth()
        return inst
617347
public void createControlAdapter()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "createControlAdapter");
    controlAdapter = new ForeignBus(messageProcessor, this);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "createControlAdapter", controlAdapter);
  }
854875
public void deliverTell (ClientObject caller, UserMessage message,
                             Name target, ChatService.TellListener listener)
        throws InvocationException
    {
        // we just forward the message as if it originated on this server
        _chatprov.deliverTell(message, target, listener);
    }
121055
public final void initialize(FaxClientSpi faxClientSpi)
    {
        if(this.initialized)
        {
            throw new FaxException("Fax client SPI interceptor already initialized.");
        }
        
        //set flag
        this.initialized=true;
        
        //get configuration
        this.faxClientSpiInstance=faxClientSpi;
        
        //initialize
        this.initializeImpl();
    }
255128
public static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ) {

		File injectionDir = new File( karafEtc, INJECTED_CONFIGS_DIR );
		if( injectionDir.isDirectory()) {
			for( File source : Utils.listAllFiles( injectionDir, ".cfg.tpl" )) {
				try {
					File target = new File( karafEtc, source.getName().replaceFirst( "\\.tpl$", "" ));

					// Do not overwrite the agent's configuration file (infinite configuration loop)
					if( Constants.KARAF_CFG_FILE_AGENT.equalsIgnoreCase( target.getName()))
						continue;

					String content = Utils.readFileContent( source );
					content = content.replace( "<domain>", domain );
					content = content.replace( "<application-name>", applicationName );
					content = content.replace( "<scoped-instance-path>", scopedInstancePath );
					content = content.replace( "<ip-address>", ipAddress );
					Utils.writeStringInto( content, target );

				} catch( IOException e ) {
					Logger logger = Logger.getLogger( AgentUtils.class.getName());
					logger.severe( "A configuration file could not be injected from " + source.getName());
					Utils.logException( logger, e );
				}
			}
		}
	}
1132421
@BetaApi
  public static TransportChannelProvider setUpChannelProvider(
      InstantiatingGrpcChannelProvider.Builder providerBuilder,
      ServiceOptions<?, ?> serviceOptions) {
    providerBuilder.setEndpoint(serviceOptions.getHost());
    return providerBuilder.build();
  }
329440
public void associateMessageProcessor( AbstractMessageProcessor<T> messageProcessor ) {

		if( this.messageProcessor != null )
			throw new IllegalArgumentException( "The message processor was already defined." );

		this.messageProcessor = messageProcessor;
		configureMessageProcessor( messageProcessor );
		this.messageProcessor.start();
	}
409853
protected <T extends InvocationMarshaller<?>> T addProvider (
        InvocationProvider prov, Class<T> mclass)
    {
        return _plmgr.addProvider(prov, mclass);
    }
795262
@SuppressWarnings("unchecked")
    public static void injectContextMethods(Object requestObject,
                                            AbstractResourceInfo cri,
                                            Message message) {

        for (Map.Entry<Class<?>, Method> entry : cri.getContextMethods().entrySet()) {
            Method method = entry.getValue();
            if (method.getParameterTypes()[0] == Application.class && cri.isSingleton()) {
                continue;
            }
            Object o = JAXRSUtils.createContextValue(message,
                                                     method.getGenericParameterTypes()[0],
                                                     entry.getKey());

            if (o != null) {
                if (!cri.isSingleton()) {
                    InjectionUtils.injectThroughMethod(requestObject, method, o, message);
                } else {
                    ThreadLocalProxy<Object> proxy = (ThreadLocalProxy<Object>) cri.getContextSetterProxy(method);
                    if (proxy != null) {
                        proxy.set(o);
                    }
                }

            }
        }
    }
624456
@Override
    public void createControlAdapter() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "createControlAdapter");
        _controlAdapter = new MessageProcessorControl(this);
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "createControlAdapter");
    }