public void activate()

in src/main/java/org/apache/sling/distribution/serialization/impl/vlt/VaultDistributionPackageBuilderFactory.java [204:282]


    public void activate(BundleContext context, Config conf) {

        String name = conf.name();
        String type = conf.type();
        String importModeString = SettingsUtils.removeEmptyEntry(conf.importMode());
        String aclHandlingString = SettingsUtils.removeEmptyEntry(conf.aclHandling());
        String cugHandlingString = SettingsUtils.removeEmptyEntry(conf.cugHandling());

        String[] packageRoots = SettingsUtils.removeEmptyEntries(conf.package_roots());
        String[] packageNodeFilters = SettingsUtils.removeEmptyEntries(conf.package_filters());
        String[] packagePropertyFilters = SettingsUtils.removeEmptyEntries(conf.property_filters());

        long cleanupDelay = conf.cleanupDelay();

        String tempFsFolder = SettingsUtils.removeEmptyEntry(conf.tempFsFolder());
        boolean useBinaryReferences = conf.useBinaryReferences();

        String digestAlgorithm = conf.digestAlgorithm();
        if (DEFAULT_DIGEST_ALGORITHM.equals(digestAlgorithm)) {
            digestAlgorithm = null;
        }

        // check the mount path patterns, if any
        Map<String, String> pathsMapping = toMap(conf.pathsMapping(), new String[0]);
        pathsMapping = SettingsUtils.removeEmptyEntries(pathsMapping);

        // import settings
        int autosaveThreshold = conf.autoSaveThreshold();

        ImportMode importMode = null;
        if (importModeString != null) {
            importMode = ImportMode.valueOf(importModeString.trim());
        }

        AccessControlHandling aclHandling = null;
        if (aclHandlingString != null) {
            aclHandling = AccessControlHandling.valueOf(aclHandlingString.trim());
        }

        AccessControlHandling cugHandling = null;
        if (cugHandlingString != null) {
            cugHandling = AccessControlHandling.valueOf(cugHandlingString.trim());
        }

        boolean strictImport = conf.strictImport();

        boolean overwritePrimaryTypesOfFolders = conf.overwritePrimaryTypesOfFolders();

        IdConflictPolicy idConflictPolicy = conf.idConflictPolicy();

        ImportSettings importSettings = new ImportSettings(importMode, aclHandling, cugHandling, autosaveThreshold, strictImport,
                overwritePrimaryTypesOfFolders, idConflictPolicy);

        DistributionContentSerializer contentSerializer = new FileVaultContentSerializer(name, packaging, packageRoots, packageNodeFilters,
                packagePropertyFilters, useBinaryReferences, pathsMapping, importSettings);

        DistributionPackageBuilder wrapped;
        if ("filevlt".equals(type)) {
            wrapped = new FileDistributionPackageBuilder(name, contentSerializer, tempFsFolder, digestAlgorithm, packageNodeFilters, packagePropertyFilters);
        } else if ("inmemory".equals(type)) {
            wrapped = new InMemoryDistributionPackageBuilder(name, contentSerializer, packageNodeFilters, packagePropertyFilters);
        } else {
            final int fileThreshold = conf.fileThreshold();
            String memoryUnitName = conf.MEGA_BYTES();
            final MemoryUnit memoryUnit = MemoryUnit.valueOf(memoryUnitName);
            final boolean useOffHeapMemory = conf.useOffHeapMemory();
            ResourceDistributionPackageBuilder resourceDistributionPackageBuilder = new ResourceDistributionPackageBuilder(contentSerializer.getName(), contentSerializer, tempFsFolder, fileThreshold, memoryUnit, useOffHeapMemory, digestAlgorithm, packageNodeFilters, packagePropertyFilters);
            Runnable cleanup = new ResourceDistributionPackageCleanup(resolverFactory, resourceDistributionPackageBuilder);
            Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(Scheduler.PROPERTY_SCHEDULER_CONCURRENT, false);
            props.put(Scheduler.PROPERTY_SCHEDULER_PERIOD, cleanupDelay);
            props.put(Scheduler.PROPERTY_SCHEDULER_RUN_ON, Scheduler.VALUE_RUN_ON_SINGLE);
            packageCleanup = context.registerService(Runnable.class, cleanup, props);
            wrapped = resourceDistributionPackageBuilder;
        }

        int monitoringQueueSize = conf.monitoringQueueSize();
        packageBuilder = new MonitoringDistributionPackageBuilder(monitoringQueueSize, wrapped, context);
    }