【静态内部类】使用案例
一、使用静态内部类,声明框架代码,不允许外部调用者使用的方式
@Configuration @ConditionalOnClass({ThriftServerPublisher.class}) @ConditionalOnProperty( prefix = "thrift", name = {"enabled"}, havingValue = "true", matchIfMissing = true ) public class ThriftServerPublisherAutoConfiguration { private static final Logger log = LoggerFactory.getLogger(ThriftServerPublisherAutoConfiguration.class); public ThriftServerPublisherAutoConfiguration() { } @Bean public static ThriftServerPublisherAutoConfiguration.ThriftServerPublisherBeanDefinitionRegistryPostProcessor thriftServerPublisherBeanDefinitionRegistryPostProcessor() { return new ThriftServerPublisherAutoConfiguration.ThriftServerPublisherBeanDefinitionRegistryPostProcessor(); } static class ThriftServerPublisherBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor { ThriftServerPublisherBeanDefinitionRegistryPostProcessor() { } public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException { //填充业务逻辑代码,向spring容器中注入业务bean } }