// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.di;

import com.yahoo.component.ComponentSpecification;
import com.yahoo.config.FileReference;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.container.bundle.MockBundle;
import org.osgi.framework.Bundle;

import java.util.Collection;
import java.util.Set;
import java.util.stream.Collectors;

import static java.util.Collections.emptySet;

/**
 * @author gjoranv
 * @author Tony Vaagenes
 * @author ollivir
 */
public interface Osgi {

    default void installPlatformBundles(Collection<String> bundlePaths) {
        System.out.println("installPlatformBundles " + bundlePaths);
    }

    /**
     * Returns the set of bundles that is not used by the current application generation,
     * and therefore should be scheduled for uninstalling.
     */
    default Set<Bundle> useApplicationBundles(Collection<FileReference> bundles) {
        System.out.println("useBundles " + bundles.stream().map(Object::toString).collect(Collectors.joining(", ")));
        return emptySet();
    }

    default Class<?> resolveClass(BundleInstantiationSpecification spec) {
        System.out.println("resolving class " + spec.classId);
        try {
            return Class.forName(spec.classId.getName());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    default Bundle getBundle(ComponentSpecification spec) {
        System.out.println("resolving bundle " + spec);
        return new MockBundle();
    }
}

@@ -509,16 +509,160 @@
 t;%0A%0A/**%0A
+ * This interface has default implementations of all methods, to allow using it%0A * for testing, instead of mocking or a test implementation.%0A *%0A
  * @auth
@@ -672,16 +672,16 @@
 gjoranv%0A
-
  * @auth
@@ -819,32 +819,34 @@
 aths) %7B%0A        
+//
 System.out.print
@@ -1145,32 +1145,34 @@
 dles) %7B%0A        
+//
 System.out.print
@@ -1374,32 +1374,34 @@
 spec) %7B%0A        
+//
 System.out.print
@@ -1676,24 +1676,24 @@
 spec) %7B%0A
-
         
 System.o
@@ -1684,16 +1684,18 @@
         
+//
 System.o

Comment debug println and add class comment.