private Set findModuleLayerAtomosBundles()

in atomos/src/main/java/org/apache/felix/atomos/impl/modules/AtomosModules.java [409:496]


        private Set<AtomosContentBase> findModuleLayerAtomosBundles(
            ModuleLayer searchLayer)
        {
            Set<AtomosContentBase> found = new LinkedHashSet<>();
            Map<ModuleDescriptor, Module> descriptorMap = searchLayer.modules().stream().collect(
                Collectors.toMap(Module::getDescriptor, m -> (m)));

            for (ResolvedModule resolved : searchLayer.configuration().modules())
            {
                // include only if it is not excluded
                Module m = descriptorMap.get(resolved.reference().descriptor());
                if (m == null)
                {
                    continue;
                }

                String location;
                if (m.getDescriptor().provides().stream().anyMatch(
                    (p) -> FrameworkFactory.class.getName().equals(p.service())))
                {
                    // we assume a module that provides the FrameworkFactory is the system bundle
                    location = Constants.SYSTEM_BUNDLE_LOCATION;
                }
                else
                {
                    location = resolved.reference().location().map((u) -> {
                        StringBuilder sb = new StringBuilder();
                        if (!getName().isEmpty())
                        {
                            sb.append(getName()).append(':');
                        }
                        sb.append(u.toString());
                        return sb.toString();
                    }).orElse(null);
                }
                if (location == null)
                {
                    continue;
                }

                ManifestHolder holder = new ManifestHolder();

                ConnectContent content = new ConnectContentModule(m, resolved.reference(), AtomosLayerModules.this, holder::getHeaders);

                Map<String, String> headers;
                try
                {
                    content.open();
                    try
                    {
                        headers = getRawHeaders(content);
                    }
                    finally
                    {
                        content.close();
                    }
                }
                catch (IOException e)
                {
                    throw new UncheckedIOException("Error reading connect manifest.", e);
                }



                generateHeaders(headers, m);

                headers = applyHeaderProvider(holder, location, headers);

                String symbolicName = headers.get(Constants.BUNDLE_SYMBOLICNAME);
                if (symbolicName != null)
                {
                    int semiColon = symbolicName.indexOf(';');
                    if (semiColon != -1)
                    {
                        symbolicName = symbolicName.substring(0, semiColon);
                    }
                    symbolicName = symbolicName.trim();

                    Version version = Version.parseVersion(
                        headers.get(Constants.BUNDLE_VERSION));

                    found.add(new AtomosContentModule(m, location,
                            symbolicName, version, content));
                }
            }

            return Collections.unmodifiableSet(found);
        }