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