Register the instrumentation class as a service in the OSGi registry

@param systemBundleCtx
The framework system bundle context
175696
protected void registerInstrumentationService(BundleContext systemContext) {
        Instrumentation inst = config.getInstrumentation();
        if (inst != null) {
            // Register a wrapper so we can trace callers.
            inst = (Instrumentation) Proxy.newProxyInstance(TraceInstrumentation.class.getClassLoader(),
                                                            new Class[] { Instrumentation.class },
                                                            new TraceInstrumentation(inst));
            Hashtable<String, String> svcProps = new Hashtable<String, String>();
            systemContext.registerService(Instrumentation.class.getName(), inst, svcProps);
        }
    }
483469
public void registerService(ProvidedServiceInstance serviceInstance, ServiceInstanceHealth registryHealth) {
        // Monitor disabled ProvidedServiceInstance should not have the ServiceInstanceHealth.
        if(serviceInstance.isMonitorEnabled()== false){
            throw new ServiceException(ErrorCode.SERVICE_INSTANCE_HEALTH_ERROR);
        }
        registerService(serviceInstance);
    }
845986
public Object getService( final Bundle bundle, ServiceRegistration registration )
    {
        class ManagedPaxLoggingService
            implements PaxLoggingService, LogService, ManagedService
        {
            private final String fqcn = getClass().getName();

            public void log( int level, String message )
            {
                PaxLoggingServiceImpl.this.log(bundle, level, message, null, fqcn);
            }

            public void log( int level, String message, Throwable exception )
            {
                PaxLoggingServiceImpl.this.log(bundle, level, message, exception, fqcn);
            }

            public void log( ServiceReference sr, int level, String message )
            {
                Bundle b = bundle == null && sr != null ? sr.getBundle() : bundle;
                PaxLoggingServiceImpl.this.log(b, level, message, null, fqcn);
            }

            public void log( ServiceReference sr, int level, String message, Throwable exception )
            {
                Bundle b = bundle == null && sr != null ? sr.getBundle() : bundle;
                PaxLoggingServiceImpl.this.log(b, level, message, exception, fqcn);
            }

            public int getLogLevel()
            {
                return PaxLoggingServiceImpl.this.getLogLevel();
            }

            public PaxLogger getLogger( Bundle myBundle, String category, String fqcn )
            {
                return PaxLoggingServiceImpl.this.getLogger( myBundle, category, fqcn );
            }

            public void updated( Dictionary<String, ?> configuration )
                throws ConfigurationException
            {
                PaxLoggingServiceImpl.this.updated( configuration );
            }

            public PaxContext getPaxContext()
            {
                return PaxLoggingServiceImpl.this.getPaxContext();
            }
        }

        return new ManagedPaxLoggingService();
    }
379225
@Activate
    public void startUp(BundleContext bundleContext) {
        extendedBundleContext = new ExtendedBundle.ExtendedBundleContext(bundleContext);
        bundleContext.addBundleListener(this);
    }
979480
protected void registerPauseableComponentController(BundleContext systemContext) {
        PauseableComponentControllerImpl pauseableComponentController = new PauseableComponentControllerImpl(systemContext);
        if (pauseableComponentController != null) {
            Hashtable<String, String> svcProps = new Hashtable<String, String>();
            systemContext.registerService(PauseableComponentController.class.getName(), pauseableComponentController, svcProps);
        }
    }
1328312
@FFDCIgnore(IllegalStateException.class)
    private <T> T adaptSystemBundle(final BundleContext bundleContext,
                                    Class<T> target) {
        try {
            Bundle systemBundle = bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
            if (systemBundle != null)
                return systemBundle.adapt(target);
        } catch (IllegalStateException e) {
        }
        return null;
    }
1045269
@Override
	public IServiceRegistration registerService(String clazz, Object service,
			Dictionary<String, String> properties) {
		final String sourceMethod = "registerService"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(PlatformServicesImpl.class.getName(), sourceMethod, new Object[]{clazz, service, properties});
		}
		ServiceRegistrationOSGi serviceRegistrationOSGi = null;
		ServiceRegistration<?> serviceRegistration = null;
		BundleContext bundleContext = Activator.getBundleContext();
		if (bundleContext != null) {
			serviceRegistration = bundleContext.registerService(clazz, service,
					properties);
			serviceRegistrationOSGi = new ServiceRegistrationOSGi(serviceRegistration);
		}
		if (isTraceLogging) {
			log.exiting(PlatformServicesImpl.class.getName(), sourceMethod, serviceRegistrationOSGi);
		}
		return serviceRegistrationOSGi;
	}
633855
@Override
	public void start(BundleContext context) throws Exception {
		final String sourceMethod = "start"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(Activator.class.getName(), sourceMethod, new Object[]{context});
		}
		super.start(context);

		// Verify the bundle id.
		if (!context.getBundle().getSymbolicName().equals(BUNDLE_NAME)) {
			throw new IllegalStateException();
		}
		serviceRegistrations = new LinkedList<ServiceRegistration<?>>();
		Activator.context = context;
		Dictionary<String, String> dict = new Hashtable<String, String>();
		dict.put("name", BUNDLE_NAME); //$NON-NLS-1$

		ServiceRegistration<?> commandProviderReg = registerCommandProvider();
		if (commandProviderReg != null) {
			serviceRegistrations.add(commandProviderReg);
		}
		// Create the executors provider.  The executors provider is created by the
		// activator primarily to allow executors to be shared by all of the
		// aggregators created by this bundle.
		dict = new Hashtable<String, String>();
		dict.put("name", BUNDLE_NAME); //$NON-NLS-1$
		executors = newExecutors();
		serviceRegistrations.add(
				context.registerService(IExecutors.class.getName(), executors, dict));

		if (isTraceLogging) {
			log.exiting(Activator.class.getName(), sourceMethod);
		}
	}
