Search in sources :

Example 1 with ServiceDescriptor

use of org.apache.dubbo.rpc.model.ServiceDescriptor in project dubbo by alibaba.

the class SimpleRegistryExporter method registerProvider.

private void registerProvider(URL url, RegistryService registryService) {
    ServiceRepository repository = ApplicationModel.getServiceRepository();
    ServiceDescriptor serviceDescriptor = repository.registerService(RegistryService.class);
    repository.registerProvider(url.getServiceKey(), registryService, serviceDescriptor, null, null);
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor) ServiceRepository(org.apache.dubbo.rpc.model.ServiceRepository)

Example 2 with ServiceDescriptor

use of org.apache.dubbo.rpc.model.ServiceDescriptor in project dubbo by alibaba.

the class ReferenceConfig method checkAndUpdateSubConfigs.

/**
 * This method should be called right after the creation of this class's instance, before any property in other config modules is used.
 * Check each config modules are created properly and override their properties if necessary.
 */
public void checkAndUpdateSubConfigs() {
    if (StringUtils.isEmpty(interfaceName)) {
        throw new IllegalStateException("<dubbo:reference interface=\"\" /> interface not allow null!");
    }
    completeCompoundConfigs(consumer);
    // get consumer's global configuration
    checkDefault();
    // init some null configuration.
    List<ConfigInitializer> configInitializers = ExtensionLoader.getExtensionLoader(ConfigInitializer.class).getActivateExtension(URL.valueOf("configInitializer://"), (String[]) null);
    configInitializers.forEach(e -> e.initReferConfig(this));
    this.refresh();
    if (getGeneric() == null && getConsumer() != null) {
        setGeneric(getConsumer().getGeneric());
    }
    if (ProtocolUtils.isGeneric(generic)) {
        interfaceClass = GenericService.class;
    } else {
        try {
            interfaceClass = Class.forName(interfaceName, true, Thread.currentThread().getContextClassLoader());
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
        checkInterfaceAndMethods(interfaceClass, getMethods());
    }
    initServiceMetadata(consumer);
    serviceMetadata.setServiceType(getActualInterface());
    // TODO, uncomment this line once service key is unified
    serviceMetadata.setServiceKey(URL.buildKey(interfaceName, group, version));
    ServiceRepository repository = ApplicationModel.getServiceRepository();
    ServiceDescriptor serviceDescriptor = repository.registerService(interfaceClass);
    repository.registerConsumer(serviceMetadata.getServiceKey(), serviceDescriptor, this, null, serviceMetadata);
    resolveFile();
    ConfigValidationUtils.validateReferenceConfig(this);
    postProcessConfig();
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor) ServiceRepository(org.apache.dubbo.rpc.model.ServiceRepository)

Example 3 with ServiceDescriptor

use of org.apache.dubbo.rpc.model.ServiceDescriptor in project dubbo by alibaba.

the class ListTelnetHandlerTest method registerProvider.

private void registerProvider(String key, Object impl, Class<?> interfaceClass) {
    ServiceConfigBase sc = mock(ServiceConfigBase.class);
    given(sc.getRegistries()).willReturn(new ArrayList<>());
    ServiceDescriptor serviceDescriptor = repository.registerService(interfaceClass);
    repository.registerProvider(key, impl, serviceDescriptor, sc, null);
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor) ServiceConfigBase(org.apache.dubbo.config.ServiceConfigBase)

Example 4 with ServiceDescriptor

use of org.apache.dubbo.rpc.model.ServiceDescriptor in project dubbo by alibaba.

the class SelectTelnetHandlerTest method registerProvider.

private void registerProvider(String key, Object impl, Class<?> interfaceClass) {
    ServiceDescriptor serviceDescriptor = repository.registerService(interfaceClass);
    repository.registerProvider(key, impl, serviceDescriptor, null, null);
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor)

Example 5 with ServiceDescriptor

use of org.apache.dubbo.rpc.model.ServiceDescriptor in project dubbo by alibaba.

the class RpcInvocation method initParameterDesc.

private void initParameterDesc() {
    ServiceRepository repository = ApplicationModel.getServiceRepository();
    if (StringUtils.isNotEmpty(serviceName)) {
        ServiceDescriptor serviceDescriptor = repository.lookupService(serviceName);
        if (serviceDescriptor != null) {
            MethodDescriptor methodDescriptor = serviceDescriptor.getMethod(methodName, parameterTypes);
            if (methodDescriptor != null) {
                this.parameterTypesDesc = methodDescriptor.getParamDesc();
                this.compatibleParamSignatures = methodDescriptor.getCompatibleParamSignatures();
                this.returnTypes = methodDescriptor.getReturnTypes();
                this.returnType = methodDescriptor.getReturnClass();
            }
        }
    }
    if (parameterTypesDesc == null) {
        this.parameterTypesDesc = ReflectUtils.getDesc(this.getParameterTypes());
        this.compatibleParamSignatures = Stream.of(this.parameterTypes).map(Class::getName).toArray(String[]::new);
        this.returnTypes = RpcUtils.getReturnTypes(this);
        this.returnType = RpcUtils.getReturnType(this);
    }
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor) ServiceRepository(org.apache.dubbo.rpc.model.ServiceRepository) MethodDescriptor(org.apache.dubbo.rpc.model.MethodDescriptor)

Aggregations

ServiceDescriptor (org.apache.dubbo.rpc.model.ServiceDescriptor)13 URL (org.apache.dubbo.common.URL)5 ServiceRepository (org.apache.dubbo.rpc.model.ServiceRepository)5 Test (org.junit.jupiter.api.Test)4 RegistryProtocol (org.apache.dubbo.registry.integration.RegistryProtocol)2 MethodDescriptor (org.apache.dubbo.rpc.model.MethodDescriptor)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Cleanable (org.apache.dubbo.common.serialize.Cleanable)1 ObjectInput (org.apache.dubbo.common.serialize.ObjectInput)1 ServiceConfigBase (org.apache.dubbo.config.ServiceConfigBase)1 NotifyListener (org.apache.dubbo.registry.NotifyListener)1 Protocol (org.apache.dubbo.rpc.Protocol)1 DubboInvoker (org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker)1 DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol)1