Retrieve a library from the service registry.

@return A library with the given id or <code>null</code> if no match was found
554471
static Library getSharedLibrary(String id) {

        if (bundleContext == null) {
            return null;
        }

        // Filter the SharedLibrary service references by ID.
        String filter = "(" + "id=" + id + ")";
        Collection<ServiceReference<Library>> refs = null;
        try {
            refs = bundleContext.getServiceReferences(Library.class, filter);
        } catch (InvalidSyntaxException e) {
            if (tc.isErrorEnabled()) {
                Tr.error(tc, "cls.library.id.invalid", id, e.toString());
            }
            return null;
        }

        if (refs.isEmpty())
            return null;

        return bundleContext.getService(getHighestRankedService(refs));
    }
425753
public static Lookup get() {
        if (LOOKUP != null) {
            return LOOKUP;
        }
        synchronized (Lookup.class) {
            // allow for override of the Lookup.class
            String overrideClassName = System.getProperty(Lookup.class.getName());
            ClassLoader l = Thread.currentThread().getContextClassLoader();
            try {
                if (overrideClassName != null && !"".equals(overrideClassName)) {
                    LOOKUP = (Lookup) Class.forName(overrideClassName, true, l).newInstance();
                } else {
                    LOOKUP = new Lookup();
                }
            } catch (Exception e) {
                // ignore
            }
            // ServiceLoader and CDI are used by defaults, important that
            // CDI is used first so that beans are enabled for injection
            CdiLookup cdiLookup = new CdiLookup();
            LOOKUP.lookupProviders.add(cdiLookup);
            ServiceLoaderLookup serviceLoaderLookup = new ServiceLoaderLookup();
            LOOKUP.lookupProviders.add(serviceLoaderLookup);
            // Use ServiceLoader to find other LookupProviders
            Collection<LookupProvider> providers = serviceLoaderLookup
                    .lookupAll(LookupProvider.class);
            LOOKUP.lookupProviders.addAll(providers);
        }

        return LOOKUP;
    }
330402
public com.google.appengine.v1.LibraryOrBuilder getLibrariesOrBuilder(
      int index) {
    return libraries_.get(index);
  }
1094910
public Document getDocument(@NonNull String id) {
        if (id == null) { throw new IllegalArgumentException("id cannot be null."); }

        synchronized (lock) {
            mustBeOpen();
            try {
                return new Document((Database) this, id, false);
            }
            catch (CouchbaseLiteException ex) {
                // only 404 - Not Found error throws CouchbaseLiteException
                return null;
            }
        }
    }
961872
@SuppressWarnings("unchecked")
    public static <E> ServiceRegistry<E> getInstance() {
        if (instance == null) {
            synchronized (ServiceRegistry.class) {
                if (instance == null) {
                    instance = new ServiceRegistry<E>();
                }
            }
        }
        return instance;
    }
116985
public Optional<Path> findLibraryInstall(String libraryName) {
        return getArduinoDirectory().map(path -> {
            Path libsDir = path.resolve("libraries");
            Path tcMenuDir = libsDir.resolve(libraryName);
            if (Files.exists(tcMenuDir)) {
                return tcMenuDir;
            }
            return null;
        });
    }
385169
public static String subscriptionFromResourceId(String id) {
        return (id != null) ? ResourceId.fromString(id).subscriptionId() : null;
    }
889923
private License getLicense(final String licenseId) {
        License result = null;
        final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(licenseId);

        if (matchingLicenses.isEmpty()) {
            result = DataModelFactory.createLicense("#" + licenseId + "# (to be identified)", NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET);
            result.setUnknown(true);
        } else {
            if (matchingLicenses.size() > 1 && LOG.isWarnEnabled()) {
                LOG.warn(String.format("%s matches multiple licenses %s. " +
                                "Please run the report showing multiple matching on licenses",
                        licenseId, matchingLicenses.toString()));
            }
            result = mapper.getLicense(matchingLicenses.iterator().next());

        }

        return result;
    }
606938
public static <T> ServiceController<T> findService(ServiceRegistry registry, ServiceName name) {
        return (ServiceController<T>) registry.getService(name);
    }
1308409
public com.google.appengine.v1.Library getLibraries(int index) {
    return libraries_.get(index);
  }
694020
@Nullable
  public String getServiceId() {
    String serviceId = getString(SERVICE_KEY);
    if (serviceId == null) {
      serviceId = getString(MODULE_KEY);
    }
    return serviceId;
  }
871952
protected Client getClient(String id) throws IOException {
        Get get = new Get.Builder(getIndexName(), id).type("client").build(); //$NON-NLS-1$
        JestResult result = getClient().execute(get);
        if (result.isSucceeded()) {
            Client client = result.getSourceAsObject(Client.class);
            return client;
        } else {
            return null;
        }
    }
57872
public final DatastoreConfig getDatastoreConfig(String id) {
        try{
            return m_moduleContext.getBean(id,DatastoreConfiguration.class);
        }
        catch (Throwable t){
            logger.info(t.getMessage(),t);
            return null;
        }
    }
623903
public static <T> T lookupProviderByName(final ServiceRegistry registry, final String providerClassName, Class<T> category) {
        try {
            return category.cast(registry.getServiceProviderByClass(Class.forName(providerClassName)));
        }
        catch (ClassNotFoundException ignore) {
            return null;
        }
    }
970971
private UserRegistryService getUserRegistryService(String id) {
        UserRegistryService service = userRegistry.getService(id);
        if (service == null) {
            throwIllegalArgumentExceptionInvalidAttributeValue(SecurityConfiguration.CFG_KEY_USERREGISTRY_REF, id);
        }
        return service;
    }
1121564
private Response<SearchResult> searchForServiceById(final Long id) throws LdapException {
        val filter = LdapUtils.newLdaptiveSearchFilter(this.searchFilter,
            LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, CollectionUtils.wrap(id.toString()));
        return LdapUtils.executeSearchOperation(this.connectionFactory, this.baseDn, filter);
    }
826381
protected RegisteredService getRegisteredServiceFromRequest(final RequestContext requestContext, final String entityId) {
        val currentService = WebUtils.getService(requestContext);
        val service = this.serviceFactory.createService(entityId);
        var registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService == null) {
            LOGGER.debug("Entity id [{}] not found in the registry. Fallback onto [{}]", entityId, currentService);
            registeredService = this.servicesManager.findServiceBy(currentService);
        }
        LOGGER.debug("Located service definition [{}]", registeredService);
        return registeredService;
    }