private static List readComponentDescription()

in atomos.utils/atomos.utils.core/src/main/java/org/apache/felix/atomos/utils/core/LauncherImpl.java [92:132]


    private static List<ComponentDescription> readComponentDescription(JarFile jar)
        throws Exception
    {
        BundleLogger logger = new EmptyBundeLogger();
        List<ComponentMetadata> list = new ArrayList<>();
        Attributes attributes = jar.getManifest().getMainAttributes();
        String descriptorLocations = attributes.getValue("Service-Component");// ComponentConstants.SERVICE_COMPONENT);
        if (descriptorLocations != null)
        {
            StringTokenizer st = new StringTokenizer(descriptorLocations, ", ");
            while (st.hasMoreTokens())
            {
                String descriptorLocation = st.nextToken();
                try (
                    InputStream stream = jar.getInputStream(
                        jar.getEntry(descriptorLocation));
                    BufferedReader in = new BufferedReader(
                        new InputStreamReader(stream, "UTF-8")))
                {

                    XmlHandler handler = new XmlHandler(new PathBundle(jar), logger, true,
                        true);

                    final SAXParserFactory factory = SAXParserFactory.newInstance();
                    factory.setNamespaceAware(true);
                    final SAXParser parser = factory.newSAXParser();

                    parser.parse(stream, handler);
                    list.addAll(handler.getComponentMetadataList());
                }

            }
        }

        List<ComponentDescription> cds = list.stream().map(cmd -> {
            cmd.validate();
            return new ComponentDescriptionImpl(cmd);

        }).collect(Collectors.toList());
        return cds;
    }