/*
 * Licensed to CRATE Technology GmbH ("Crate") under one or more contributor
 * license agreements.  See the NOTICE file distributed with this work for
 * additional information regarding copyright ownership.  Crate licenses
 * this file to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.  You may
 * obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * However, if you have executed another commercial license agreement
 * with Crate these terms will supersede the license and you may use the
 * software solely pursuant to the terms of the relevant commercial agreement.
 */

package io.crate.plugin;

import io.crate.http.netty.CrateNettyHttpServerTransport;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;

import java.util.*;

import static org.elasticsearch.common.network.NetworkModule.HTTP_TYPE_KEY;
import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_COMPRESSION;


public class HttpTransportPlugin extends Plugin implements ActionPlugin {

    private static final String CRATE_HTTP_TRANSPORT_NAME = "crate";

    public String name() {
        return "http";
    }

    public String description() {
        return "Plugin for extending HTTP transport";
    }

    @Override
    public Collection<Module> createGuiceModules() {
        return Collections.emptyList();
    }

    @Override
    public Settings additionalSettings() {
        return Settings.builder()
            .put(HTTP_TYPE_KEY, CRATE_HTTP_TRANSPORT_NAME)
            .put(SETTING_HTTP_COMPRESSION.getKey(), false)
            .build();
    }

    @Override
    public List<Setting<?>> getSettings() {
        return Collections.emptyList();
    }

    @Override
    public Collection<Class<? extends LifecycleComponent>> getGuiceServiceClasses() {
        return Collections.emptyList();
    }

    public void onModule(NetworkModule networkModule) {
        if (networkModule.canRegisterHttpExtensions()) {
            networkModule.registerHttpTransport(CRATE_HTTP_TRANSPORT_NAME, CrateNettyHttpServerTransport.class);
        }
    }

    @Override
    public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
        return Collections.emptyList();
    }
}

@@ -1102,103 +1102,8 @@
 rt;%0A
-import org.elasticsearch.action.ActionRequest;%0Aimport org.elasticsearch.action.ActionResponse;%0A
 impo
@@ -1400,22 +1400,16 @@
 ins.
-Action
 Plugin;%0A
 impo
@@ -1408,49 +1408,67 @@
 in;%0A
+%0A
 import 
-org.elasticsearch.plugins.Plugin;%0A
+java.util.Collection;%0Aimport java.util.Collections;
 %0Aimp
@@ -1481,17 +1481,20 @@
 va.util.
-*
+List
 ;%0A%0Aimpor
@@ -1703,32 +1703,8 @@
 gin 
-implements ActionPlugin 
 %7B%0A%0A 
@@ -2773,168 +2773,7 @@
    %7D
-%0A%0A    @Override%0A    public List%3CActionHandler%3C? extends ActionRequest%3C?%3E, ? extends ActionResponse%3E%3E getActions() %7B%0A        return Collections.emptyList();%0A    %7D
 %0A%7D%0A

Remove ActionPlugin implementation from HttpTransportPlugin