// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.filedistribution;

import com.google.inject.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.application.api.FileRegistry;
import com.yahoo.config.model.api.FileDistribution;
import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Transport;
import com.yahoo.vespa.defaults.Defaults;

import java.io.File;

/**
 * Factory for creating providers that are used to interact with file distribution.
 *
 * @author Ulf Lilleengen
 */
@SuppressWarnings("WeakerAccess")
public class FileDistributionFactory {

    protected final ConfigserverConfig configserverConfig;
    private final Supervisor supervisor = new Supervisor(new Transport("filedistribution"));

    @Inject
    public FileDistributionFactory(ConfigserverConfig configserverConfig) {
        this.configserverConfig = configserverConfig;
    }

    public FileRegistry createFileRegistry(File applicationPackage) {
        return new FileDBRegistry(new ApplicationFileManager(applicationPackage, new FileDirectory(getFileReferencesDir())));
    }

    public FileDistribution createFileDistribution() {
        return new FileDistributionImpl(getFileReferencesDir(), supervisor);
    }

    public AddFileInterface createFileManager(File applicationDir) {
        return new ApplicationFileManager(applicationDir, new FileDirectory(getFileReferencesDir()));
    }

    protected File getFileReferencesDir() {
        return new File(Defaults.getDefaults().underVespaHome(configserverConfig.fileReferencesDir()));
    }

}

@@ -1083,31 +1083,22 @@
 egistry(
-new Application
+create
 FileMana
@@ -1123,51 +1123,8 @@
 kage
-, new FileDirectory(getFileReferencesDir())
 ));%0A

Use existing method to create an AddFileInterface