Register a ProvidedServiceInstance with the ServiceInstanceHealth callback.

@param serviceInstance
the ProvidedServiceInstance.
@param registryHealth
the ServiceInstanceHealth callback.
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);
    }
1042753
def _register_service_type(cls, subclass):
        """"""
        if hasattr(subclass, '__service_type__'):
            cls._service_type_mapping[subclass.__service_type__] = subclass
            if subclass.__service_type__:
                setattr(subclass,
                        subclass.__service_type__,
                        property(lambda x: x))
        return subclass
648021
private void registerCachedServiceInstance(ProvidedServiceInstance instance, ServiceInstanceHealth registryHealth) {
        try {
            write.lock();
            ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
                    instance.getProviderId());
            CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);

            if(cachedInstance == null){
                cachedInstance = new CachedProviderServiceInstance(
                    instance);
                getCacheServiceInstances().put(id, cachedInstance);

            }
            if(LOGGER.isDebugEnabled()){
                LOGGER.debug("add cached ProvidedServiceInstance: {}.", cachedInstance.toString());
            }
            cachedInstance.setServiceInstanceHealth(registryHealth);
        } finally {
            write.unlock();
        }
    }
1145171
public static void setRegistry(Registry registry) {
    SpectatorContext.registry = registry;
    if (registry instanceof NoopRegistry) {
      initStacktrace = null;
    } else {
      Exception cause = initStacktrace;
      Exception e = new IllegalStateException(
          "called SpectatorContext.setRegistry(" + registry.getClass().getName() + ")",
          cause);
      e.fillInStackTrace();
      initStacktrace = e;
      if (cause != null) {
        LOGGER.warn("Registry used with Servo's SpectatorContext has been overwritten. This could "
            + "result in missing metrics.", e);
      }
    }
  }
1013593
private function registerServices()
    {
        $this->createServices();

        $this->app->singleton('pragmarx.health.cache', $this->cacheClosure);

        $this->app->singleton(
            'pragmarx.health.resource.checker',
            $this->resourceCheckerClosure
        );

        $this->app->singleton('pragmarx.health', $this->healthServiceClosure);

        $this->app->singleton(
            'pragmarx.health.commands',
            $this->instantiateCommands()
        );
    }
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);
    }
1059428
public void register(DescribeService service, String describeService) throws POIProxyException {
		serviceManager.registerServiceConfiguration(service.getId(), describeService, service);
	}
619207
public void registerServiceClass(Class serviceClass) {

		registeredServiceClasses.put(serviceClass.getSimpleName(), serviceClass);

		// make it possible to select options in configuration editor
		Settings.Services.addAvailableOption(serviceClass.getSimpleName());
	}
201298
protected void registerSelf() {
        publishSelf();
        serviceRegistry.get().registerService(getServiceDescription());
        serviceRegistry.get().subscribe((pair, err) -> {
            serviceEvent(pair.car(), pair.cdr(), err);
        });
        heartBeat();
        Log.Info(this, "registered at serviceRegistry.");
    }
342682
protected void configureServices(final T builder) {
        // support health check
        if (this.properties.isHealthServiceEnabled()) {
            builder.addService(this.healthStatusManager.getHealthService());
        }
        if (this.properties.isReflectionServiceEnabled()) {
            builder.addService(ProtoReflectionService.newInstance());
        }

        for (final GrpcServiceDefinition service : this.serviceList) {
            final String serviceName = service.getDefinition().getServiceDescriptor().getName();
            log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: "
                    + service.getBeanClazz().getName());
            builder.addService(service.getDefinition());
            this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING);
        }
    }
