private void install()

in atomosfeaturelauncher/src/main/java/org/apache/sling/feature/launcher/atomos/AtomosRunner.java [120:185]


    private void install(final Framework framework, final Map<Integer, List<URL>> bundleMap) throws BundleException {
        System.out.println(System.getProperty("java.specification.version"));
        final BundleContext bc = framework.getBundleContext();
        // System.out.println(bc.getBundle(0).getHeaders());
        int defaultStartLevel = getProperty(bc, "felix.startlevel.bundle", 1);

        System.out.println(new File(".").getAbsolutePath());
        System.out.println(new File(new File("."), "content").getAbsolutePath());

        for (final Integer startLevel : sortStartLevels(bundleMap.keySet(), defaultStartLevel)) {
            logger.debug("Installing bundles with start level {}", startLevel);

            for (final URL file : bundleMap.get(startLevel)) {
                logger.debug("- {}", file);

                final URLStreamHandler dummyHandler = new URLStreamHandler() {
                    @Override
                    protected URLConnection openConnection(URL u) throws IOException {
                        return null;
                    }
                };

                AtomosContent content = getAtomos()
                        .getBootLayer()
                        .getAtomosContents().stream()
                        .filter(atomosContent -> {
                            try {
                                if (atomosContent instanceof  AtomosBase.AtomosLayerBase.AtomosContentIndexed) {
                                    ConnectContent.ConnectEntry fileLocation = atomosContent.getConnectContent().getEntry("META-INF/atomos/file.location").orElse(null);
                                    if (fileLocation != null) {
                                        String fileName = file.getPath().substring(file.getPath().lastIndexOf('/') + 1);
                                        return new String(fileLocation.getBytes()).endsWith(fileName);
                                    } else {
                                        return false;
                                    }
                                } else {
                                    return new URL(new URL(null, "missing:", dummyHandler), atomosContent.getAtomosLocation(), dummyHandler).getPath().endsWith(file.getPath().substring(file.getPath().lastIndexOf('/')));
                                }
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        })
                        .findFirst().orElseThrow(() -> new IllegalStateException("Unable to find " + file.getPath() + " on the classpath!"));

                final Bundle bundle = content.install();
                System.out.println(bundle.getBundleId() + " " + bundle.getLocation());

                // fragment?
                if (!isSystemBundleFragment(bundle) && getFragmentHostHeader(bundle) == null) {
                    if (startLevel > 0) {
                        bundle.adapt(BundleStartLevel.class).setStartLevel(startLevel);
                    }
                    bundle.start();
                }

                if (this.bundleReporter != null) {
                    final Map<String, String> params = new HashMap<>();
                    params.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
                    params.put(Constants.BUNDLE_VERSION, bundle.getVersion().toString());
                    params.put("Bundle-Id", String.valueOf(bundle.getBundleId()));

                    this.bundleReporter.accept(file, params);
                }
            }
        }
    }