package cn.fateverse.query.portal.config;

import org.apache.dubbo.config.spring.ServiceBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Clay
 * @date 2024/4/19 17:24
 */
@Component
public class DubboServiceBean {

    @Resource
    private ServiceBean serviceBean;

    private volatile int port;


    public int getPort() {
        if (port == 0) {
            synchronized (this) {
                if (port == 0) {
                    port = serviceBean.getExportedUrls().get(0).getPort();
                }
            }
        }
        return port;
    }
}
