public boolean handle()

in src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java [97:137]


    public boolean handle(ExtensionContext context, Extension extension) throws Exception {
        File registryHome = getRegistryHomeDir(context);
        if (extension.getType() == ExtensionType.ARTIFACTS
                && extension.getName().equals(Extension.EXTENSION_NAME_CONTENT_PACKAGES)) {

        	boolean useStrictMode = Boolean.getBoolean(getClass().getPackageName()+ ".useStrictMode");

            Map<Integer, Collection<Artifact>> orderedArtifacts = new TreeMap<>();
            for (final Artifact a : extension.getArtifacts()) {
                int order;
                // content-packages without explicit start-order to be installed last
                if (a.getMetadata().get(Artifact.KEY_START_ORDER) != null) {
                    order = a.getStartOrder();
                } else {
                    order = Integer.MAX_VALUE;
                }
                orderedArtifacts.computeIfAbsent(order, id -> new ArrayList<>()).add(a);
            }
            List<String> executionPlans = new ArrayList<>();
            Set<PackageId> satisfiedPackages = new HashSet<>();
            for (Collection<Artifact> artifacts : orderedArtifacts.values()) {
                ExecutionPlanBuilder builder = buildExecutionPlan(artifacts, satisfiedPackages, context, registryHome, useStrictMode);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                builder.save(baos);
                executionPlans.add(baos.toString(StandardCharsets.UTF_8));
            }
            // Workaround for too bold relocation mechanism - corresponding details at https://issues.apache.org/jira/browse/MSHADE-156
            final Configuration initcfg = new Configuration("org.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer");
            initcfg.getProperties().put("executionplans", executionPlans.toArray(new String[executionPlans.size()]));
            initcfg.getProperties().put("statusfilepath", registryHome.getAbsolutePath() + File.separator + "executedplans.file");
            context.addConfiguration(initcfg.getPid(), null, initcfg.getProperties());
            // Workaround for too bold relocation mechanism - corresponding details at https://issues.apache.org/jira/browse/MSHADE-156
            final Configuration registrycfg = new Configuration("org.UNSHADE.apache.jackrabbit.vault.packaging.registry.impl.FSPackageRegistry");
            registrycfg.getProperties().put("homePath", registryHome.getPath());
            context.addConfiguration(registrycfg.getPid(), null, registrycfg.getProperties());

            return true;
        } else {
            return false;
        }
    }