406272
public void registerLookupBundles(final List<GuiceyBundle> bundles) {
        setScope(ConfigScope.BundleLookup.getType());
        for (GuiceyBundle bundle : bundles) {
            register(ConfigItem.Bundle, bundle);
        }
        closeScope();
        lifecycle().bundlesFromLookupResolved(bundles);
        lifecycle().bundlesResolved(getEnabledBundles(), getDisabledBundles());
    }
361534
public function registerComponent($className, $code = null, $plugin = null)
    {
        if (!$this->classMap) {
            $this->classMap = [];
        }

        if (!$this->codeMap) {
            $this->codeMap = [];
        }

        if (!$code) {
            $code = Str::getClassId($className);
        }

        if ($code == 'viewBag' && $className != 'Cms\Components\ViewBag') {
            throw new SystemException(sprintf(
                'The component code viewBag is reserved. Please use another code for the component class %s.',
                $className
            ));
        }

        $className = Str::normalizeClassName($className);
        $this->codeMap[$code] = $className;
        $this->classMap[$className] = $code;
        if ($plugin !== null) {
            $this->pluginMap[$className] = $plugin;
        }
    }
881867
@Autowired
    public void setCtx(ApplicationContext _ctx) {
        // in lambda we need to start up the CTX ourselves
        // for unit tests and REST, all the autowiring should happen automatically
        if (LambdaSpringUtil.ctx == null) {
            LambdaSpringUtil.ctx = _ctx;
        }
    }
1368834
private ServiceRegistration<?> registerMBeanService(String jmsResourceName, BundleContext bundleContext) {
        Dictionary<String, String> props = new Hashtable<String, String>();
        props.put(KEY_SERVICE_VENDOR, "IBM");

        JmsServiceProviderMBeanImpl jmsProviderMBean = new JmsServiceProviderMBeanImpl(getServerName(), KEY_JMS2_PROVIDER);
        props.put(KEY_JMX_OBJECTNAME, jmsProviderMBean.getobjectName());

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "JmsQueueMBeanImpl=" + jmsProviderMBean.getobjectName() + " props=" + props);
        }
        return bundleContext.registerService(JmsServiceProviderMBeanImpl.class, jmsProviderMBean, props);
    }
879381
private void register(PathMapping pathMapping) throws IOException {

		GeneratorRegistry generatorRegistry = bundlesHandler.getConfig().getGeneratorRegistry();
		List<PathMapping> mappings = new ArrayList<>();
		if (generatorRegistry.isPathGenerated(pathMapping.getPath())) {
			List<PathMapping> genPathMappings = generatorRegistry.getGeneratedPathMappings(pathMapping.getBundle(),
					pathMapping.getPath(), rsReader);
			if (genPathMappings != null) {
				mappings.addAll(genPathMappings);
			} else {
				mappings.add(pathMapping);
			}
		} else {
			mappings.add(pathMapping);
		}

		for (PathMapping pMapping : mappings) {
			String filePath = rsReader.getFilePath(pMapping.getPath());
			registerPathMapping(pMapping, filePath);
		}
	}
1199200
private function registerService($dir, $namespace, $server, $moduleSuffix = '') {
        $files = [];
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    $filetype = filetype($dir . $file);
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    if ($filetype == 'file' && $ext == 'php') {
                        $files [] = substr($file, 0, -4);
                    }
                }
                closedir($dh);
            }
        }
        if (count($files) > 0) {
            foreach ($files as $filename) {
                $module = strtolower(str_replace('Service', '', $filename)) . $moduleSuffix;
                $className = $namespace . $filename;
                $class = new $className($this->yiiConfig, $server);
                $this->add($class, $className, $module);
            }
            unset($filename);
        }
        unset($files);
    }
568717
protected void displaySystem (String bundle, String message, byte attLevel, String localtype)
    {
        // nothing should be untranslated, so pass the default bundle if need be.
        if (bundle == null) {
            bundle = _bundle;
        }
        SystemMessage msg = new SystemMessage(message, bundle, attLevel);
        dispatchMessage(msg, localtype);
    }
347496
@Override
    protected ServiceRegistration<D> addService(S service, ServiceProperties props) {
        D decorator = createDecorator(service, props);
        if (decorator == null) {
            return null;
        }
        Dictionary<String, ?> decoratorServiceProps = decoratorServiceProps(props);
        getLogger().info("Registering decorator service {} with properties {}", decoratorType.getSimpleName(), decoratorServiceProps);
        return getBundleContext().registerService(decoratorType, decorator, decoratorServiceProps);
    }
853810
protected function registerInterfaceBindings()
    {
        $this->app->singleton(LocaleRepositoryInterface::class, LocaleRepository::class);
        $this->app->singleton(MenuConfigInterpreterInterface::class, MenuConfigInterpreter::class);
        $this->app->singleton(MenuModulesInterpreterInterface::class, MenuModulesInterpreter::class);
        $this->app->singleton(MenuPermissionsFilterInterface::class, MenuPermissionsFilter::class);

        return $this;
    }