com.foreveross.springboot.dubbo.autoconfigure.DubboxAutoConfiguration Maven / Gradle / Ivy
package com.foreveross.springboot.dubbo.autoconfigure;
import com.foreveross.springboot.dubbo.commands.DubboxServiceLatchCommandLineRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
/**
* 应用程序启动过程中,Spring Boot使用SpringFactoriesLoader类加载器查找org.springframework.boot.autoconfigure.EnableAutoConfiguration关键字对应的Java配置文件。
* Spring Boot会遍历在各个jar包种META-INF目录下的spring.factories文件,构建成一个配置文件链表。
*/
@Configuration
@Order
@Import({DubboxConfig.class, JsonDateSerializer.class})
public class DubboxAutoConfiguration {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
@Value("${shutdown.latch.domain.name:com.foreveross.lifecycles}")
private String shutdownLatchDomainName;
@Bean
@ConditionalOnClass(name = "com.alibaba.dubbo.rpc.Exporter")
public DubboxServiceLatchCommandLineRunner configureDubboxServiceLatchCommandLineRunner() {
logger.debug("DubboxAutoConfiguration enabled by adding DubboxServiceLatchCommandLineRunner.\nShutdownLatchDomainName is " + this.shutdownLatchDomainName);
DubboxServiceLatchCommandLineRunner runner = new DubboxServiceLatchCommandLineRunner();
runner.setDomain(shutdownLatchDomainName);
return runner;
}
}