// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component;

import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.config.model.producer.AbstractConfigProducer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

/**
 * Models a jdisc RequestHandler (including ClientProvider).
 * RequestHandlers always have at least one server binding,
 * while ClientProviders have at least one client binding.
 * <p>
 * Note that this is also used to model vespa handlers (which do not have any bindings)
 *
 * @author gjoranv
 */
public class Handler<CHILD extends AbstractConfigProducer<?>> extends Component<CHILD, ComponentModel> {

    private Set<String> serverBindings = new LinkedHashSet<>();
    private List<String> clientBindings = new ArrayList<>();

    public Handler(ComponentModel model) {
        super(model);
    }

    public static Handler<AbstractConfigProducer<?>> fromClassName(String className) {
        return new Handler<>(new ComponentModel(className, null, null, null));
    }

    public static Handler<AbstractConfigProducer<?>> getVespaHandlerFromClassName(String className) {
        return new Handler<>(new ComponentModel(BundleInstantiationSpecification.getInternalHandlerSpecificationFromStrings(className, null), null));
    }

    public void addServerBindings(String... bindings) {
        serverBindings.addAll(Arrays.asList(bindings));
    }

    public void removeServerBinding(String binding) {
        serverBindings.remove(binding);
    }

    public void addClientBindings(String... bindings) {
        clientBindings.addAll(Arrays.asList(bindings));
    }

    public final Set<String> getServerBindings() {
        return Collections.unmodifiableSet(serverBindings);
    }

    public final List<String> getClientBindings() {
        return Collections.unmodifiableList(clientBindings);
    }

}

@@ -188,54 +188,49 @@
 .con
-tainer.bundle.BundleInstantiationSpecification
+fig.model.producer.AbstractConfigProducer
 ;%0Aim
@@ -283,71 +283,8 @@
 del;
-%0Aimport com.yahoo.config.model.producer.AbstractConfigProducer;
 %0A%0Aim
@@ -1228,267 +1228,8 @@
  %7D%0A%0A
-    public static Handler%3CAbstractConfigProducer%3C?%3E%3E getVespaHandlerFromClassName(String className) %7B%0A        return new Handler%3C%3E(new ComponentModel(BundleInstantiationSpecification.getInternalHandlerSpecificationFromStrings(className, null), null));%0A    %7D%0A%0A
     

Remove unused method