Search in sources :

Example 1 with ConfigManager

use of org.apache.dubbo.config.context.ConfigManager in project dubbo by alibaba.

the class PublishingServiceDefinitionListenerTest method init.

@BeforeEach
public void init() {
    DubboBootstrap.reset();
    String metadataType = DEFAULT_METADATA_STORAGE_TYPE;
    ConfigManager configManager = ApplicationModel.getConfigManager();
    ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-demo-provider");
    applicationConfig.setMetadataType(metadataType);
    configManager.setApplication(applicationConfig);
    this.writableMetadataService = WritableMetadataService.getDefaultExtension();
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ConfigManager(org.apache.dubbo.config.context.ConfigManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ConfigManager

use of org.apache.dubbo.config.context.ConfigManager in project dubbo by alibaba.

the class GrpcOptionsUtils method buildServerSslContext.

private static SslContext buildServerSslContext(URL url) {
    ConfigManager globalConfigManager = ApplicationModel.getConfigManager();
    SslConfig sslConfig = globalConfigManager.getSsl().orElseThrow(() -> new IllegalStateException("Ssl enabled, but no ssl cert information provided!"));
    SslContextBuilder sslClientContextBuilder = null;
    InputStream serverKeyCertChainPathStream = null;
    InputStream serverPrivateKeyPathStream = null;
    InputStream trustCertCollectionFilePath = null;
    try {
        serverKeyCertChainPathStream = sslConfig.getServerKeyCertChainPathStream();
        serverPrivateKeyPathStream = sslConfig.getServerPrivateKeyPathStream();
        String password = sslConfig.getServerKeyPassword();
        if (password != null) {
            sslClientContextBuilder = GrpcSslContexts.forServer(serverKeyCertChainPathStream, serverPrivateKeyPathStream, password);
        } else {
            sslClientContextBuilder = GrpcSslContexts.forServer(serverKeyCertChainPathStream, serverPrivateKeyPathStream);
        }
        trustCertCollectionFilePath = sslConfig.getServerTrustCertCollectionPathStream();
        if (trustCertCollectionFilePath != null) {
            sslClientContextBuilder.trustManager(trustCertCollectionFilePath);
            sslClientContextBuilder.clientAuth(ClientAuth.REQUIRE);
        }
    } catch (Exception e) {
        throw new IllegalArgumentException("Could not find certificate file or the certificate is invalid.", e);
    } finally {
        safeCloseStream(serverKeyCertChainPathStream);
        safeCloseStream(serverPrivateKeyPathStream);
        safeCloseStream(trustCertCollectionFilePath);
    }
    try {
        return sslClientContextBuilder.build();
    } catch (SSLException e) {
        throw new IllegalStateException("Build SslSession failed.", e);
    }
}
Also used : SslConfig(org.apache.dubbo.config.SslConfig) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) InputStream(java.io.InputStream) SSLException(javax.net.ssl.SSLException) ConfigManager(org.apache.dubbo.config.context.ConfigManager) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException)

Example 3 with ConfigManager

use of org.apache.dubbo.config.context.ConfigManager in project dubbo by alibaba.

the class AbstractInterfaceConfig method setConfigCenter.

@Deprecated
public void setConfigCenter(ConfigCenterConfig configCenter) {
    this.configCenter = configCenter;
    if (configCenter != null) {
        ConfigManager configManager = ApplicationModel.getConfigManager();
        Collection<ConfigCenterConfig> configs = configManager.getConfigCenters();
        if (CollectionUtils.isEmpty(configs) || configs.stream().noneMatch(existed -> existed.equals(configCenter))) {
            configManager.addConfigCenter(configCenter);
        }
    }
}
Also used : Arrays(java.util.Arrays) Assert(org.apache.dubbo.common.utils.Assert) Version(org.apache.dubbo.common.Version) COMMA_SPLIT_PATTERN(org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN) ConfigManager(org.apache.dubbo.config.context.ConfigManager) TIMESTAMP_KEY(org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY) StringUtils(org.apache.dubbo.common.utils.StringUtils) ArrayList(java.util.ArrayList) URL(org.apache.dubbo.common.URL) RELEASE_KEY(org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY) INVOKER_LISTENER_KEY(org.apache.dubbo.common.constants.CommonConstants.INVOKER_LISTENER_KEY) Map(java.util.Map) ReflectUtils(org.apache.dubbo.common.utils.ReflectUtils) ServiceMetadata(org.apache.dubbo.rpc.model.ServiceMetadata) TAG_KEY(org.apache.dubbo.common.constants.CommonConstants.TAG_KEY) ApplicationModel(org.apache.dubbo.rpc.model.ApplicationModel) CollectionUtils(org.apache.dubbo.common.utils.CollectionUtils) Collection(java.util.Collection) PID_KEY(org.apache.dubbo.common.constants.CommonConstants.PID_KEY) REFERENCE_FILTER_KEY(org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY) ConfigUtils(org.apache.dubbo.common.utils.ConfigUtils) DUBBO_VERSION_KEY(org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY) List(java.util.List) Parameter(org.apache.dubbo.config.support.Parameter) Optional(java.util.Optional) ConfigManager(org.apache.dubbo.config.context.ConfigManager)

Example 4 with ConfigManager

use of org.apache.dubbo.config.context.ConfigManager in project dubbo by alibaba.

the class AbstractInterfaceConfig method setModule.

@Deprecated
public void setModule(ModuleConfig module) {
    this.module = module;
    if (module != null) {
        ConfigManager configManager = ApplicationModel.getConfigManager();
        configManager.getModule().orElseGet(() -> {
            configManager.setModule(module);
            return module;
        });
    }
}
Also used : ConfigManager(org.apache.dubbo.config.context.ConfigManager)

Example 5 with ConfigManager

use of org.apache.dubbo.config.context.ConfigManager in project dubbo by alibaba.

the class AbstractInterfaceConfig method setMetrics.

@Deprecated
public void setMetrics(MetricsConfig metrics) {
    this.metrics = metrics;
    if (metrics != null) {
        ConfigManager configManager = ApplicationModel.getConfigManager();
        configManager.getMetrics().orElseGet(() -> {
            configManager.setMetrics(metrics);
            return metrics;
        });
    }
}
Also used : ConfigManager(org.apache.dubbo.config.context.ConfigManager)

Aggregations

ConfigManager (org.apache.dubbo.config.context.ConfigManager)14 SslConfig (org.apache.dubbo.config.SslConfig)5 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 SSLException (javax.net.ssl.SSLException)4 Collection (java.util.Collection)3 List (java.util.List)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Map (java.util.Map)2 Optional (java.util.Optional)2 URL (org.apache.dubbo.common.URL)2 Version (org.apache.dubbo.common.Version)2 COMMA_SPLIT_PATTERN (org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN)2 DUBBO_VERSION_KEY (org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY)2 INVOKER_LISTENER_KEY (org.apache.dubbo.common.constants.CommonConstants.INVOKER_LISTENER_KEY)2 PID_KEY (org.apache.dubbo.common.constants.CommonConstants.PID_KEY)2 REFERENCE_FILTER_KEY (org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY)2 RELEASE_KEY (org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY)2