/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed 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.
 */
package io.gravitee.gateway.debug.vertx;

import io.gravitee.common.service.AbstractService;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author Guillaume CUSNIEUX (guillaume.cusnieux at graviteesource.com)
 * @author GraviteeSource Team
 */
public class VertxDebugService extends AbstractService {

    /**
     * Logger.
     */
    private final Logger logger = LoggerFactory.getLogger(VertxDebugService.class);

    @Autowired
    private Vertx vertx;

    private String deploymentId;

    @Value("${http.instances:0}")
    private int instances;

    @Override
    public VertxDebugService start() {
        doStart();
        return this;
    }

    @Override
    public VertxDebugService stop() {
        doStop();
        return this;
    }

    @Override
    protected void doStart() {
        instances = (instances < 1) ? VertxOptions.DEFAULT_EVENT_LOOP_POOL_SIZE : instances;
        logger.info("Starting Vertx DEBUG container and deploy Gateway Verticles [{} instance(s)]", instances);

        final DebugReactorVerticle debugReactorVerticle = new DebugReactorVerticle();
        applicationContext.getAutowireCapableBeanFactory().autowireBean(debugReactorVerticle);

        vertx.deployVerticle(
            debugReactorVerticle,
            event -> {
                if (event.failed()) {
                    logger.warn("Unable to start Debug HTTP server", event.cause());
                } else {
                    deploymentId = event.result();
                }
            }
        );
    }

    @Override
    protected void doStop() {
        if (deploymentId != null) {
            vertx.undeploy(
                deploymentId,
                event -> {
                    lifecycle.moveToStopped();
                }
            );
        }
    }
}

@@ -749,43 +749,8 @@
 tx;%0A
-import io.vertx.core.VertxOptions;%0A
 impo
@@ -770,16 +770,16 @@
 Logger;%0A
+
 import o
@@ -868,67 +868,8 @@
 red;
-%0Aimport org.springframework.beans.factory.annotation.Value;
 %0A%0A/*
@@ -1231,70 +1231,8 @@
 d;%0A%0A
-    @Value(%22$%7Bhttp.instances:0%7D%22)%0A    private int instances;%0A%0A
     
@@ -1474,101 +1474,8 @@
 ) %7B%0A
-        instances = (instances %3C 1) ? VertxOptions.DEFAULT_EVENT_LOOP_POOL_SIZE : instances;%0A
     
@@ -1537,54 +1537,33 @@
 loy 
-Gateway Verticles %5B%7B%7D instance(s)%5D%22, instances
+1 Debug Reactor Verticle%22
 );%0A%0A

clean dead code for instances number in debug service gravitee-io/issues#6073