package com.emc.ecs.serviceBroker.config;

import java.net.URISyntaxException;
import java.net.URL;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.servicebroker.model.BrokerApiVersion;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import com.emc.ecs.managementClient.Connection;
import com.emc.ecs.serviceBroker.EcsManagementClientException;
import com.emc.ecs.serviceBroker.EcsManagementResourceNotFoundException;
import com.emc.ecs.serviceBroker.EcsService;
import com.emc.ecs.serviceBroker.repository.ServiceInstanceBindingRepository;
import com.emc.ecs.serviceBroker.repository.ServiceInstanceRepository;
import com.emc.ecs.serviceBroker.service.EcsServiceInstanceBindingService;
import com.emc.ecs.serviceBroker.service.EcsServiceInstanceService;

@EnableAutoConfiguration
@ComponentScan
public class Application {
	
	@Autowired
	private BrokerConfig broker;

	public Application() {
		super();
	}

	@Bean
	public Connection ecsConnection() {
		URL certificate = getClass().getClassLoader()
				.getResource(broker.getCertificate());
		return new Connection(broker.getManagementEndpoint(),
				broker.getUsername(), broker.getPassword(), certificate);
	}
	
	@Bean
	public BrokerApiVersion brokerApiVersion() {
		return new BrokerApiVersion(broker.getBrokerApiVersion());
	}
	
	@Bean
	public EcsService ecsService() throws EcsManagementClientException,
			EcsManagementResourceNotFoundException {
		return new EcsService();
	}
	
	@Bean
	public EcsServiceInstanceBindingService ecsServiceInstanceBindingService()
			throws EcsManagementClientException,
			EcsManagementResourceNotFoundException, URISyntaxException {
		return new EcsServiceInstanceBindingService();
	}
	
	@Bean
	public ServiceInstanceRepository serviceInstanceRepository()
			throws EcsManagementClientException,
			EcsManagementResourceNotFoundException, URISyntaxException {
		return new ServiceInstanceRepository();
	}

	@Bean
	public EcsServiceInstanceService ecsServiceInstanceService()
			throws EcsManagementClientException,
			EcsManagementResourceNotFoundException, URISyntaxException {
		return new EcsServiceInstanceService();
	}
	
	@Bean
	public ServiceInstanceBindingRepository serviceInstanceBindingRepository()
			throws EcsManagementClientException,
			EcsManagementResourceNotFoundException, URISyntaxException {
		return new ServiceInstanceBindingRepository();
	}
	
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	public BrokerConfig getBroker() {
		return broker;
	}

	public void setBroker(BrokerConfig broker) {
		this.broker = broker;
	}
   	
}
@@ -1129,32 +1129,128 @@
 %0A%09%09super();%0A%09%7D%0A%0A
+%09public static void main(String%5B%5D args) %7B%0A%09%09SpringApplication.run(Application.class, args);%0A%09%7D%0A%0A
 %09@Bean%0A%09public C
@@ -2687,104 +2687,8 @@
 %7D%0A%09%0A
-%09public static void main(String%5B%5D args) %7B%0A%09%09SpringApplication.run(Application.class, args);%0A%09%7D%0A%0A
 %09pub

Move main function to the top