268197
def register(self, service, name=''):
        
        # expose a sub-factory
        if isinstance(service, ApiFactory):
            self.services[name] = (service.factory, None)

        # expose a module dynamically as a service
        elif inspect.ismodule(service):
            name = name or service.__name__.split('.')[-1]

            # exclude endpoints with patterns
            for obj in vars(service).values():
                endpoint = getattr(obj, 'endpoint', None)
                if isinstance(endpoint, Endpoint) and endpoint.pattern:
                    route = Route('', endpoint.pattern)
                    self.routes.append((route, endpoint))

            self.services[name] = (ModuleService, service)

        # expose a class dynamically as a service
        elif inspect.isclass(service):
            name = name or service.__name__
            self.services[name] = (ClassService, service)

        # expose an endpoint directly
        elif isinstance(getattr(service, 'endpoint', None), Endpoint):
            if service.endpoint.pattern:
                route = Route('', service.endpoint.pattern)
                self.routes.append((route, service.endpoint))
            else:
                self.services[service.endpoint.name] = (service.endpoint, None)

        # expose a scope
        elif isinstance(service, dict):
            for srv in service.values():
                try:
                    self.register(srv)
                except RuntimeError:
                    pass

        # expose a list of services
        elif isinstance(service, list):
            for srv in service:
                try:
                    self.register(srv)
                except RuntimeError:
                    pass

        # expose a service directly
        else:
            raise RuntimeError('Invalid service provide: {0} ({1}).'.format(service, type(service)))
1321496
protected void doRegister(String appName, String serviceName, ProviderInfo providerInfo) {

        registerAppInfoOnce(appName);

        if (LOGGER.isInfoEnabled(appName)) {
            LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_ROUTE_REGISTRY_PUB, serviceName));
        }

        PublishServiceRequest publishServiceRequest = new PublishServiceRequest();
        publishServiceRequest.setServiceName(serviceName);
        ProviderMetaInfo providerMetaInfo = new ProviderMetaInfo();
        providerMetaInfo.setProtocol(providerInfo.getProtocolType());
        providerMetaInfo.setSerializeType(providerInfo.getSerializationType());
        providerMetaInfo.setAppName(appName);
        providerMetaInfo.setVersion(VERSION);
        publishServiceRequest.setProviderMetaInfo(providerMetaInfo);

        client.publishService(publishServiceRequest);
    }
1270808
@Override
	public void injectServices(ServiceRegistryImplementor serviceRegistry) {
		if ( gridDialect instanceof ServiceRegistryAwareService ) {
			( (ServiceRegistryAwareService) gridDialect ).injectServices( serviceRegistry );
		}
	}
618129
public final void register() {
        synchronized (lock) {
            if (serviceRegistration == null) {
                BundleClassResolver resolver = new BundleClassResolver();
                serviceRegistration = bundleContext.registerService(SERVICE_NAMES, resolver, serviceProperties);
            }
        }
    }
42164
private void registerService(BundleContext bc, String name, Object serviceInstance) {
        Dictionary<String, Object> properties = new Hashtable<String, Object>();
        properties.put("service.vendor", "IBM");
        bc.registerService(name, serviceInstance, properties);
    }
585984
public static void ensureServiceAccessIsAllowed(final String service, final RegisteredService registeredService) {
        if (registeredService == null) {
            val msg = String.format("Unauthorized Service Access. Service [%s] is not found in service registry.", service);
            LOGGER.warn(msg);
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
        }
        if (!registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            val msg = String.format("Unauthorized Service Access. Service [%s] is not enabled in service registry.", service);
            LOGGER.warn(msg);
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
        }
        if (!ensureServiceIsNotExpired(registeredService)) {
            val msg = String.format("Expired Service Access. Service [%s] has been expired", service);
            LOGGER.warn(msg);
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_EXPIRED_SERVICE, msg);
        }
    }
832891
public void updateServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.UpdateServiceInstance);

        UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
        ProtocolCallback pcb = new ProtocolCallback(){

            @Override
            public void call(boolean result, Response response,
                    ErrorCode error, Object ctx) {
                cb.call(result, error, ctx);
            }

        };
        connection.submitCallbackRequest(header, p, pcb, context);
    }