Java Code Examples for org.wso2.carbon.config.provider.ConfigProvider#getConfigurationObject()
The following examples show how to use
org.wso2.carbon.config.provider.ConfigProvider#getConfigurationObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileBasedUserStore.java From ballerina-message-broker with Apache License 2.0 | 6 votes |
@Override public void initialize(StartupContext startupContext, Map<String, String> properties) throws Exception { Path usersYamlFile; String usersFilePath = System.getProperty(BrokerAuthConstants.SYSTEM_PARAM_USERS_CONFIG); if (usersFilePath == null || usersFilePath.trim().isEmpty()) { // use current path. usersYamlFile = Paths.get("", BrokerAuthConstants.USERS_FILE_NAME).toAbsolutePath(); } else { usersYamlFile = Paths.get(usersFilePath).toAbsolutePath(); } ConfigProvider configProvider = ConfigProviderFactory.getConfigProvider(usersYamlFile, null); UsersFile usersFile = configProvider .getConfigurationObject(BrokerAuthConstants.USERS_CONFIG_NAMESPACE, UsersFile.class); if (usersFile != null) { List<UserConfig> usersList = usersFile.getUserConfigs(); for (UserConfig userConfig : usersList) { if (userConfig != null && userConfig.getUsername() != null) { userRegistry.put(userConfig.getUsername(), new User(userConfig.getUsername(), userConfig.getPassword().toCharArray(), new HashSet<>(userConfig.getRoles()))); } else { LOGGER.error("User or username can not be null"); } } } }
Example 2
Source File: HTTPMonitoringConfigBuilder.java From msf4j with Apache License 2.0 | 5 votes |
public static HTTPMonitoringConfig build() { HTTPMonitoringConfig configurationObject; ConfigProvider configProvider = AnalyticUtils.getConfigurationProvider(); try { configurationObject = configProvider.getConfigurationObject(HTTPMonitoringConfig.class); } catch (ConfigurationException e) { throw new RuntimeException( "Error while loading " + HTTPMonitoringConfig.class.getName() + " from config provider", e); } return configurationObject; }
Example 3
Source File: CarbonRuntimeFactory.java From carbon-kernel with Apache License 2.0 | 5 votes |
public static CarbonRuntime createCarbonRuntime(ConfigProvider configProvider) throws Exception { CarbonConfiguration carbonConfiguration = configProvider.getConfigurationObject( CarbonConfiguration.class); PrivilegedCarbonRuntime carbonRuntime = new DefaultCarbonRuntime(); carbonRuntime.setCarbonConfiguration(carbonConfiguration); return carbonRuntime; }
Example 4
Source File: MicroservicesServerSC.java From msf4j with Apache License 2.0 | 4 votes |
@Reference( name = "carbon.config.provider", service = ConfigProvider.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unregisterConfigProvider" ) protected void registerConfigProvider(ConfigProvider configProvider) { DataHolder.getInstance().setConfigProvider(configProvider); try { final TransportsConfiguration transportsConfiguration; Object transportConf = configProvider.getConfigurationObject(STREAMLINED_TRANSPORT_NAMESPACE); if (transportConf != null) { transportsConfiguration = Utils.resolveTransportsNSConfiguration(transportConf); } else { transportsConfiguration = configProvider.getConfigurationObject (MSF4JConstants.WSO2_TRANSPORT_HTTP_CONFIG_NAMESPACE, TransportsConfiguration.class); } CarbonConfiguration carbonConfig = configProvider.getConfigurationObject(CarbonConfiguration.class); transportsConfiguration.getListenerConfigurations().forEach( listenerConfiguration -> listenerConfiguration.setPort( listenerConfiguration.getPort() + carbonConfig.getPortsConfig().getOffset())); Set<ListenerConfiguration> listenerConfigurations = transportsConfiguration.getListenerConfigurations(); if (listenerConfigurations.isEmpty()) { listenerConfigurations = new HashSet<>(); listenerConfigurations.add(new ListenerConfiguration()); } ServerBootstrapConfiguration serverBootstrapConfiguration = HttpConnectorUtil.getServerBootstrapConfiguration(transportsConfiguration.getTransportProperties()); HttpWsConnectorFactory connectorFactory = new DefaultHttpWsConnectorFactory(); listenerConfigurations.forEach(listenerConfiguration -> { ServerConnector serverConnector = connectorFactory.createServerConnector(serverBootstrapConfiguration, listenerConfiguration); MicroservicesRegistryImpl microservicesRegistry = new MicroservicesRegistryImpl(); Map<String, MicroservicesRegistryImpl> microservicesRegistries = DataHolder.getInstance().getMicroservicesRegistries(); Dictionary<String, String> properties = new Hashtable<>(); properties.put(MSF4JConstants.CHANNEL_ID, serverConnector.getConnectorID()); microservicesRegistries.put(serverConnector.getConnectorID(), microservicesRegistry); DataHolder.getInstance().getBundleContext() .registerService(MicroservicesRegistry.class, microservicesRegistry, properties); listenerConfigurationMap.put(serverConnector.getConnectorID(), listenerConfiguration); serverConnectors.add(serverConnector); }); } catch (ConfigurationException e) { log.error("Error while loading TransportsConfiguration", e); throw new RuntimeException("Error while loading TransportsConfiguration", e); } StartupServiceUtils.updateServiceCache("wso2-microservices-server", ConfigProvider.class); }