Search in sources :

Example 11 with ConfigManager

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

the class AbstractInterfaceConfig method setMonitor.

@Deprecated
public void setMonitor(MonitorConfig monitor) {
    this.monitor = monitor;
    if (monitor != null) {
        ConfigManager configManager = ApplicationModel.getConfigManager();
        configManager.getMonitor().orElseGet(() -> {
            configManager.setMonitor(monitor);
            return monitor;
        });
    }
}
Also used : ConfigManager(org.apache.dubbo.config.context.ConfigManager)

Example 12 with ConfigManager

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

the class RegistryProtocolTest method setUp.

@BeforeEach
public void setUp() {
    ApplicationModel.setApplication("RegistryProtocolTest");
    ConfigManager configManager = ApplicationModel.getConfigManager();
    ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-demo-provider");
    configManager.setApplication(applicationConfig);
    ApplicationModel.getServiceRepository().registerService(RegistryService.class);
}
Also used : ApplicationConfig(org.apache.dubbo.config.ApplicationConfig) ConfigManager(org.apache.dubbo.config.context.ConfigManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with ConfigManager

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

the class GrpcOptionsUtils method buildClientSslContext.

private static SslContext buildClientSslContext(URL url) {
    ConfigManager globalConfigManager = ApplicationModel.getConfigManager();
    SslConfig sslConfig = globalConfigManager.getSsl().orElseThrow(() -> new IllegalStateException("Ssl enabled, but no ssl cert information provided!"));
    SslContextBuilder builder = GrpcSslContexts.forClient();
    InputStream trustCertCollectionFilePath = null;
    InputStream clientCertChainFilePath = null;
    InputStream clientPrivateKeyFilePath = null;
    try {
        trustCertCollectionFilePath = sslConfig.getClientTrustCertCollectionPathStream();
        if (trustCertCollectionFilePath != null) {
            builder.trustManager(trustCertCollectionFilePath);
        }
        clientCertChainFilePath = sslConfig.getClientKeyCertChainPathStream();
        clientPrivateKeyFilePath = sslConfig.getClientPrivateKeyPathStream();
        if (clientCertChainFilePath != null && clientPrivateKeyFilePath != null) {
            String password = sslConfig.getClientKeyPassword();
            if (password != null) {
                builder.keyManager(clientCertChainFilePath, clientPrivateKeyFilePath, password);
            } else {
                builder.keyManager(clientCertChainFilePath, clientPrivateKeyFilePath);
            }
        }
    } catch (Exception e) {
        throw new IllegalArgumentException("Could not find certificate file or find invalid certificate.", e);
    } finally {
        safeCloseStream(trustCertCollectionFilePath);
        safeCloseStream(clientCertChainFilePath);
        safeCloseStream(clientPrivateKeyFilePath);
    }
    try {
        return builder.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 14 with ConfigManager

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

the class Environment method initialize.

@Override
public void initialize() throws IllegalStateException {
    ConfigManager configManager = ApplicationModel.getConfigManager();
    Optional<Collection<ConfigCenterConfig>> defaultConfigs = configManager.getDefaultConfigCenter();
    defaultConfigs.ifPresent(configs -> {
        for (ConfigCenterConfig config : configs) {
            this.setExternalConfigMap(config.getExternalConfiguration());
            this.setAppExternalConfigMap(config.getAppExternalConfiguration());
        }
    });
    this.externalConfiguration.setProperties(externalConfigurationMap);
    this.appExternalConfiguration.setProperties(appExternalConfigurationMap);
}
Also used : ConfigCenterConfig(org.apache.dubbo.config.ConfigCenterConfig) Collection(java.util.Collection) 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