// Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/registry/IRegistry.java
// public interface IRegistry {
// 
//     /**
//      * 服务注册信息
//      *
//      * @param serviceName 服务名称 比如 zebra/service
//      * @param address     服务真实地址 比如 ip:port
//      */
//     void register(String serviceName, String address);
// 
//     /**
//      * 服务卸载
//      * @param serviceName
//      * @param address
//      */
//     void unRegister(String serviceName, String address);
// }


import com.zebra.boot.registry.IRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.Map;
package com.zebra.boot.listener;



/**
 * Created by js-dev.cn on 2016/11/24.
 * 监听器:当服务启动之后,立即监听并开始向注册中心Registry注册服务,告诉注册中心,自己是一个服务节点
 */
@Component
@ComponentScan
@WebListener
public class ZebraListener implements ServletContextListener{

    private static Logger logger = LoggerFactory.getLogger(ZebraListener.class);

    @Value("${server.address}")
    private String serverAddress;

    @Value("${server.port}")
    private int serverPort;

    @Autowired
// Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/registry/IRegistry.java
// public interface IRegistry {
// 
//     /**
//      * 服务注册信息
//      *
//      * @param serviceName 服务名称 比如 zebra/service
//      * @param address     服务真实地址 比如 ip:port
//      */
//     void register(String serviceName, String address);
// 
//     /**
//      * 服务卸载
//      * @param serviceName
//      * @param address
//      */
//     void unRegister(String serviceName, String address);
// }


// Path: zebra4j/zebra-boot/src/main/java/com/zebra/boot/listener/ZebraListener.java
import com.zebra.boot.registry.IRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.Map;

package com.zebra.boot.listener;



/**
 * Created by js-dev.cn on 2016/11/24.
 * 监听器:当服务启动之后,立即监听并开始向注册中心Registry注册服务,告诉注册中心,自己是一个服务节点
 */
@Component
@ComponentScan
@WebListener
public class ZebraListener implements ServletContextListener{

    private static Logger logger = LoggerFactory.getLogger(ZebraListener.class);

    @Value("${server.address}")
    private String serverAddress;

    @Value("${server.port}")
    private int serverPort;

    @Autowired
    private IRegistry registry;