/*
 * Copyright 2014 Netflix, Inc.
 *
 * 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 com.netflix.spinnaker.front50.config;

import static retrofit.RestAdapter.LogLevel.BASIC;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jakewharton.retrofit.Ok3Client;
import com.netflix.spinnaker.config.DefaultServiceEndpoint;
import com.netflix.spinnaker.config.okhttp3.OkHttpClientProvider;
import com.netflix.spinnaker.front50.echo.EchoService;
import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger;
import okhttp3.OkHttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit.Endpoints;
import retrofit.RestAdapter;
import retrofit.converter.JacksonConverter;

/** echo service configuration */
@Configuration
public class EchoConfiguration {
  @Bean
  EchoService echoService(
      OkHttpClientProvider okHttpClientProvider, @Value("${echo.base-url:none}") String baseUrl) {
    if ("none".equals(baseUrl)) {
      return null;
    }

    OkHttpClient okHttpClient =
        okHttpClientProvider.getClient(new DefaultServiceEndpoint("echo", baseUrl));
    ObjectMapper objectMapper = new ObjectMapper();
    JacksonConverter jacksonConverter = new JacksonConverter(objectMapper);

    return new RestAdapter.Builder()
        .setEndpoint(Endpoints.newFixedEndpoint(baseUrl))
        .setClient(new Ok3Client(okHttpClient))
        .setConverter(jacksonConverter)
        .setLogLevel(BASIC)
        .setLog(new Slf4jRetrofitLogger(EchoService.class))
        .build()
        .create(EchoService.class);
  }
}

@@ -1113,16 +1113,95 @@
 .Value;%0A
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;%0A
 import o
@@ -1244,16 +1244,16 @@
 n.Bean;%0A
-
 import o
@@ -1455,16 +1455,64 @@
 uration%0A
+@ConditionalOnProperty(%22services.echo.enabled%22)%0A
 public c
@@ -1619,16 +1619,22 @@
 rovider,
+%0A     
  @Value(
@@ -1636,16 +1636,25 @@
 alue(%22$%7B
+services.
 echo.bas
@@ -1662,13 +1662,8 @@
 -url
-:none
 %7D%22) 
@@ -1684,68 +1684,8 @@
 ) %7B%0A
-    if (%22none%22.equals(baseUrl)) %7B%0A      return null;%0A    %7D%0A%0A
     

Add @ConditionalOnProperty, move property to services.echo. (#891)