summaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/core/config/DiskBundleInstaller.java
blob: 87c3d3048c5afa6a48497c2bd3bbeaf70e5d1701 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.core.config;

import com.yahoo.config.FileReference;
import com.yahoo.osgi.Osgi;
import org.osgi.framework.Bundle;

import java.io.File;
import java.util.List;

/**
 * @author gjoranv
 */
public class DiskBundleInstaller implements BundleInstaller {

    @Override
    public List<Bundle> installBundles(FileReference reference, Osgi osgi) {
        // TODO: remove when the last model producing 'file:' has rolled out of hosted
        String referenceFileName = reference.value().startsWith("file:")
                ? reference.value().substring("file:".length())
                : reference.value();

        File file = new File(referenceFileName);
        if ( ! file.exists()) {
            throw new IllegalArgumentException("Reference '" + reference.value() + "' not found on disk.");
        }

        return osgi.install(file.getAbsolutePath());
    }

}