/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.platform.service.impl;

import com.crunii.micro.platform.jdbc.MicroJdbcDao;
import com.crunii.micro.platform.service.MicroService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author 田平 create 2018年10月10日下午3:33:18
 */
public class MicroServiceImpl implements MicroService, InitializingBean {

	@Autowired
	private MicroJdbcDao microJdbcDao;

	@Value("${spring.application.name}")
	private String serviceCode;

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

	@Override
	public void afterPropertiesSet() {
		boolean confPort = microJdbcDao.validatePort(serviceCode, port);
		if (!confPort) {
			throw new RuntimeException("please config port at table t_service and port not allow in extend_ports!");
		}
	}
}
