Get a adapter based on the service info and what exists on the file system

@param serviceInfo
@param resource
@param moduleStack
196650
function getAdapter(serviceInfo, resource, moduleStack) {
        var adapterName = serviceInfo.adapterName;

        // if adapter name is 'service' and there is a default, switch to the default
        if (adapterName === 'service' && resource.adapters[this.injector.container]) {
            adapterName = serviceInfo.adapterName = resource.adapters[this.injector.container];
            serviceInfo.adapterImpl = this.injector.adapterMap[adapterName];
            serviceInfo.serviceName = utils.getCamelCase(serviceInfo.resourceName + '.' +
                serviceInfo.adapterName + '.service');
        }

        // if that doesn't work, we will assume the adapter is in the current codebase, so go get it
        var overridePath = '/resources/' + serviceInfo.resourceName + '/' + serviceInfo.resourceName + '.' +
            (adapterName === 'service' ? adapterName : adapterName + '.service');
        var adapterPath = '/adapters/' + adapterName + '/' +
            serviceInfo.adapterImpl + '.' + adapterName + '.adapter';

        // if override exists, use that one, else use the lower level adapter
        var Adapter =
            this.loadIfExists(overridePath, moduleStack, null) ||
            this.injector.adapters[serviceInfo.adapterImpl] ||
            this.loadIfExists(adapterPath, moduleStack, null);

        // if still no adapter found, then there is an issue
        if (!Adapter) {
            throw new Error('ServiceFactory could not find adapter ' + adapterName +
            ' paths ' + overridePath + ' and ' + adapterPath);
        }

        return new Adapter(resource);
    }
379211
def application_adapter(obj, request):
    
    return {
        'title': obj.title,
        'uri': obj.uri,
        'service_url': obj.service_url,
        'success': obj.success,
        'has_references': obj.has_references,
        'count': obj.count,
        'items': [{
                      'uri': i.uri,
                      'title': i.title
                  } for i in obj.items] if obj.items is not None else None
    }
1270900
@SuppressWarnings("unchecked")
    private static <T> T getHighLevelElementByServiceImplBean(String portLink, Adaptable containerToAdapt, Class<T> clazz, LinkType linkType) throws UnableToAdaptException {
        if (null == portLink) {
            return null;
        }
        if (PortComponent.class.isAssignableFrom(clazz)
            || WebserviceDescription.class.isAssignableFrom(clazz)) {
            Webservices wsXml = containerToAdapt.adapt(Webservices.class);
            if (null == wsXml) {
                return null;
            }
            for (WebserviceDescription wsDes : wsXml.getWebServiceDescriptions()) {
                if (wsDes.getPortComponents().size() == 0) {
                    continue;
                }
                for (PortComponent portCmpt : wsDes.getPortComponents()) {
                    ServiceImplBean servImplBean = portCmpt.getServiceImplBean();

                    String serviceLink = LinkType.SERVLET == linkType ? servImplBean.getServletLink() : servImplBean.getEJBLink();

                    if (serviceLink == null) {
                        continue;
                    } else if (serviceLink.equals(portLink)) {
                        if (PortComponent.class.isAssignableFrom(clazz)) {
                            return (T) portCmpt;
                        } else {
                            return (T) wsDes;
                        }
                    }
                }
            }
            return null;
        }
        return null;
    }
424980
public void loadModule(final JsiiModule module) {
        try {
            String tarball = extractResource(module.getModuleClass(), module.getBundleResourceName(), null);
            ObjectNode req = makeRequest("load");
            req.put("tarball", tarball);
            req.put("name", module.getModuleName());
            req.put("version", module.getModuleVersion());
            this.runtime.requestResponse(req);
        } catch (IOException e) {
            throw new JsiiException("Unable to extract resource " + module.getBundleResourceName(), e);
        }
    }
1219178
private IItemRenderer getItemRendererOverride(ItemStack itemStack)
	{
		for (ItemRendererOverride overrides : itemRendererOverrides)
		{
			IItemRenderer renderer = overrides.get(itemStack);
			if (renderer != null)
				return renderer;
		}

		return null;
	}
1036209
protected static <AdapterType> AdapterType getAdapter(Resource resource, Class<AdapterType> type) {
        if (type == ResourceHandle.class) {
            return type.cast(new ResourceHandle(resource));
        }
        log.info("Unable to adapt resource on {} to type {}", resource.getPath(), type.getName());
        return null;
    }
