package com.excavator.rpc.boot;

import com.excavator.rpc.boot.service.SayService;
import com.excavator.rpc.factory.ClientFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Configuration
@RestController
@SpringBootApplication
@RequestMapping("/test")
public class SpringClientConfig{

    String zkConn = "";

    @Bean
    public SayService clientFactoryBean() throws Exception{
        ClientFactoryBean<SayService> clientFactoryBean = new ClientFactoryBean<>();
        clientFactoryBean.setZkConn(zkConn);
        clientFactoryBean.setServiceName("hello");
        clientFactoryBean.setServiceInterface(SayService.class);

        return clientFactoryBean.getObject();
    }

    @Resource
    private SayService sayService;
    
    @RequestMapping("/hello")
    public String hello(String msg){
        return sayService.say(msg);
    }

    public static void main (String [] args) {
        SpringApplication.run(SpringClientConfig.class, "--server.port=8081");
    }
}

@@ -124,24 +124,83 @@
 actoryBean;%0A
+import org.springframework.beans.factory.annotation.Value;%0A
 import org.s
@@ -703,28 +703,128 @@
     
-String zkConn = %22%22;%0A
+@Value(%22$%7BzkConnection%7D%22)%0A    private String zkConnection;%0A%0A    @Value(%22$%7BserviceName%7D%22)%0A    private String serviceName;
 %0A   
@@ -1017,16 +1017,22 @@
 n(zkConn
+ection
 );%0A     
@@ -1071,15 +1071,19 @@
 ame(
-%22hello%22
+serviceName
 );%0A 

change get serviceName