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();
}
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);
}
}
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);
}
}
}
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;
});
}
}
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;
});
}
}
Aggregations