821283
protected function resolveModuleResource(ModuleResource $resource)
    {
        // Load from module resource
        $relativePath = $resource->getRelativePath();
        $exists = $resource->exists();
        $absolutePath = $resource->getPath();

        // Rewrite to _resources with public directory
        if (Director::publicDir()) {
            // All resources mapped directly to _resources/
            $relativePath = Path::join(RESOURCES_DIR, $relativePath);
        } elseif (stripos($relativePath, ManifestFileFinder::VENDOR_DIR . DIRECTORY_SEPARATOR) === 0) {
            // @todo Non-public dir support will be removed in 5.0, so remove this block there
            // If there is no public folder, map to _resources/ but trim leading vendor/ too (4.0 compat)
            $relativePath = Path::join(
                RESOURCES_DIR,
                substr($relativePath, strlen(ManifestFileFinder::VENDOR_DIR))
            );
        }
        return [$exists, $absolutePath, $relativePath];
    }
954898
protected ModuleSorter.Sorted sort(ServletContext context, Set<String> jars) {
        final ModuleSorter sorter = new ModuleSorter();

        try {
            _logger.config("There are " + jars.size() + " resource paths");
            ServiceModule.scan(context, jars, new Functor<Void, ServiceModule>() {
                public Void invoke(ServiceModule module) {
                    sorter.add(module);
                    return null;
                }
            }, _logger);
        } catch (Exception x) {
            throw new RuntimeException("Failed to sort service modules", x);
        }

        return sorter.sort();
    }
1179848
protected static <AdapterType> AdapterType getAdapter(ResourceHandle resourceHandle, Class<AdapterType> type) {
        if (type == ResourceHandle.class) {
            return type.cast(resourceHandle);
        }
        log.info("Unable to adapt resource on {} to type {}", resourceHandle.getPath(), type.getName());
        return null;
    }
307246
public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
        try {
            if (com.google.api.ads.admanager.axis.v201805.ContentMetadataKeyHierarchyServiceInterface.class.isAssignableFrom(serviceEndpointInterface)) {
                com.google.api.ads.admanager.axis.v201805.ContentMetadataKeyHierarchyServiceSoapBindingStub _stub = new com.google.api.ads.admanager.axis.v201805.ContentMetadataKeyHierarchyServiceSoapBindingStub(new java.net.URL(ContentMetadataKeyHierarchyServiceInterfacePort_address), this);
                _stub.setPortName(getContentMetadataKeyHierarchyServiceInterfacePortWSDDServiceName());
                return _stub;
            }
        }
        catch (java.lang.Throwable t) {
            throw new javax.xml.rpc.ServiceException(t);
        }
        throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface:  " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
    }
103589
@Override
    public WebModuleClassesInfo adapt(Container root, OverlayContainer rootOverlay, ArtifactContainer artifactContainer, Container containerToAdapt) throws UnableToAdaptException {
        WebModuleClassesInfo classesInfo = (WebModuleClassesInfo) rootOverlay.getFromNonPersistentCache(artifactContainer.getPath(), WebModuleClassesInfo.class);
        if (classesInfo != null) {
            //either we created this already, or OSGi prepopulated it.
            return classesInfo;
        }

        ArrayList<String> resolved = new ArrayList<String>();
        final List<ContainerInfo> containerInfos = new ArrayList<ContainerInfo>();

        //This should possibly be processing manifest classpath locations, like the old classloader did.. 
        Entry moduleEntry = containerToAdapt.adapt(Entry.class);
        if (moduleEntry != null && !moduleEntry.getPath().isEmpty()) {
            ManifestClassPathUtils.processMFClasspath(moduleEntry, containerInfos, resolved, true);
        }

        Entry classesEntry = containerToAdapt.getEntry("WEB-INF/classes");
        if (classesEntry != null) {
            final Container classesContainer = classesEntry.adapt(Container.class);
            if (classesContainer != null) {
                ContainerInfo containerInfo = new ContainerInfo() {
                    @Override
                    public Type getType() {
                        return Type.WEB_INF_CLASSES;
                    }

                    @Override
                    public String getName() {
                        return "WEB-INF/classes";
                    }

                    @Override
                    public Container getContainer() {
                        return classesContainer;
                    }
                };
                containerInfos.add(containerInfo);
            }
        }

        Entry libEntry = containerToAdapt.getEntry("WEB-INF/lib");
        if (libEntry != null) {
            Container libContainer = libEntry.adapt(Container.class);
            if (libContainer != null) {
                for (Entry entry : libContainer) {
                    if (entry.getName().toLowerCase().endsWith(".jar")) {
                        final String jarEntryName = entry.getName();
                        final Container jarContainer = entry.adapt(Container.class);
                        if (jarContainer != null) {
                            ContainerInfo containerInfo = new ContainerInfo() {
                                @Override
                                public Type getType() {
                                    return Type.WEB_INF_LIB;
                                }

                                @Override
                                public String getName() {
                                    return "WEB-INF/lib/" + jarEntryName;
                                }

                                @Override
                                public Container getContainer() {
                                    return jarContainer;
                                }
                            };
                            containerInfos.add(containerInfo);

                            ManifestClassPathUtils.addCompleteJarEntryUrls(containerInfos, entry, resolved);
                        }
                    }
                }
            }
        }

        classesInfo = new WebModuleClassesInfo() {
            @Override
            public List<ContainerInfo> getClassesContainers() {
                return containerInfos;
            }
        };

        rootOverlay.addToNonPersistentCache(artifactContainer.getPath(), WebModuleClassesInfo.class, classesInfo);
        return classesInfo;
    }
