package com.dtolabs.rundeck.core.plugins;

import com.dtolabs.rundeck.core.common.Framework;
import com.dtolabs.rundeck.core.common.IFramework;

import java.util.Map;

/**
 * Created by greg on 5/5/16.
 */
public class ServiceFactory {

    /**
     *
     * @param framework
     * @param serviceName
     * @param classes
     * @param <T>
     * @return
     * @deprecated
     */
    public static <T> BaseProviderRegistryService<T> builtinService(
            final Framework framework,
            final String serviceName,
            final Map<String, Class<? extends T>> classes
    )
    {
        return new BaseProviderRegistryService<T>(framework, classes) {
            @Override
            public String getName() {
                return serviceName;
            }
        };
    }

    public static <T> IFrameworkProviderRegistryService<T> builtinService(
            final IFramework framework,
            final String serviceName,
            final Map<String, Class<? extends T>> classes
    )
    {
        return new IFrameworkProviderRegistryService<T>(framework, classes) {
            @Override
            public String getName() {
                return serviceName;
            }
        };
    }

    /**
     * @param serviceName
     * @param framework
     * @param providerClass
     * @param <T>
     * @deprecated use {@link #pluginService(String, Class, ServiceProviderLoader)}
     */
    @Deprecated
    public static <T> PluggableProviderService<T> pluginService(
            final String serviceName,
            final Framework framework,
            final Class<T> providerClass
    )
    {
        return new
                FrameworkPluggableProviderService<T>(
                serviceName,
                framework,
                providerClass
        );
    }

    /**
     * Creates a pluggable service using a provider loader
     *
     * @param serviceName
     * @param providerClass
     * @param serviceProviderLoader
     * @param <T>
     */
    public static <T> PluggableProviderService<T> pluginService(
            final String serviceName,
            final Class<T> providerClass,
            final ServiceProviderLoader serviceProviderLoader
    )
    {
        return new
                BasePluggableProviderServiceImpl<T>(
                serviceName,
                providerClass,
                serviceProviderLoader
        );
    }
}

@@ -1214,32 +1214,399 @@
       %7D;%0A    %7D%0A%0A
+    public static %3CT%3E ProviderRegistryService%3CT%3E builtinService(%0A%0A            final String serviceName,%0A            final Map%3CString, Class%3C? extends T%3E%3E classes%0A    )%0A    %7B%0A        return new AbstractProviderRegistryService%3CT%3E(classes) %7B%0A            @Override%0A            public String getName() %7B%0A                return serviceName;%0A            %7D%0A        %7D;%0A    %7D%0A%0A
     /**%0A     * @

create a registry service without framework