com.gomcarter.frameworks.dubbo.factory.DubboApiRegistrar Maven / Gradle / Ivy
package com.gomcarter.frameworks.dubbo.factory;
import com.gomcarter.frameworks.base.common.ReflectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.*;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.Order;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* @author gomcarter on 2019-11-09 23:31:48
*/
@Order
@Slf4j
public class DubboApiRegistrar implements BeanPostProcessor {
private RegistryConfig rc;
private ApplicationConfig ac;
private ProtocolConfig pc;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
// register service
this.registerService(bean);
// registry reference
this.registerReference(bean);
return bean;
}
private void registerService(Object bean) {
Service service = bean.getClass().getAnnotation(Service.class);
if (service != null) {
// 如果打了service标签,则注册到注册中心去
Class[] interfaces = bean.getClass().getInterfaces();
if (interfaces != null) {
for (Class> itfas : interfaces) {
ServiceConfig
© 2015 - 2024 Weber Informatics LLC | Privacy Policy