816374
public List<Dependency> getModuleAncestors(final String moduleName, final String moduleVersion) throws GrapesCommunicationException {
        final Client client = getClient();
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactAncestors(moduleName, moduleVersion));
        final ClientResponse response = resource.queryParam(ServerAPI.SCOPE_COMPILE_PARAM, "true")
                .queryParam(ServerAPI.SCOPE_PROVIDED_PARAM, "true")
                .queryParam(ServerAPI.SCOPE_RUNTIME_PARAM, "true")
                .queryParam(ServerAPI.SCOPE_TEST_PARAM, "true")
                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

        client.destroy();
        if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
            final String message = String.format(FAILED_TO_GET_MODULE, "get module ancestors", moduleName, moduleVersion);
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }

        return response.getEntity(new GenericType<List<Dependency>>(){});
    }
1068075
function loadAdapters() {
        var adapters = {};
        var adaptersDir = path.join(this.injector.rootDir, this.injector.servicesDir + '/adapters');

        if (!fs.existsSync(adaptersDir)) {
            return this.injector.adapters || {};
        }

        var me = this;
        var adapterNames = fs.readdirSync(adaptersDir);

        _.each(adapterNames, function (adapterName) {
            if (adapterName.substring(adapterName.length - 3) !== '.js') {  // only dirs, not js files
                var adapterImpl = me.injector.adapterMap[adapterName];
                adapterName = utils.getPascalCase(adapterImpl + '.' + adapterName + '.adapter');
                adapters[adapterName] = me.injector.loadModule(adapterName);
            }
        });

        // add the adapters that come from plugins to the list
        _.extend(adapters, this.injector.adapters);

        // return the adapters
        return adapters;
    }
719978
private static String getResourceLookup(Resource resource) // F743-16274.1
    {
        if (svResourceLookupMethod == null)
        {
            return "";
        }

        try
        {
            return (String) svResourceLookupMethod.invoke(resource, (Object[]) null);
        } catch (Exception ex)
        {
            throw new IllegalStateException(ex);
        }
    }
186158
private static String getModuleFolder(String moduleName) {

        if (moduleName == null) {
            return null;
        }
        CmsModule module = OpenCms.getModuleManager().getModule(moduleName);
        if (module != null) {
            for (String resource : module.getResources()) {
                if (CmsStringUtil.comparePaths("/system/modules/" + moduleName, resource)) {
                    return resource;
                }
            }
        }
        return null;
    }
284041
public com.google.javascript.jscomp.FunctionInformationMap.ModuleOrBuilder getModuleOrBuilder(
      int index) {
    return module_.get(index);
  }
1033466
public ServiceRRLoadBalancer getServiceRRLoadBalancer(String serviceName) {
        for (ServiceRRLoadBalancer lb : svcLBList) {
            if (lb.getServiceName().equals(serviceName)) {
                return lb;
            }
        }
        ServiceRRLoadBalancer lb = new ServiceRRLoadBalancer(lookupService,
                serviceName);
        svcLBList.add(lb);
        return lb;
    }